Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
6245 Переглядів

I would like to demonstrate how to create Customer Invoices 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 Customer called "ACME Inc" and an Income Account with code "400000" you could do something like: 

customer_name = "ACME Inc"
invoice_ref = "B65253"
invoice_date = "2022-07-01"
invoice_date_due = "2022-07-31"
invoice_line_note = 'Consulting Services'
invoice_line_account = '400000'
invoice_line_amount = '150'
invoice_line_quantity = 10

customer_in_odoo = env['res.partner'].search([('name','=',customer_name)])

if not customer_in_odoo:
raise UserError("Cannot find Customer!")

invoice_line_account_in_odoo = env['account.account'].search([('code','=',invoice_line_account)])

if not invoice_line_account_in_odoo:
raise UserError("Cannot find Account for the Invoice Line!")

invoice = env['account.move'].create({
'move_type': 'out_invoice',
'invoice_origin': 'External API Demo',
'partner_id': customer_in_odoo.id,
'ref': invoice_ref,
'invoice_date': invoice_date,
'invoice_date_due': invoice_date_due,
'invoice_line_ids': [(0,0,{
'name': invoice_line_note,
'account_id': invoice_line_account_in_odoo.id,
'price_unit': invoice_line_amount,
'quantity': invoice_line_quantity,
})],
})
Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
2
лип. 19
4066
0
трав. 19
4145
1
черв. 17
3565
1
трав. 16
3423
1
лют. 25
1543