From d24aede8d7c2867eca8974eacd4fe7522dbc40af Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Tue, 27 May 2014 18:03:15 +0200 Subject: [PATCH] [FIX] product: don't create new variants if the product.template is create by product.product. --- addons/product/product.py | 9 ++++++++- addons/product/product_demo.xml | 19 ++++++++++++++++--- addons/website_sale/data/demo.xml | 4 ++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/addons/product/product.py b/addons/product/product.py index 634fb02cf48..cff70c9e6b9 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -663,7 +663,8 @@ class product_template(osv.osv): def create(self, cr, uid, vals, context=None): ''' Store the initial standard price in order to be able to retrieve the cost of a product template for a given date''' product_template_id = super(product_template, self).create(cr, uid, vals, context=context) - self.create_variant_ids(cr, uid, [product_template_id], context=context) + if not context or "create_product_product" not in context: + self.create_variant_ids(cr, uid, [product_template_id], context=context) self._set_standard_price(cr, uid, product_template_id, vals.get('standard_price', 0.0), context=context) return product_template_id @@ -1045,6 +1046,12 @@ class product_product(osv.osv): 'res_id': product.product_tmpl_id.id, 'target': 'new'} + def create(self, cr, uid, vals, context=None): + if context is None: + context = {} + context.update(create_product_product=True) + return super(product_product, self).create(cr, uid, vals, context=context) + class product_packaging(osv.osv): _name = "product.packaging" diff --git a/addons/product/product_demo.xml b/addons/product/product_demo.xml index 7ebd89b906b..95cfbda7a27 100644 --- a/addons/product/product_demo.xml +++ b/addons/product/product_demo.xml @@ -155,6 +155,14 @@ HDD SH-1 + + Wi-Fi + + + 2.4 GHz + + + iPad Retina Display @@ -195,9 +203,14 @@ FaceTime HD Camera, 1.2 MP Photos + + + + + - + @@ -296,14 +309,14 @@ FaceTime HD Camera, 1.2 MP Photos - + - + diff --git a/addons/website_sale/data/demo.xml b/addons/website_sale/data/demo.xml index 5fc2f7e5eed..a4380c3d7dd 100644 --- a/addons/website_sale/data/demo.xml +++ b/addons/website_sale/data/demo.xml @@ -6,6 +6,10 @@ + + color + + 2