Inheriting old methods in version 8
2 answers
You only need to update the odoo engine code, which itself manages the update / downgrade engine as needed.
from openerp import models, fields, api, _
class product_product(models.Model):
_inherit= "product.product"
_description = "Product"
@api.model
def create(self, vals):
### Add your code here
return super(product_product, self).create(vals);
@api.multi
def write(self, vals):
### Add your code here
return super(product_product, self).write(vals);
Likewise, you can override any legacy methods except exchange methods. in onchange methods, you need to provide the definition in the old template.
+1
source to share
yes, you can override v8 method in v7
from openerp import models, fields, api, _
class product_product(models.Model):
_inherit= "product.product"
_description = "Product"
@api.v7
def _product_code(self, cr, uid, ids, name, arg, context=None):
res = {}
if context is None:
context = {}
for p in self.browse(cr, uid, ids, context=context):
res[p.id] = self._get_partner_code_name(cr, uid, [], p, context.get('partner_id', None), context=context)['code']
return res
I am just overriding v7 _product_code method
in my new API product class for Odoo 8.0.
Hope my answer can help you :)
+2
source to share