In a Web emailtemplate I use a variable set with a '.' as decimal for calculation.
How can I show it with a ',' as decimal?
Apparently .replace() doesn't work with integers and format() needs a second argument. But which one?
Regards,
Luc
In a Web emailtemplate I use a variable set with a '.' as decimal for calculation.
How can I show it with a ',' as decimal?
Apparently .replace() doesn't work with integers and format() needs a second argument. But which one?
Regards,
Luc
Thanks Muhammad!
But isn't there a way to just format to the system's main decimal setting?
Hello Luc,
.replace() works only on strings, so first format/convert the value, then replace the decimal separator.
For example:
${"{:.2f}".format(object.your_value).replace(".", ",")}or, if it is already calculated:
${"{:.2f}".format(your_variable).replace(".", ",")}Here, :.2f is the second argument/format specification: it means “show the number with 2 decimals”.
Example:
12.5 → 12,50
So the issue is not the comma itself, but that the number must first be converted/formatted as a string before using .replace().
Odoo email templates allow dynamic placeholders and direct HTML/XML editing, so this kind of expression can be used in the template code. () Similar Odoo examples also use Python-style formatting such as "%.2f" % object.amount_total or "{:.2f}".format(value) for decimal display. ()
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrire| Publications associées | Réponses | Vues | Activité | |
|---|---|---|---|---|
|
Line Spacing in Odoo 17
Résolu
|
3
sept. 25
|
4754 | ||
|
6
mars 24
|
23475 | |||
|
4
juil. 25
|
37400 | |||
|
1
mars 23
|
3901 | |||
|
1
nov. 22
|
9742 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.