[FIX] product: Two product.price.history created for one variant
When a unique variant was created from a product template with function create_variant_ids, two product price history were created: -One was created from function create on product.product -The other one was created from function _set_standard_price on product.template The first product.price.history created in this situation was all the time set to 0 and it lead to some problems in the report inventory date. This first product.price.history doesn't have to be created. opw:747857
This commit is contained in:
@@ -314,7 +314,9 @@ class ProductProduct(models.Model):
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
product = super(ProductProduct, self.with_context(create_product_product=True)).create(vals)
|
||||
product._set_standard_price(vals.get('standard_price', 0.0))
|
||||
# When a unique variant is created from tmpl then the standard price is set by _set_standard_price
|
||||
if not (self.env.context.get('create_from_tmpl') and len(product.product_tmpl_id.product_variant_ids) == 1):
|
||||
product._set_standard_price(vals.get('standard_price') or 0.0)
|
||||
return product
|
||||
|
||||
@api.multi
|
||||
|
||||
@@ -264,7 +264,7 @@ class ProductTemplate(models.Model):
|
||||
tools.image_resize_images(vals)
|
||||
template = super(ProductTemplate, self).create(vals)
|
||||
if "create_product_product" not in self._context:
|
||||
template.create_variant_ids()
|
||||
template.with_context(create_from_tmpl=True).create_variant_ids()
|
||||
|
||||
# This is needed to set given values to first variant after creation
|
||||
related_vals = {}
|
||||
|
||||
Reference in New Issue
Block a user