Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
2168 Представления

Hi there,

How can I add invoice line via automation action? 


Right now my automation works:

1. Contact is created.

1a) Invoice is automatically created via Automation Action.


Now I want to add specific product into the invoice line when invoice is created via Automation. 


Any solution?

Thanks

Аватар
Отменить
Лучший ответ

Hi,

In the existing code in the automation for creating invoices you can modify it like this:

The "lines" are the invoice lines. In the dictionary, you can add the appropriate values. like in the product_id you can add the id of specific product.

And the lines are used in the invoice creation as invoice_line_ids. It will create the invoice lines too.

def action_create_invoice_line(self):
lines = [(0, 0, {
'product_id': product_id.id,
'name': description,
'quantity': 1.0,
'price_unit': price,
}) for rec in self]
invoice = self.env['account.move'].create({
'move_type': 'out_invoice',
'partner_id': partner_id.id,
'payment_reference': reference,
'invoice_date': (datetime.now()).date(),
'invoice_line_ids': lines
})

Regards

Аватар
Отменить