diff options
| author | Parth Gajjar <pga@openerp.com> | 2017-11-16 12:40:22 +0530 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2018-03-15 11:30:53 +0100 |
| commit | 964e16a7f5598b6f2f5be75c9e591deabfaeccff (patch) | |
| tree | 45f6fabec74dc918f653425e9e7f6bc52bdf3646 /addons/web/models | |
| parent | f2f2dfaf3695cd6f1ca694c3e6b42a6ae011360d (diff) | |
[IMP] web: support famous 'avoid_if_small' parameter in image controller and qweb field options
Before this commit there was no option to avoid resizing images when it
was smaller than expected size. This leads to several image being displayed
with extra and unnecessary padding due to resize. This option will allow
to avoid that behavior by allowing to propagate the parameter directly
to image_resize_image.
This commit is related to task ID 31994 .
Diffstat (limited to 'addons/web/models')
| -rw-r--r-- | addons/web/models/ir_qweb.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/addons/web/models/ir_qweb.py b/addons/web/models/ir_qweb.py index 5c94da64d53..a7376e04b5d 100644 --- a/addons/web/models/ir_qweb.py +++ b/addons/web/models/ir_qweb.py @@ -42,7 +42,8 @@ class Image(models.AbstractModel): sha = hashlib.sha1(getattr(record, '__last_update').encode('utf-8')).hexdigest()[0:7] max_size = '' if max_size is None else '/%s' % max_size - src = '/web/image/%s/%s/%s%s?unique=%s' % (record._name, record.id, field_name, max_size, sha) + avoid_if_small = '&avoid_if_small=true' if options.get('avoid_if_small') else '' + src = '/web/image/%s/%s/%s%s?unique=%s%s' % (record._name, record.id, field_name, max_size, sha, avoid_if_small) alt = None if options.get('alt-field') and getattr(record, options['alt-field'], None): |
