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. ()
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj się| Powiązane posty | Odpowiedzi | Widoki | Czynność | |
|---|---|---|---|---|
|
Line Spacing in Odoo 17
Rozwiązane
|
3
wrz 25
|
4758 | ||
|
6
mar 24
|
23477 | |||
|
Limit the number of digits in integer?
Rozwiązane
|
4
lip 25
|
37401 | ||
|
Integer Field Converts Value to Zero
Rozwiązane
|
1
mar 23
|
3901 | ||
|
1
lis 22
|
9742 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.