Upload Products with additional images
parent
75f4534d3b
commit
d6faa73c69
|
|
@ -93,16 +93,18 @@ class ProductTemplate(models.Model):
|
||||||
self.check_not_specified_fields(vals)
|
self.check_not_specified_fields(vals)
|
||||||
vals = self.correct_values(vals)
|
vals = self.correct_values(vals)
|
||||||
product_template = self.with_context(active_test=False).search([('default_code', '=', vals['default_code'])])
|
product_template = self.with_context(active_test=False).search([('default_code', '=', vals['default_code'])])
|
||||||
|
pid = 0
|
||||||
if product_template:
|
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
|
# 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)
|
vals.pop('default_code',None)
|
||||||
if product_template['manufacturing_number']:
|
if product_template['manufacturing_number']:
|
||||||
vals.pop('manufacturing_number',None)
|
vals.pop('manufacturing_number',None)
|
||||||
product_template.write(vals)
|
product_template.write(vals)
|
||||||
|
pid = product_template.id
|
||||||
else:
|
else:
|
||||||
if vals['active']:
|
if vals['active']:
|
||||||
self.create(vals)
|
pid = self.create(vals)
|
||||||
return True
|
return True, pid
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def correct_values(self, vals):
|
def correct_values(self, vals):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue