Skip to content

Commit

Permalink
Merge branch '14.0-imp-report_py3o-translate_selection' of git+ssh://…
Browse files Browse the repository at this point in the history
…github.com/efatto/reporting-engine into 14.0
  • Loading branch information
Pretecno committed Feb 10, 2025
2 parents 44107fc + eba9205 commit 858f409
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions report_py3o/models/_py3o_parser_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,22 @@ def __init__(self, env):
"format_multiline_value": format_multiline_value,
"html_sanitize": mail.html2plaintext,
"b64decode": b64decode,
"o_format_lang_selection": self._format_lang_selection,
}

def _format_lang_selection(self, model, field, value, lang_code=False):
env = self._env
if lang_code:
context = dict(env.context, lang=lang_code)
env = env(context=context)
values = env["ir.translation"].get_field_selection(model, field)
formatted_value = value
for val in values:
if val[0] == value:
formatted_value = val[1]
break
return formatted_value

def _format_lang(
self,
value,
Expand Down

0 comments on commit 858f409

Please sign in to comment.