Odoo - OpenERP - Syntax Migration from OpenERP 7 to Odoo v8 - How & What are Changes ?

Support
Support
5000
| 2 1 2
Asked on 8/15/15, 7:30 AM
0
vote
2864 Views

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’)

Support
Support
5000
| 2 1 2
Answered on 8/15/15, 7:30 AM
0
vote

Your answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

Ask a Question

Keep Informed

About This Forum

This forum is for HiTechnologia Employees & just Odoo general knowledge purpose only.

Read Guidelines

Question tools

3 follower(s)

Stats

Asked: 8/15/15, 7:30 AM
Seen: 2864 times
Last updated: 8/15/15, 7:30 AM