[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
This commit is contained in:
@@ -6,7 +6,7 @@ import logging
|
|||||||
from lxml import etree, html
|
from lxml import etree, html
|
||||||
|
|
||||||
from odoo.exceptions import AccessError
|
from odoo.exceptions import AccessError
|
||||||
from odoo import api, models
|
from odoo import api, fields, models
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -33,6 +33,10 @@ class IrUiView(models.Model):
|
|||||||
def extract_embedded_fields(self, arch):
|
def extract_embedded_fields(self, arch):
|
||||||
return arch.xpath('//*[@data-oe-model != "ir.ui.view"]')
|
return arch.xpath('//*[@data-oe-model != "ir.ui.view"]')
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def get_default_lang_code(self):
|
||||||
|
return False
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def save_embedded_field(self, el):
|
def save_embedded_field(self, el):
|
||||||
Model = self.env[el.get('data-oe-model')]
|
Model = self.env[el.get('data-oe-model')]
|
||||||
@@ -44,7 +48,10 @@ class IrUiView(models.Model):
|
|||||||
|
|
||||||
if value is not None:
|
if value is not None:
|
||||||
# TODO: batch writes?
|
# 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):
|
def _pretty_arch(self, arch):
|
||||||
# remove_blank_string does not seem to work on HTMLParser, and
|
# remove_blank_string does not seem to work on HTMLParser, and
|
||||||
|
|||||||
@@ -146,3 +146,12 @@ class View(models.Model):
|
|||||||
if full:
|
if full:
|
||||||
return views
|
return views
|
||||||
return views.filtered(lambda v: v.customize_show)
|
return views.filtered(lambda v: v.customize_show)
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def get_default_lang_code(self):
|
||||||
|
website_id = self.env.context.get('website_id')
|
||||||
|
if website_id:
|
||||||
|
lang_code = self.env['website'].browse(website_id).default_lang_code
|
||||||
|
return lang_code
|
||||||
|
else:
|
||||||
|
return super(View, self).get_default_lang_code()
|
||||||
|
|||||||
Reference in New Issue
Block a user