Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
9092 Tampilan

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
Buang
Jawaban Terbai

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
Buang

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?

Jawaban Terbai


write to the one2many Line_ids ..

check this answer u can learn it there

https://www.odoo.com/forum/help-1/question/how-to-insert-value-to-a-one2many-field-in-table-with-create-method-28714


Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
1
Jun 25
24366
2
Jul 22
3902
1
Sep 21
3494
3
Sep 21
8340
1
Sep 21
2818