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,
})],
})
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
AanmeldenGerelateerde posts | Antwoorden | Weergaven | Activiteit | |
---|---|---|---|---|
|
3
jun. 22
|
9196 | ||
|
4
apr. 22
|
9572 | ||
|
0
jan. 25
|
4285 | ||
|
1
dec. 17
|
4560 | ||
|
2
jul. 17
|
5116 |