Reputation: 741
i'm trying to customized report_purchasequotation.xml and report_purchaseorder.xml. I have added a new th to add Product reference at the supplier in my reports. My problem is when i use span t-field="order_line.product_id.product_code" (field product_code in the model product.supplierinfo ) it shows error QWebException: 'product_code'. Any help please ?
<table class="table table-condensed">
<thead>
<tr>
<th><strong>Article</strong></th>
<th><strong>Référence fournisseur</strong></th>
<th><strong>Désignation</strong></th>
<th class="text-center"><strong>Expected Date</strong></th>
<th class="text-right"><strong>Qty</strong></th>
</tr>
</thead>
<tbody>
<tr t-foreach="o.order_line" t-as="order_line">
<td>
<span t-field="order_line.name"/>
</td>
<td>
<span t-field="order_line.product_id.product_code"/>
</td>
<td>
</td>
<td class="text-center">
<span t-field="order_line.date_planned"/>
</td>
<td class="text-right">
<span t-field="order_line.product_qty"/>
<span t-field="order_line.product_uom" groups="product.group_uom"/>
</td>
</tr>
</tbody>
</table>
Upvotes: 0
Views: 115
Reputation: 9640
By default there is a one2many
field on the product.template
that is called seller_ids
. This is the relation between product_supplierinfo
and product_template
. So you can do something like this to get all the supplier codes:
<span><t t-esc="', '.join([x.product_code for x in order_line.product_id.product_tmpl_id.seller_ids])" /></span>
You can show all the product codes in a table as well
<table class="table table-condensed">
<thead>
<tr>
<th>Supplier</th>
<th>Product Code</th>
</tr>
</thead>
<tbody>
<tr t-foreach="order_line.product_id.product_tmpl_id.seller_ids" t-as="s">
<td>
<span t-esc="s.name.name"/>
</td>
<td>
<span t-esc="s.product_code"/>
</td>
</tr>
</tbody>
</table>
Upvotes: 1