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 = (