콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
19330 화면

Hi all,

there are major differences between V12 and V13. In V13 i can add an invoice  via API and then i try to add account.move.line to that invoice. I always get the error

Cannot create unbalanced journal entry
Differences debit - credit

i set the following fields:

'account_id' => $account_id,
'move_id' => $odoo_move_id,
'product_id' => 174,
'tax_ids' => [[6, 0, [$odoo_tax_id]]],
'quantity' => 2.0,
'price_unit' => 1.99,
'name' => 'TEST'

Do i really have to add serveral lines in order to make it work? whatelse do i have to do in order to have odoo add the lines automatically just as it does when it do it via the UI?

Fritz


아바타
취소
베스트 답변

Hi, I have faced the same problem in v13.

Done some code changes, now its working for me.

I here share some of my changes, you may check if its useful for your's.

# Journal

journal_id = self.env['account.journal'].search([('type','=','sale')])[0]

# Move Line creation:

invoice_lines = []

for line in lines:

    invoice_lines.append((0,0,{

                                                            'name': line.name,

                                                            'display_name': line.name,

                                                            'price_unit': price,

                                                            'quantity': qty,

                                                            'product_uom_id': uoms.id,

                                                            'product_id': line.product_id.id,

                                                            'tax_ids': [(6, 0, tax.ids)],

                                                        }))


# Move creation:

    account_move = self.env['account.move'].sudo().create({

                                                            'name':  doc_name,

                                                            'invoice_origin': doc_name,

                                                            'invoice_date': date.today(),

                                                            'type': 'out_invoice',

                                                            'partner_id': partner.id,

                                                            'invoice_line_ids': invoice_lines,

                                                            'journal_id': journal_id.id,

                                                            'company_id': self.env.user.company_id.id,

                                        })


Thanks.

아바타
취소
베스트 답변

Hi,

Python code example for Odoo 13:

...

from odoo.tests.common import Form

class AccountMove(models.Model):
_inherit = 'account.move'

    def add_invoice_line(self):

         with Form(self) as move_form:
            with move_form.invoice_line_ids.new() as line:
                line.name ='Product Name'
                line.product_uom_id =
                line.price_unit = 1.0
                line.quantity = 1.0
                line.account_id =
            move_form.save()


아바타
취소
베스트 답변

Read my answer in this question:
Create invoices/credit notes in odoo13 by code.

아바타
취소
작성자

Thanks, i had a lock on it.

I do a account.move create in the first place. Then i use the move_id to add account.move.line .

And there is the problem. as in former verions i expected that all nessesary lines are being created. at the moment with v13 it looks like i have to submit 3 lines in order to get the balance right.

Is there any way odoo api can add all lines by itself and automatically refere to the customer profile with all tax settings?

I would appreciate an example on how to add an invoice with all lines in V13. Is there any documentation available? I really could not find it.

Best regards and many thanks,

Fritz

관련 게시물 답글 화면 활동
0
11월 24
1529
2
3월 22
6789
0
9월 24
1356
0
6월 24
2838
2
11월 23
3499