Skip to content

Commit

Permalink
[FIX] product_multi_image: Do not resize large image to small/medium
Browse files Browse the repository at this point in the history
when saved from single image
  • Loading branch information
FFernandez-PlanetaTIC committed Jul 5, 2018
1 parent 0e922b1 commit 846709c
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion product_multi_image/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -22,3 +22,30 @@ 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()):
# medium/small image is saved as large
# on load image will be medium/small resized on the fly
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):
# on save product module resizes large image to medium
# medium image should not overwrite the large
pass

@api.multi
def _set_multi_image_main_small(self):
# on save product module resizes large image to small
# small image should not overwrite the large
pass

0 comments on commit 846709c

Please sign in to comment.