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

I'm trying to create invoice lines without any luck.

I can correctly create an invoice using the following code with dummy data:

line_id3 = models.execute_kw(db, uid, password,

     'account.move', 'create',

     [{

         "name":"test",

      "date":"2020-09-08",

      "ref":"test",

      "state":"draft",

      "type":"out_invoice",

      "type_name":"Invoice",

      "user_id":2,

      "invoice_payment_state":"paid",

      "invoice_date":"2020-09-08",

      "invoice_date_due":"2020-09-08",

      "partner_id":5072,

      "commercial_partner_id":5072,

}])


From what i understand looking at the database i need to create 3 different Lines, each with different data in it but i don't really understand how it works.

If i try to create it using something like:

line_id1 = models.execute_kw(db, uid, password,

     'account.move.line', 'create',

     [{

         'name': 'test',

        'debit': 1,

        'credit': 0.0,

        'account_id': 27,

         'move_id':14

    }])

I get the following error:

Cannot create unbalanced journal entry. Ids: [14]\nDifferences debit - credit: [1.0]


Has anyone tried creating invoices using xmlrpc and python and can point me in the right direction?

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

You are almost doing it right accept you are using wrong field to pass the price. Since you are creating invoice lines, you should use "price_unit" field instead of credit/debit field.

[{
    'name': 'test',
    'price_unit': 1,
    'account_id': 27,
    'move_id':14
}])



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

Hi,

Pass check_move_validity=False in the context and try.

sample code:

api.execute_kw(db, uid, pwd, 'res.country', 'search_read', [[]], {'fields': ['id', 'name'], 'context' :{'check_move_validity': False}})


Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 11 22
2779
1
thg 10 22
2838
1
thg 9 15
4231
3
thg 2 24
2921
1
thg 8 23
12367