Skip to Content
Menú
This question has been flagged
2 Respostes
9497 Vistes

Hi,

i'm trying to build a function that will Create Automatic Journal( account.move). More than 1 account.move.line

i don't know the exact way to add multiple lines 

any help would be appreciated 

here's my code:


for payment in payments:
payment.phase = self.phase
 "credit": payment.amount,

move_vals = {
"date": datetime.date.today(),
"journal_id": payment.journal_id.id,
"ref": payment.communication,
"company_id": payment.company_id.id,
"name": str(payment.name),
"state": "posted",
"line_ids": move_line_vals,
}
self.env['account.move'].create(move_vals)
I just don't know how to declare move_line_vals 

Thanks.

Avatar
Descartar
Best Answer

Hi,

You can try like this,

move_line_vals = []
for a in ABCD:
line = (0, 0, {'product_id': a.product_id.id, 'product_qty': a.product_qty,
'product_uom_id': a.product_id.uom_id.id})
move_line_vals.append(line)
# insert necessary values to this list move_line_vals
# here given fields inside the dictionary are sample
move_vals = {
"date": datetime.date.today(),
"journal_id": payment.journal_id.id,
"ref": payment.communication,
"company_id": payment.company_id.id,
"name": str(payment.name),
"state": "posted",
"line_ids": move_line_vals,
}
self.env['account.move'].create(move_vals)

Thanks

Avatar
Descartar

hi Niyas, hi Ali, i am copying data in model called x_case. so i replace for a in ABCD by for a in record.x_case:. However, i've got a attribute error. Can u advise how to solve?

Related Posts Respostes Vistes Activitat
1
de juny 25
25037
2
de jul. 22
4208
1
de set. 21
3849
3
de set. 21
8631
1
de set. 21
3050