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. ()
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
Registrarse| Publicaciones relacionadas | Respuestas | Vistas | Actividad | |
|---|---|---|---|---|
|
Line Spacing in Odoo 17
Resuelto
|
3
sept 25
|
4758 | ||
|
6
mar 24
|
23477 | |||
|
4
jul 25
|
37401 | |||
|
Integer Field Converts Value to Zero
Resuelto
|
1
mar 23
|
3901 | ||
|
1
nov 22
|
9742 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.