Odoo Help

Welcome!

This community 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.

0

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

By
alexk1r
on 6/2/16, 11:51 AM 220 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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

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