Skip to content
Snippets Groups Projects
Commit c3f81c52 authored by Vipul Bhatt's avatar Vipul Bhatt Committed by Pierre Masereel
Browse files

[FIX] product: error during migration

Barcode, default_code (Internal Reference), standard_price,
volume, weight fields are not saved when we create a new product.

This is due to the fact that these fields need the product_variant_ids
field to be set, in order to compute their values.

Due to migration in rev https://github.com/odoo-dev/odoo/commit/1aa5bc0fdfa402ac7cccbc3a7203ec5050f6339b
parent e59a7fe3
No related branches found
No related tags found
No related merge requests found
......@@ -265,6 +265,21 @@ class ProductTemplate(models.Model):
template = super(ProductTemplate, self).create(vals)
if "create_product_product" not in self._context:
template.create_variant_ids()
# This is needed to set given values to first variant after creation
related_vals = {}
if vals.get('barcode'):
related_vals['barcode'] = vals['barcode']
if vals.get('default_code'):
related_vals['default_code'] = vals['default_code']
if vals.get('standard_price'):
related_vals['standard_price'] = vals['standard_price']
if vals.get('volume'):
related_vals['volume'] = vals['volume']
if vals.get('weight'):
related_vals['weight'] = vals['weight']
if related_vals:
template.write(related_vals)
return template
@api.multi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment