Browse Source

[IMP] py3o_report: Allow to specify the lang when calling o_format_lang

lang_code is already supported by o_format_date
pull/347/head
Laurent Mignon (ACSONE) 6 years ago
parent
commit
dfbe696bd8
  1. 2
      report_py3o/README.rst
  2. 8
      report_py3o/models/_py3o_parser_context.py

2
report_py3o/README.rst

@ -167,7 +167,7 @@ display_address(partner)
formatLang(value, digits=None, date=False, date_time=False, grouping=True, monetary=False, dp=False, currency_obj=False)
Return a formatted numeric, monetary, date or time value according to the context language and timezone
(old implementation kept for compatibility and ease migration)
o_format_lang(value, digits=None, grouping=True, monetary=False, dp=False, currency_obj=False, no_break_space=True)
o_format_lang(value, lang_code=False, digits=None, grouping=True, monetary=False, dp=False, currency_obj=False, no_break_space=True)
Return a formatted numeric or monetary value according to the context language and timezone
o_format_date(value, lang_code=False, date_format=False)
Return a formatted date or time value according to the context language and timezone

8
report_py3o/models/_py3o_parser_context.py

@ -49,11 +49,15 @@ class Py3oParserContext(object):
'b64decode': b64decode,
}
def _format_lang(self, value, digits=None, grouping=True,
def _format_lang(self, value, lang_code=False, digits=None, grouping=True,
monetary=False, dp=False, currency_obj=False,
no_break_space=True):
env = self._env
if lang_code:
context = dict(env.context, lang=lang_code)
env = env(context=context)
formatted_value = misc.formatLang(
self._env, value, digits=digits, grouping=grouping,
env, value, digits=digits, grouping=grouping,
monetary=monetary, dp=dp, currency_obj=currency_obj)
if currency_obj and currency_obj.symbol and no_break_space:
parts = []

Loading…
Cancel
Save