コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
2159 ビュー

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

アバター
破棄