Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
7572 มุมมอง

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


 

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

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.

คำตอบที่ดีที่สุด

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.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ก.ย. 17
4353
0
ส.ค. 16
3321
Generate new PDF report each time แก้ไขแล้ว
1
มิ.ย. 16
4720
0
เม.ย. 24
1264
4
ก.พ. 20
9912