Skip to Content
Menu
This question has been flagged
1 Reply
1529 Views

I am creating an excel report for invoice line details in odoo 13,

Its all well when there is single invoice line but when it comes to multiple invoice line, I get an issue

Here I am pasting my code

for wizard in self:
heading = 'Sales VAT Summary Report'
worksheet.write_merge(0, 0, 0, 9, heading, easyxf(
'font:height 300; align: horiz center;pattern: pattern solid, fore_color black; font: color white; font:bold True;' "borders: top thin,bottom thin"))
invoice_objs = self.env['account.move'].search([('invoice_date', '>=', wizard.from_date),
('invoice_date', '<=', wizard.to_date)])
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, invoice.invoice_line_ids.product_id.name) --> invoice line
worksheet.write(row, 4, invoice.invoice_line_ids.tax_ids.name) --.> invoice line

I just want to use for loop and get the invoice details according to the number of lines in the invoice

Avatar
Discard
Best Answer

Hi,

Iterate the invoice_line_ids over  a for loop

for line in invoice.invoice_line_ids:

    row += 1
    worksheet.write(row, 3, line.product_id.name)


Thanks


Avatar
Discard
Author

That worked niyas thanks, but how can I repeats the invoice headers as well?

Author

Yes I got it, I just used the loop before headers
Thanks

Related Posts Replies Views Activity
1
Feb 22
61
0
Feb 22
52
0
Feb 22
50
2
Jan 22
1412
0
Jan 22
18