-1

I have a function that give me a quantity from a product but it displays 3 decimals and I want to show only two

<t t-esc="orderline.get_quantity_str_with_unit()" />

I tried this:

<t t-esc="orderline.get_quantity_str_with_unit().toFixed(2)"/>
  • What does `orderline.get_quantity_str_with_unit()` return? The function name suggests it returns a string containing a number and a unit. You can't call `toFixed` on a string. – jabaa Sep 06 '21 at 19:22
  • Try with `parseInt(orderline.get_quantity_str_with_unit()).toFixed(2)` – Shantun Parmar Sep 07 '21 at 06:24

1 Answers1

-2

I am assuming your function returns a string. You were not very clear with what your function returns, but try this:

Number(yourFunction()).toFixed(2)
J_K
  • 688
  • 5
  • 12