Odoo Help


Access origin sale.order information in inherited account.invoice

on 1/10/14, 12:51 PM 3,350 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

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.


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

0 follower(s)


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