summaryrefslogtreecommitdiff
path: root/addons/web/models/ir_qweb.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-06-28 19:01:52 +0200
committerChristophe Simonis <chs@odoo.com>2018-06-28 19:01:52 +0200
commitc8bb02141d2801c243ae65ba6800b07f090bb5c6 (patch)
tree2d099c5577df4783a6db3d853cf0141bf41c1aa9 /addons/web/models/ir_qweb.py
parent4e2733e83a1f42773fb28f66431a0d6fb0393be9 (diff)
parent3cdcbce93cbde548d2d24426ee8de1d93f06706e (diff)
[MERGE] forward port branch saas-11.3 up to 3cdcbce93cb
Diffstat (limited to 'addons/web/models/ir_qweb.py')
-rw-r--r--addons/web/models/ir_qweb.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/addons/web/models/ir_qweb.py b/addons/web/models/ir_qweb.py
index a7376e04b5d..29426b9d8a8 100644
--- a/addons/web/models/ir_qweb.py
+++ b/addons/web/models/ir_qweb.py
@@ -2,6 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import hashlib
+from collections import OrderedDict
from odoo import api, models
from odoo.tools import pycompat
@@ -57,6 +58,24 @@ class Image(models.AbstractModel):
elif options.get('zoom'):
src_zoom = options['zoom']
- img = '<img class="%s" src="%s" style="%s"%s%s/>' % \
- (classes, src, options.get('style', ''), ' alt="%s"' % alt if alt else '', ' data-zoom="1" data-zoom-image="%s"' % src_zoom if src_zoom else '')
- return pycompat.to_text(img)
+ atts = OrderedDict()
+ atts["src"] = src
+ atts["class"] = classes
+ atts["style"] = options.get('style')
+ atts["alt"] = alt
+ atts["data-zoom"] = src_zoom and u'1' or None
+ atts["data-zoom-image"] = src_zoom
+
+ atts = self.env['ir.qweb']._post_processing_att('img', atts, options.get('template_options'))
+
+ img = ['<img']
+ for name, value in atts.items():
+ if value:
+ img.append(' ')
+ img.append(escape(pycompat.to_text(name)))
+ img.append('="')
+ img.append(escape(pycompat.to_text(value)))
+ img.append('"')
+ img.append('/>')
+
+ return u''.join(img)