Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
22315 Lượt xem

Hi, I'm trying to create an invoice line using the Web APIs and XML-RPC (python). I receive this error while creating it.


xmlrpc.client.Fault: <Fault 2: 'Cannot create unbalanced journal entry. Ids: [12083]\nDifferences debit - credit: [-2629.33]'>

I'm creating the invoice line as follows:


inv_line_id = models.execute_kw(db, uid, password, 'account.move.line', 'create', [{'move_id':invoice_id,'product_id':product_id[0]['id'],'price_unit':product_id[0]['list_price'],'quantity':sale_line_id[0]['product_uom_qty'],'account_id':account_id[0]['property_account_income_categ_id'][0]}])

If i dont add the 'price_unit' the invoice line is being created normally but without a price.


Anyone knows how to fix this ? Thanks in advance


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

Pass check_move_validity as False in the context and try.


Thanks

Ảnh đại diện
Huỷ bỏ
Tác giả

Could you kindly tell me how to do this ? I'm still new to Odoo.

Thanks

Thank you so much Niyas well done work,
invoice.with_context(check_move_validity=False).write({'invoice_line_ids':[[0,0,invoice_dict]]})

Dear Sender,

Thank you for your e-mail. I'm out of office until 15-08-2023 with limited access to email.

I will respond to your emails as soon as possible upon my return.


Best regards,
Pedro Teixeira

 

Câu trả lời hay nhất

Please pass the "exclude_from_invoice_tab: False" in the invoice values and try it again.

Ảnh đại diện
Huỷ bỏ
Tác giả

Nope , this didn't fix it , still getting the same error

Did you pass the type (in_invoice, out_invoice, etc) when creating an invoice? If not, please try that.

Tác giả

Yes , I passed it as out_invoice . Is there anything i might be missing ?

Câu trả lời hay nhất

Hi Ahmad,

Please override the _check_balance method of 'account.move' by returning True.

def _check_balanced(self):
        return True

Once the script execution is completed, remove the _check_balanced (override) method so the Odoo flow will not be affected in normal(form view) invoice creation.

Thanks

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

When Niyas Raphy said

 Hi,

Pass check_move_validity as False in the context and try.

He said that you have to put on the invoice a context before you can change the quantity of the lines, just like this.

invoice = self.env['account.move'].create({}) //Supose I create an invoice here

invoice = invoice.with_context(check_move_validity=False,)


Caution! This change work when invoice is a sale invoice!

I proof this and The result has been correct.


I hope this help you, I pass 3 hours with this.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 11 23
1495
3
thg 12 19
8565
2
thg 7 25
1477
0
thg 5 25
780
0
thg 1 24
1448