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.


Access origin sale.order information in inherited account.invoice

on 1/10/14, 12:51 PM 2,255 views

Can anybody explain me how I can access the sale.order model from my inherited account.invoice report?

What I need is especially order date...

On 1/11/14, 1:23 PM

As mentioned by S. LE Gal the ORM link doesn't exist between the invoice and its respective sales orders. But it does exist in the database. So, you can create a custom module that adds a new many2many field to the account.invoice model that references the sale.order model via the sale_order_invoice_rel model.

class account_invoice(osv.osv):
_inherit = "account.invoice"

_columns = {
    'sale_order_ids': fields.many2many('sale.order', 'sale_order_invoice_rel'
        , 'invoice_id', 'order_id', 'Sale Orders', readonly=True, 
        help="The sale order(s) that generated this invoice. Multiple sales '\
        'orders may have been combined for the same customer to generate one invoice."),

Thank you very much! This sounds like what I have been looking for! Could you also tell me how to get further product information into account.invoice.line model? What I need is product.id, product.name and product.description separately, not joined like invoiceline.name in account.invoice.line relation.

on 1/12/14, 1:39 PM
Sylvain LE GAL
On 1/10/14, 4:12 PM


I don't think there is a link from account.invoice to sale.order, but you have the revert link : In sale.order model, you have a many2many fields named "invoice_ids" (table : sale_order_invoice_rel).

So you can request the sale_order that have linked to a defined invoice.


As far as I know, there is a field called 'origin' inside account.invoice model. This is the element which the invoice was created from. We always generate invoices from sale.order. What I do not know is how to come from this field to the order_date and where I have to do my changes. Only in .rml file or in report parser, too?

on 1/11/14, 6:36 AM

Hi. Yes there is the 'origin' field, but this is a char field. So, that's why I think it's more complicated to request. for exemple in my database, there is some values like "OUT/02432:SO2074, OUT/08140:SO2485".

Sylvain LE GAL
on 1/11/14, 8:53 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

0 follower(s)


Asked: 1/10/14, 12:51 PM
Seen: 2255 times
Last updated: 3/16/15, 8:10 AM