0
votes

I have override create() method in my product_product and product_template class. When I use view with model product.product and try to create new record (new product) by pressing Save, both create() methods are called: first in product_product then in product_template. This causes a problem because of the different vals values. I expected only product_product create() to be called. Here is the code snippet:

class product_product(osv.Model):
    _inherit = 'product.product'

    def create(self, cr, uid, vals, context=None):
    # ... validation code
    return super(product_product, self).create(cr, uid, vals, context=context)

class product_template(osv.Model):
    _inherit = 'product.template'

    def create(self, cr, uid, vals, context=None):
    # ... validation code
    return super(product_template, self).create(cr, uid, vals, context=context) 
1
Every product has a required field linking it to a template (product_tmpl_id), so if you don't provide it with an existing template it has to create a new one.Ludwik Trammer
Thanks for the comment Ludwik.SmithMcPatrick
Can you put your question as resolved ?Quentin THEURET

1 Answers

0
votes

Every product has a required field linking it to a template (product_tmpl_id), so if you don't provide it with an existing template it has to create a new one. – Ludwik Trammer Dec 10 at 10:56