From b4cbac3cba20f9e8e3956c7104bd6589d78f953d Mon Sep 17 00:00:00 2001 From: kevin wang Date: Tue, 17 Jun 2014 10:48:44 +0200 Subject: [PATCH] [FIX] product: create works for internal reference and ean13 code in product.template This is a temporary workaround until these fields are removed from the template or the view is more explicit about the meaning of this field (the one on the first variant) Fix #542 --- addons/product/product.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/addons/product/product.py b/addons/product/product.py index db86047c10a..b7090841dde 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -675,6 +675,17 @@ class product_template(osv.osv): 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) + + # TODO: this is needed to set given values to first variant after creation + # these fields should be moved to product as lead to confusion + related_vals = {} + if vals.get('ean13'): + related_vals['ean13'] = vals['ean13'] + if vals.get('default_code'): + related_vals['default_code'] = vals['default_code'] + if related_vals: + self.write(cr, uid, product_template_id, related_vals, context=context) + return product_template_id def write(self, cr, uid, ids, vals, context=None):