From 130aa5458d0af29a24d5049c12715b442b0d9029 Mon Sep 17 00:00:00 2001 From: "Aung Ko Ko Lin (Quartile)" <45355704+AungKoKoLin1997@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:32:04 +0700 Subject: [PATCH] [4258][FIX] template_content_swapper (#5) * [FIX] template_content_swapper --- template_content_swapper/models/ir_ui_view.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/template_content_swapper/models/ir_ui_view.py b/template_content_swapper/models/ir_ui_view.py index ce9062d..490da6d 100644 --- a/template_content_swapper/models/ir_ui_view.py +++ b/template_content_swapper/models/ir_ui_view.py @@ -14,15 +14,14 @@ class IrUiView(models.Model): def _render_template(self, template, values=None): result = super()._render_template(template, values) result_str = str(result) - lang_code = "en_US" - request = values.get("request") - if request: + lang_code = self.env.user.lang + if values and values.get("request"): # For views - lang_code = request.env.lang + lang_code = values.get("request").env.lang else: - # For reports lang_match = re.search(r'data-oe-lang="([^"]+)"', result_str) if lang_match: + # For reports lang_code = lang_match.group(1) view = self.browse(self.get_view_id(template)).sudo() content_mappings = (