3

I have been trying to display a calculated variable in qweb separated by comma's.

<td align="right">
                      <t t-set="total" t-value="0"/>
                          <t t-foreach="l.invoice_line_tax_id" t-as="t">
                          <t t-set="total" t-value="total + (t.amount * 
l.price_subtotal)" />
                          </t>
                          <span t-esc="'%.2f'%(l.price_subtotal + total)"/>

                </td>

-

This line displays the values with decimal points, whereas the digits before decimal is not separated by comma's.

For example, the above code would display value as 400000.00 whereas I would like it to be 4,00,000.00

Anyone with any idea on this.?

ChesuCR
  • 9,352
  • 5
  • 51
  • 114
Shravy
  • 656
  • 1
  • 23
  • 61

2 Answers2

2

Try below code,

<span><t t-esc="'{0:,.2f}'.format(inv_value)"/></span>

Hope it will help you.

KbiR
  • 4,047
  • 6
  • 37
  • 103
1

This one may help you:

You need to calculate total in *.py side. by creating function field like this.

total = fields.Float('Total', compute='_cal_total') 

@api.one
def _cal_total(self):
     self.total = t.amount * l.price_subtotal

and show in *.xml field like this.

<field name="total" widget='monetary'
options="{'currency_field': 'currency_id'}" />
Luuklag
  • 3,897
  • 11
  • 38
  • 57
Thawatchai
  • 133
  • 1
  • 7
  • this could be of help, But I dont want to get going with declaring fields in my .py file. Right now I am just declaring a field in qweb reports. – Shravy Aug 09 '17 at 03:24