Odoo Help

Welcome!

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.

1

printing "sale.order" fields in account.invoice pdf (qweb)

By
Philipp Becker
on 11/19/15, 10:20 AM 821 views

My Goal is to print fields of the "sale.order" into the invoice pdf. 


Normaly I use 

<span t-field="o.partner_id"/>

(invoice_line for example).

and nest it like this for example:

<span t-field="o.partner_id.phone"/> 


That mostly work for account.invoice and all kinds of connected fields.

Is there a way to "nest to" the informations of the sale.order which Im missing? Or is there maybe a way not to start from "o"?


 

0
Philipp Becker
On 11/23/15, 9:54 AM

I found the solution. As said, there isnt any connection to the sale.order so I build a module to make this connection:

from openerp.osv import fields, osv

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

now its possible to nest the fields like this in the invoice pdf:

<span t-field="o.sale_order_ids.name"/>


Thank you for the explanation. Can you please show

- how this code would look like when I want to access the sales.order module not from accounts but from the Manufacturing Orders module in a qweb report.

- where to put the code. Do I need to create a new file or can I place this into a specific file? Please explain where to copy this file into.

Thank you.

Raphael
on 8/11/16, 10:35 AM
0
Divyang Jariwala
On 8/13/16, 7:57 AM

Hello Philipp Becker,

There is a link between invoice and sale order.

Please refer _get_invoiced method of 'sale.order'

its returning invoice linked to particular sale order.

i hope this will surely help you.

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

2 follower(s)

Stats

Asked: 11/19/15, 10:20 AM
Seen: 821 times
Last updated: 8/16/16, 4:53 AM