I am stuck in a simple if condition for the below code
for invoice in invoice_objs:
invoice_date = invoice.invoice_date.strftime('%Y-%m-%d')
worksheet.write(row, 0, invoice_date)
worksheet.write(row, 1, invoice.name)
worksheet.write(row, 2, invoice.partner_id.name)
worksheet.write(row, 3, ', '.join(invoice.invoice_line_ids.mapped('product_id.name')))
--> worksheet.write(row, 4, ', '.join(invoice.invoice_line_ids.mapped('tax_ids.name')))
worksheet.write(row, 5, ', '.join(str(i) for i in invoice.invoice_line_ids.mapped('price_subtotal')))
--> if invoice.invoice_line_ids.mapped('tax_ids.name') == 'Sales VAT':
worksheet.write(row, 6, '15%')
else:
worksheet.write(row, 6, '0%')
row += 1
key = u'_'.join((invoice.partner_id.name, invoice.currency_id.name)).encode('utf-8')
key = str(key, 'utf-8')
I just want to fetch the value of one excel field and use in if condition
If tax_ids.name == 'Sales VAT'
it should print 15%
else
0%
but for all the lines its taking only the else condition i.e 0%
Invoice Date | Invoice Number | Customer | Invoice Description | Tax Name | Total before VAT | VAT % |
2022-01-17 | INV/2022/0001 | Administrator | Betrillix | Sales VAT | 2173.91 | 0% |
2022-01-05 | INV/2022/0003 | My Company | Betrillix, Sample | Sales VAT | 60.0, 30.0 | 0% |
2022-01-03 | INV/2022/0004 | My Company | Betrillix | Sales VAT | 2500.0 | 0% |
2022-01-03 | INV/2022/0002 | Administrator | Betrillix | Sales VAT | 500.0 | 0% |