Hi,
I'm new to Odoo, and I need to override a existing method.
What i need is to insert new lines on Bill Of Material tree, on changing product template id.
There are just a method on mrp_bom class, called onchange_product_tmpl_id, so according with what i understood, i need to inherit the mrp_bom class in a new class, and override the onchange_product_tmpl_id method with a new one.
How can I override the method with new api (the old super() in OpenERP) and fire the onchange method when ai change the product template id?
Something like that:
class bom_template(models.Model):
_inherit = 'mrp.bom'
@api.onchange
def _populate_bom_lines(self):
lines =[]
for val in self.bom_template: #value on a BOM template that cointain products
line_item = {
'attr1': val.name,
'attr2': val.a1,
...
}
lines += [line_item]
self.update({'line': lines})