diff --git a/ext/custom-addons/dp_custom/models/product.py b/ext/custom-addons/dp_custom/models/product.py index 49ada47e..475f575a 100644 --- a/ext/custom-addons/dp_custom/models/product.py +++ b/ext/custom-addons/dp_custom/models/product.py @@ -93,16 +93,18 @@ class ProductTemplate(models.Model): self.check_not_specified_fields(vals) vals = self.correct_values(vals) product_template = self.with_context(active_test=False).search([('default_code', '=', vals['default_code'])]) + pid = 0 if product_template: # default_code may not be changed if there is already an inventory_line (in other company), so we remove it from the dict vals.pop('default_code',None) if product_template['manufacturing_number']: vals.pop('manufacturing_number',None) product_template.write(vals) + pid = product_template.id else: if vals['active']: - self.create(vals) - return True + pid = self.create(vals) + return True, pid @api.model def correct_values(self, vals):