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. ()
Creează-ți un cont astăzi pentru a beneficia de funcții exclusive și a interacționa cu minunata noastră comunitate!
Înscrie-te| Postări similare | Răspunsuri | Vizualizări | Activitate | |
|---|---|---|---|---|
|
Line Spacing in Odoo 17
Rezolvat
|
3
sept. 25
|
4939 | ||
|
6
mar. 24
|
23595 | |||
|
4
iul. 25
|
37518 | |||
|
Integer Field Converts Value to Zero
Rezolvat
|
1
mar. 23
|
3965 | ||
|
1
nov. 22
|
9869 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.