Skip to Content
Menú
This question has been flagged
1 Respondre
3289 Vistes

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}),
],
}])

Avatar
Descartar
Best Answer

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

Avatar
Descartar
Related Posts Respostes Vistes Activitat
1
d’oct. 22
4125
0
d’ag. 21
2369
1
de febr. 17
3242
2
de gen. 17
7073
0
de nov. 23
1502