Odoo reporting I want to insert comma in t-option float_time

39 views Asked by At

"I have a variable ot10_total with a value of 1758.92. I successfully added commas to format it using the code <span t-esc="'{0:,.2f}'.format(ot10_total)"/>, and it displays as 1,758.92.

Next, I wanted to display it using the float_time widget, so I used the code <span t-esc="ot10_total" t-options="{'widget': 'float_time'}"/>, which worked, and it now shows as 1758:55.

Now, I'd like to combine both features - having commas in the ot10_total value and displaying it with the float_time widget. I attempted to use the code <span t-esc="'{0:,.2f}'.format(ot10_total)" t-options="{'widget': 'float_time'}"/> but it resulted in an error: TypeError: bad operand type for abs(): 'str'. How can I fix this?"

1

There are 1 answers

2
Yassir Irfan On

You can achieve this by formatting variable and then apply the "float_time" widget.

<span t-esc="float('{0:,.2f}'.format(ot10_total))" t-options="{'widget': 'float_time'}"/>