在 odoo 13 中将"vendor product code"添加到 QWEB 报告



在内置的销售订单报告中,如果产品具有"供应商产品代码";设置,它将在产品名称前面显示该数字。如果没有设置;内部参考";。

我们已经创建了一个新的报告,并希望在其自己的列中显示内部参考/供应商产品代码。

我不知道如何参考特定产品的特定供应商;供应商产品代码";。也就是说,我不知道该使用什么领域、什么模型。

在伪代码中(不是qweb,但你明白了(:

if(sales_order_line.vendor_product_code.is_set())
print( sales_order_line.vendor_product_code)
else
print( sales_order_line.product.internal_id)

在您的custom上,包含order-line的表上有新的report,因此您可以从这里获得默认测试odoosale order报价报告的想法。

测试产品:在采购选项卡上,seller_ids使用vendor_code&default_code(内部引用(。

代码示例,

<t t-foreach="doc.order_line" t-as="line">
<t t-set="code" t-value="line.product_id.seller_ids[0].product_code if line and line.product_id and line.product_id.seller_ids and line.product_id.seller_ids[0].product_code else line.product_id.default_code"/>
<td name="td_name"><span t-field="line.name"/><br/>Code: <span t-esc="code"/></td>
</t>

根据上面的代码,它只是在reportq-web中使用的一种方法,正如我在这里使用的那样,从多个列表中获得第一个卖家

因此,根据您的定制进行更改

代码中自定义需求的改进逻辑

<t t-set="code" t-value="line.product_id.seller_ids.filtered(
lambda x: doc.partner_id == x.name).product_code if line and line.product_id and line.product_id.seller_ids else line.product_id.default_code"/>

通过这种方式,您可以检查您的当前合作伙伴是否拥有卖家列表。但你可以添加一个更精确的条件,这样对于在卖家中找到的多合作伙伴,你就不会因为根据你的定制添加了一些独特的条件而出现错误。

最新更新