Odoo Help

0

[8.0] Automated Actions: Conditions and iterating through Account Invoice Lines (one2many objects)

By
alexk1r
on 6/2/16, 11:51 AM 383 views

Hi all,

I'm trying to create an automatic action that is triggered by Customer Invoice creation. The invoice would have 3 invoice lines, one for a customer payment, one for a payment provider fee and one for commission. I would like to create 3 separate Supplier Invoices. Everything is fine until I get to invoice.line object. I need to somehow to differentiate between the three records using the product_id when I'm creating the individual Supplier Invoices. Conceptually, this is what I would like to do:

for line in object.invoice_line:         if line.product_id = 2:        [(0, 0, {'name': line.name, 'product_id': line.product_id.id, 'account_id': line.account_id.id, 'account_analytic_id': line.account_analytic_id.id, 'quantity': line.quantity, 'price_unit': line.price_unit})]

   

The above doesn't work. I'd imagine the invoice_line is not an array? My python-fu is pretty weak though. The third line works fine on it's own but only if there's only one invoice line. This would work as well but having all the amounts as invoice lines is tidier.

Any idea how I could add some conditions when creating an invoice line on the Automated Actions interface so that I could pull values of one of them based on the invoice.line.product_id.

Thanks.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 6/2/16, 11:51 AM
Seen: 383 times
Last updated: 6/2/16, 12:17 PM