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. ()
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up| Related Posts | Replies | Views | Activity | |
|---|---|---|---|---|
|
Line Spacing in Odoo 17
Solved
|
3
Sep 25
|
4743 | ||
|
6
Mar 24
|
23472 | |||
|
4
Jul 25
|
37398 | |||
|
1
Mar 23
|
3900 | |||
|
1
Nov 22
|
9740 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.