Odoo has a long history and the so-called "traditional" or "old" API has been in use for a very long time. When designing the "new" API in Odoo 8.0, time was taken to ensure that the APIs would be able to coexist, because it was foreseen that porting the huge codebase to the new API would be a huge effort. So you will probably come across addon modules using the traditional API. When migrating them to the current version of Odoo, you may want to port them to the new API.
This recipe explains how to perform this translation. It can also serve as an aide memoire when you need to extend a module that uses the traditional API with the new API.
Let's port the following addon module code developed with the traditional API:
from datetime import date, timedelta from openerp.osv import orm, fields from openerp.tools import _, DEFAULT_SERVER_DATE_FORMAT as DATE_FMT class library_book(orm.Model): _name = 'library.book' _columns = { 'name'...