İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
3234 Görünümler

Hi,


I want to add the delivery reference  to pdf invoice. I tried this way:

<trt-foreach="o.picking_ids"t-as="picking">

<td><spant-field="picking.name"/>td>

tr>

but it didn't work so may anyone help in solving this. Waiting for a reply.


Thanks in advance! 

Avatar
Vazgeç
En İyi Yanıt

Hi,

There is no field picking_ids in account.move. picking_ids is in sale.order. If you want to have delivery reference in account.move then we have to get it from sale order like:

<table>

<th>Name</th>

<t t-foreach="o.invoice_line_ids.sale_line_ids.order_id" t-as="sale">

<t t-foreach="sale.picking_ids" t-as="picking">

<tr>

<td><span t-field="picking.name"/></td> 

</tr>

</t>

</t>

</table>


If you want to add it in the sale order pdf:

<table>

<th>Name</th>

<t t-foreach="o.picking_ids" t-as="picking">

<tr>

<td><span t-field="picking.name"/></td> 

</tr>

</t>

</table>




Hope it helps

Avatar
Vazgeç
En İyi Yanıt
  1. Identify the QWeb template used for the invoice report. In this case, it would be the template with the report_invoice_document name. You can locate the template in the Odoo source code or search for it in your Odoo custom modules.

  2. Override the QWeb template to include the delivery reference

  3. Create a new template extension to add the necessary code. Here an example:

odoo>

data>

template id="custom_invoice_document_inherit" inherit_id="account.report_invoice_document">

xpath expr="//template[@id='account.report_invoice_document']" position="replace">

template>

xpath expr="//td[@class='trt-data text-right']" position="after">

td class="trt-data">

Delivery Reference: o.picking_ids.mapped('name').join(', ')"/>

/td>

/xpath>

/template>

/xpath>

/template>

/data>


In the above example, the custom_invoice_document template extends the account.report_invoice_document template. It adds a new td element after the existing ones, displaying the delivery reference using the o.picking_ids field. The mapped('name').join(', ') expression retrieves the name field value from the picking_ids and joins them with a comma.


Make sure to include the XML file in your custom module's manifest file

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
3
Haz 22
20005
1
Ağu 17
4760
1
Mar 15
5380
1
Kas 17
15759
0
May 17
7844