跳至內容
選單
此問題已被標幟
1 回覆
3291 瀏覽次數

How to create invoice in accounting module in Odoo 14 through python coding. 

the below code is creating sales order in sale module but iam not able to create invoice through coding

models.execute_kw(db, uid, password, 'sale.order', 'create', [{
'partner_id': 1, 'validity_date': "2021-08-09", 'state': 'sale',
'order_line': [(0, 0, {'product_id': 2, 'product_uom_qty': 2, 'price_unit': 10.00}),
(0, 0, {'product_id': 5, 'product_uom_qty': 4, 'price_unit': 20.00}),
],
}])

頭像
捨棄
最佳答案

Hi,

You can create invoice from code as follows:

Sample Python Code:


move = self.env['account.move'].create({
'move_type': 'in_invoice',
'date': '2017-01-01',
'partner_id': self.partner_a.id,
'invoice_date': fields.Date.from_string('2017-01-01'),
'currency_id': self.currency_data['currency'].id,
'invoice_payment_term_id': self.pay_terms_a.id,
'invoice_line_ids': [
(0, None, {
'name': self.product_line_vals_1['name'],
'product_id': self.product_line_vals_1['product_id'],
'product_uom_id': self.product_line_vals_1['product_uom_id'],
'quantity': self.product_line_vals_1['quantity'],
'price_unit': self.product_line_vals_1['price_unit'],
'tax_ids': self.product_line_vals_1['tax_ids'],
}),
(0, None, {
'name': self.product_line_vals_2['name'],
'product_id': self.product_line_vals_2['product_id'],
'product_uom_id': self.product_line_vals_2['product_uom_id'],
'quantity': self.product_line_vals_2['quantity'],
'price_unit': self.product_line_vals_2['price_unit'],



If you need to create using xmlrpc, change the model name to account.move and change the fields and try.


Thanks

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
10月 22
4125
0
8月 21
2370
1
2月 17
3242
2
1月 17
7073
0
11月 23
1503