Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
8998 Vizualizări

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

Imagine profil
Abandonează
Cel mai bun răspuns

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."),
}
Imagine profil
Abandonează
Autor

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.

Cel mai bun răspuns

Hi,

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.

Regards.

Imagine profil
Abandonează
Autor

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?

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".

Related Posts Răspunsuri Vizualizări Activitate
1
aug. 21
37673
0
mar. 15
5335
3
mar. 15
5006
3
mar. 25
6708
3
nov. 24
3815