summaryrefslogtreecommitdiff
path: root/addons/web_editor/models/ir_ui_view.py
diff options
context:
space:
mode:
authorGoffin Simon <sig@odoo.com>2017-06-19 13:49:17 +0200
committerGoffin Simon <sig@odoo.com>2017-06-21 12:02:06 +0200
commit036ccbeff1ae9215bc02c45f60ee8f519ba94a8f (patch)
treeaaff895ac67c5502b3ddace8c7eb8b21012ea16d /addons/web_editor/models/ir_ui_view.py
parent18152f35b6a0db7d710c41c7a1040808d7e36bde (diff)
[FIX] web_editor: Translating a product in the website
Steps to reproduce the bug: -Change the default lang on the website to be different than en_US -Edit the name of a product in the website Bug: The name of the product is changed in en_US and not in the language set on the website. The lang is in fact removed from the context in function saveElement(in addons/web_editor/static/rte.js). opw:747084
Diffstat (limited to 'addons/web_editor/models/ir_ui_view.py')
-rw-r--r--addons/web_editor/models/ir_ui_view.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/addons/web_editor/models/ir_ui_view.py b/addons/web_editor/models/ir_ui_view.py
index c50922bdce3..48a94e4b8cb 100644
--- a/addons/web_editor/models/ir_ui_view.py
+++ b/addons/web_editor/models/ir_ui_view.py
@@ -6,7 +6,7 @@ import logging
from lxml import etree, html
from odoo.exceptions import AccessError
-from odoo import api, models
+from odoo import api, fields, models
_logger = logging.getLogger(__name__)
@@ -34,6 +34,10 @@ class IrUiView(models.Model):
return arch.xpath('//*[@data-oe-model != "ir.ui.view"]')
@api.model
+ def get_default_lang_code(self):
+ return False
+
+ @api.model
def save_embedded_field(self, el):
Model = self.env[el.get('data-oe-model')]
field = el.get('data-oe-field')
@@ -44,7 +48,10 @@ class IrUiView(models.Model):
if value is not None:
# TODO: batch writes?
- Model.browse(int(el.get('data-oe-id'))).write({field: value})
+ if self.get_default_lang_code() and field != 'arch' and not isinstance(Model._fields[field], fields.Html):
+ Model.browse(int(el.get('data-oe-id'))).with_context(lang=self.get_default_lang_code()).write({field: value})
+ else:
+ Model.browse(int(el.get('data-oe-id'))).write({field: value})
def _pretty_arch(self, arch):
# remove_blank_string does not seem to work on HTMLParser, and