I would like to demonstrate how to create Vendor Bills using the API, so do this from within a Scheduled Action that I can run manually.
How would I do this?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
I would like to demonstrate how to create Vendor Bills using the API, so do this from within a Scheduled Action that I can run manually.
How would I do this?
For v15, assuming you have a Vendor called "ACME Services" and an Expense Account with code "60000" you could do something like:
vendor_name = "ACME Services"
bill_ref = "B65253"
bill_date = "2022-07-01"
bill_date_due = "2022-07-31"
bill_line_note = 'Legal Services'
bill_line_account = '600000'
bill_line_amount = '2500'
bill_line_quantity = 1
vendor_in_odoo = env['res.partner'].search([('name','=',vendor_name)])
if not vendor_in_odoo:
raise UserError("Cannot find Vendor!")
bill_line_account_in_odoo = env['account.account'].search([('code','=',bill_line_account)])
if not bill_line_account_in_odoo:
raise UserError("Cannot find Account for the Bill Line!")
bill = env['account.move'].create({
'move_type': 'in_invoice',
'invoice_origin': 'External API Demo',
'partner_id': vendor_in_odoo.id,
'ref': bill_ref,
'invoice_date': bill_date,
'invoice_date_due': bill_date_due,
'invoice_line_ids': [(0,0,{
'name': bill_line_note,
'account_id': bill_line_account_in_odoo.id,
'price_unit': bill_line_amount,
'quantity': bill_line_quantity,
})],
})
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
3
Jun 22
|
7946 | ||
|
4
Apr 22
|
8015 | ||
|
0
Jan 24
|
3428 | ||
|
1
Dec 17
|
3797 | ||
|
2
Jul 17
|
4118 |