Syntax Migration from OpenERP 7 to Odoo v8

In Odoo v8 Syntax is the main thing which is new to the Developers. It’s Simple, Easy to Use and more flexible than OpenERP7 Syntax.

Here are some Syntax changes in Odoo v8 API

1. Statement:

OpenERP 7 Search Syntax:
self.pool.get(‘model.name’).search(cr, uid, [(‘operand1′,’operator’,’operand2′)])

Odoo 8 Search Syntax:
self.env[‘model.name’].search([(‘operand1′,’operator’,’operand2′)])

OpenERP7 Write Syntax:
self.pool.get(‘model.name’).write(cr, uid, ids,{”:”})

Odoo 8 Write Syntax:
self.env[‘model.name’].write({”:”})

2. _defaults:

OpenERP 7 Syntax:
_defaults={
‘field1′:’value’,
‘field2′:’value’,
….
}

Odoo 8 Syntax:
_Default is No more in Odoo 8
field_name = fields.datatype(string=’value’, default=compute_default_value)

3. _columns:

OpenERP 7 Syntax:
_columns={
‘field1′ : fields.integer(string=’value’),
‘field2′ : fields.char(default=’value’),
….
}

Odoo 8 Syntax:
No need to Write _columns, directly start writing column names as a class members
field1= fields.Integer(string=’value’)
field2= fields.Char(default=’value’)

4. field.function:

OpenERP 7 fields.function Syntax:
_columns={
‘field_name’: fields.function(‘_compute_value’, string=’value’, type=’value’, store=True/False)
}

Odoo 8 Syntax:
No fields.function
field_name= fields.type(compute=’_compute_value’, string=’value’)

5. related fields:

OpenERP 7 fields.related Syntax:
_columns={
‘field_name’: fields.related(‘first_destination_obj’, ‘second_destination_obj’, type=’value’, relation=’model.name’ , string=’value’ )
}

Odoo 8 Syntax:
No fields.related
field_name= fields.type(related=’destination object’, store=True)

6. Creating a model:

OpenERP 7 Syntax:
from osv import osv, fields
class model_name(osv.osv):
_name = ‘a.model.name’

Odoo 8 Syntax:
from openerp import models, fields
class model_name(models.Model):
_name = ‘a.model.name’

7. Syntax Case in fields type:

OpenERP 7 Syntax:
‘field1′ : fields.integer(string=’value’)
‘field2′ : fields.char(default=’value’)

Odoo 8 Syntax:

‘field1′ : fields.Integer(string=’value’)
‘field2′ : fields.Char(default=’value’)

You must be logged in to post a comment.