Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
3200 Vues

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?

Avatar
Ignorer
Meilleure réponse

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,
})],
})
Avatar
Ignorer
Publications associées Réponses Vues Activité
3
juin 22
9198
4
avr. 22
9575
0
janv. 25
4286
1
déc. 17
4561
2
juil. 17
5120