summaryrefslogtreecommitdiff
path: root/addons/web_editor/models
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2016-05-24 13:19:19 +0200
committerChristophe Simonis <chs@odoo.com>2016-05-24 13:19:19 +0200
commitfac4cc7006e5d72a5f6ee261e8a7422c78f5e6fb (patch)
treefacc8cb60bcd0f1d0536f6f004d05aefcf444fc7 /addons/web_editor/models
parentfacb6644839c2120296e0845b8f780cb9998e34e (diff)
parentf8e6bb73b3aed541fd96e28ec0382ea9964a1db7 (diff)
[MERGE] forward port of branch saas-9 up to f8e6bb7
Diffstat (limited to 'addons/web_editor/models')
-rw-r--r--addons/web_editor/models/ir_translation.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/addons/web_editor/models/ir_translation.py b/addons/web_editor/models/ir_translation.py
index 19627b58c57..df56cf41011 100644
--- a/addons/web_editor/models/ir_translation.py
+++ b/addons/web_editor/models/ir_translation.py
@@ -4,7 +4,7 @@
from lxml import etree
from openerp import models, api
-from openerp.tools.translate import encode, xml_translate
+from openerp.tools.translate import encode, xml_translate, html_translate
def edit_translation_mapping(data):
data = dict(data, model=data['name'].partition(',')[0])
@@ -35,4 +35,11 @@ class ir_translation(models.Model):
# root is html > body > div
# serialize div as XML and discard surrounding tags
value = etree.tostring(root[0][0], encoding='utf-8')[5:-6]
+ elif field.translate == html_translate:
+ # wrap value inside a div and parse it as HTML
+ div = "<div>%s</div>" % encode(value)
+ root = etree.fromstring(div, etree.HTMLParser(encoding='utf-8'))
+ # root is html > body > div
+ # serialize div as HTML and discard surrounding tags
+ value = etree.tostring(root[0][0], encoding='utf-8', method='html')[5:-6]
return self.write({'value': value})