Odoo Help


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.


Find the different customer invoice

Ajeng Shilvie
on 1/7/15, 10:27 PM 434 views

how can i know that the customer invoice is created by validating sales order or manually create by input manually ? i have to filter customer invoice only from sales order , not manually created . is there anyway to know the different ?




i use this code but it didn't work ..

my python code :

        'invoice_id': fields.many2one('account.invoice',string='Invoice',required=True, domain=[('origin', '=', True)]),

my xml code:

       <field name="invoice_id" context="{'form_view_ref':'account.invoice_form'}" domain="[('state','=','paid'),('type','=','out_invoice'),('branch_id','=',branch_id),('division','=',division)]" on_change="_onchange_invoice(invoice_id)"/>




| 5 3 6
Jakarta, Indonesia
On 1/7/15, 11:33 PM

@Ajeng, customer invoices created from sales order will be linked to the sale order at sale order's invoice_ids field, which is a many2many.  So, what you can do is to create a reverse many2many field at account.invoice, and if you need, create a function field on account.invoice that counts the number of sale.order that this invoice is linked to.

Note that this is not 100% foolproof as people can create modules to link account.invoice to sale.order.  However, if the idea is to separate which account.invoices are related to sale.order and which are not, the above method should suffice.

@ivan thanks for the answer , the field 'invoice_id' above i store it in new object. So it didn't inherit to the other object. But i have to filter order line from account.invoice that has source document from sales order. in order to do that i have to use domain 'origin' but it didn't work.

Ajeng Shilvie
on 1/8/15, 12:02 AM

Origin does not guarantee and is only available in account.invoice. If you want to access the sale.order.line, then you can do it from the following relationship: sale.order --> sale.order.line (through order_id of sale.order.line --> account.invoice.line (through invoice_lines of sale.order.line, you can create the reverse many2many field in account.invoice.line to ease the searching) --> account.invoice (through invoice_id of account.invoice.line). From that relationship you can create proxy fields (related fields) that will help you to do the search. Also, I'm not quite sure why you want to filter order line (I presume you mean sale.order.line) from account.invoice? Maybe if you described what is the ultimate objective (instead of just asking how to do it in certain way), you can get a better help.

on 1/8/15, 12:17 AM

i am following your answer, but how can i get invoice that have a 'paid' state ?

Ajeng Shilvie
on 1/8/15, 1:40 AM

Put a domain to limit the returned records.

on 1/8/15, 7:10 AM

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

1 follower(s)


Asked: 1/7/15, 10:27 PM
Seen: 434 times
Last updated: 3/16/15, 8:10 AM