From 443c38dbc0a9b70f9d0d1177ae50d52ade72d84e Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 24 Jun 2015 11:37:21 +0200 Subject: [PATCH] [IMP] product: fnct_inv of image variant Doesn't seem to have much effect, but it's probably still better to not have 3 UPDATE run every time we create a new product.product. --- addons/product/product.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/product/product.py b/addons/product/product.py index 30ee7a9a9b7..44f6dcf81a3 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -946,12 +946,12 @@ class product_product(osv.osv): def _set_image_variant(self, cr, uid, id, name, value, args, context=None): image = tools.image_resize_image_big(value) - res = self.write(cr, uid, [id], {'image_variant': image}, context=context) + product = self.browse(cr, uid, id, context=context) - if not product.product_tmpl_id.image: - product.write({'image_variant': None}) - product.product_tmpl_id.write({'image': image}) - return res + if product.product_tmpl_id.image: + product.image_variant = image + else: + product.product_tmpl_id.image = image def _get_price_extra(self, cr, uid, ids, name, args, context=None): result = dict.fromkeys(ids, False)