Skip to Content
Menu
This question has been flagged
5 Replies
2714 Views

here's my method:

@api.multi
def action_invoice_open(self):
res = super(AccountInvoice, self).action_invoice_open()
for record in self:
obj = record.env['account.asset.category'].search(
[('method_number', '=', record.invoice_line_ids.total_months)], limit=1).id
if record.invoice_line_ids.deferred_revenue == True:
for rec in record:
rec.env['account.asset.asset'].create({
'name': rec.name or 'kkkkk',
'category_id': obj,
'date': rec.date,
'value': rec.invoice_line_ids.price_subtotal,
'partner_id': rec.partner_id.id,
'invoice_id': rec.id,

})
return res

it gives this error


ValueError: Expected singleton: account.invoice.line(494, 495, 496)
Error is in the bold line. Any help? 
P.S: I'm getting these values from line and it works fine with single line value but gives error when i add multiple lines.
Avatar
Discard
Best Answer

for line in record.invoice_line_ids:

Avatar
Discard
Best Answer

you need to loop record.invoice_line_ids

for line in record.invoice_line_ids:
    if line.deferred_revenue == True:
        ......
Avatar
Discard
Author Best Answer

i got your point i'm iterating this in the 1st for loop but it isnt iterating then i'll have to think differently.

Avatar
Discard

you have to iterate record.invoice_line_ids

Best Answer

Hi,

In the above code record.invoice_line_ids will return multiple values, cant see you have iterated this over a for loop. Iterate this over a loop or adjust accordingly such a way it will return single value. 

If you add a print statement in the code, you can see it will hold multiple records.

Thanks

Avatar
Discard
Related Posts Replies Views Activity
2
Jul 23
1226
5
Feb 20
8021
1
Dec 19
4948
1
Mar 16
3296
4
Mar 24
299