跳至内容
菜单
此问题已终结
1 回复
3285 查看

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
4124
0
8月 21
2368
1
2月 17
3239
2
1月 17
7073
0
11月 23
1502