Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
6 Antwoorden
7013 Weergaven

Hello dear beautiful odoo community.

Recently I have been trying to create invoices in odoo13 by code by apparently everytime I run the code I get a message stating that my journal entries arenot balanced.

I have tried to create invoice by executing this line.
self.env[`account.move`].create({
"partner_id": partner_id,
"journal_id": journal_id,
"partner_shipping_id": partner_shipping_id,
"type": "out_invoice",
"invoice_line_ids": [(0, 0, {
"name": name,
"price_unit":88,
"product_uom_id":1,
"quantity": 2,
"account_id": account_id,
"tax_ids": [(4, 67)],
"product_id": product_id})],
})

the first invoice is always created, but when i try to execute the same line twice, I get an error stating that my journal items(account.move.line) are unbalanced. so I dont know If am doing something wrong or missing something.

your help so so appreciated.

Avatar
Annuleer
Beste antwoord
in my code you will see that . i created 2 entries / line items ... one for credit and second for debit like journal entries...and in both entries the account is diffrent ... for debit i used expense account and for credit i use income account ... and in account move record i used specific journal eg. vendor journal
mov_line_credit = {'move_name': 'test invoice',
'move_id': invoice.id,
'debit': 0.0 ,
'credit': amount,
'date': date,
'partner_id': partner,
'product_id': product.id,
'account_id': acc_p.id,
'name':product.name,
'exclude_from_invoice_tab': True,
'quantity': 1,
'price_unit': float(amount)}

mov_line_debit = {'move_name': 'test invoice',
'move_id': invoice.id,
'debit': amount,
'credit': 0.0 ,
'date': date,
'name': product.name,
'partner_id': partner,
'product_id': product.id,
'account_id': acc_r.id,
'quantity': 1,
# 'exclude_from_invoice_tab': True,
'price_unit': float(amount)}

ct = self.env['account.move.line'].sudo().with_context(
check_move_validity=True).create([mov_line_debit,mov_line_crediit])
Avatar
Annuleer
Beste antwoord

Hello Hamza, I think you solved your problem? I have a similar one - could you pls be as kind as to share your final code? How and where do you call _recompute_dynamic_lines method? thanks for an hint.


Avatar
Annuleer
Beste antwoord

Probably your problem is that, in version 13, account.move has two different relations defined for account.move.line.
One is: invoice_line_ids
The other is: line_ids

invoice_line_ids is just a subset of line_ids​

Avatar
Annuleer
Auteur

Exactly!

can you explain how invoice_line_ids is subset of line_ids

when PRICE, QUANTITY, SUBTOTAL are not present in line_ids

Beste antwoord

Please provide the full code.then easily found the problem

Avatar
Annuleer
Auteur Beste antwoord

The reason we had miss match in journal item was because the create method wasnot calling _recompute_dynamic_lines method to recompute journal items.

Avatar
Annuleer