From ac4f4020085cb515cbd63bd79a02e65eed85c1d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Fern=C3=A1ndez=20=40PlanetaTIC?= Date: Thu, 5 Jul 2018 11:29:11 +0200 Subject: [PATCH] [FIX] product_multi_image: Do not resize large image to small/medium when saved from single image --- .../models/product_template.py | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/product_multi_image/models/product_template.py b/product_multi_image/models/product_template.py index 214488ba609c..f851789f76b8 100644 --- a/product_multi_image/models/product_template.py +++ b/product_multi_image/models/product_template.py @@ -3,7 +3,7 @@ # © 2015 Antiun Ingeniería S.L. - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import fields, models +from odoo import api, fields, models class ProductTemplate(models.Model): @@ -22,3 +22,24 @@ class ProductTemplate(models.Model): related='image_main_small', store=False, ) + + @api.multi + def write(self, vals): + if set(['image', 'image_medium', 'image_small']) & set(vals.keys()): + if 'image' in vals: + pass + elif 'image_medium' in vals: + vals['image'] = vals['image_medium'] + del vals['image_medium'] + elif 'image_small' in vals: + vals['image'] = vals['image_small'] + del vals['image_small'] + return super(ProductTemplate, self).write(vals) + + @api.multi + def _set_multi_image_main_medium(self): + pass + + @api.multi + def _set_multi_image_main_small(self): + pass