How to set number format to the user language on reports

On tryton, depending on the user language setted, the number fields would have different formats. For example, in spanish, the decimal separator is a comma (“,”), unlike english, where is a period/dot (“.”).
On the client side, both graphical client or SAO, it wouldn’t be any problem.
But at the time you want to make a report and use some number field, the default format would be using period’s as decimal separator.
To make the number as the user language format looks like, you have to use the format_number function on your template.
Supposed that you have a Numeric field named number. In case you are using and fodt, all you have to do is

format_number(number, None)

In case you are using an fods

relatorio://format_number(number, None)

In this case, the number would be format on the user language setted. In the case a more specific language is needed, just change the None with the language code.
And that’s all

1 Like