Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
8886 Vistas

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

Avatar
Descartar
Mejor respuesta

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."),
}
Avatar
Descartar
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.

Mejor respuesta

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.

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

Publicaciones relacionadas Respuestas Vistas Actividad
1
ago 21
37556
0
mar 15
5244
3
mar 15
4868
3
mar 25
6513
3
nov 24
3468