添加 "vendor product code" 到 odoo 13 中的 QWEB 报告
Add "vendor product code" to a QWEB report in odoo 13
在内置的销售订单报告中,如果产品设置了“供应商产品代码”,则会在产品名称前显示该编号。如果不设置,则显示“内部引用”。
我们创建了一个新报告,并希望在其自己的列中显示内部 reference/vendor 产品代码。
我无法弄清楚如何为特定产品引用特定供应商并获取“供应商产品代码”。 IE。不知道用什么模型的什么字段。
在伪代码中(不是 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)
在包含 order-line
的 table 上的 custom
new report
上,因此您可以从这里获取在默认 odoo [=15 中进行测试的想法=] 报价报告.
Test-Product: On the purchase tab, seller_ids
have vendor set with vendor_code & default_code(internal reference) too.
代码示例,
<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>
从上面的代码来看,只是为了在report
q-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"/>
像这样您可以检查您的当前合作伙伴是否有卖家列表。
但是您可以添加更精确的条件,以便在卖家中找到多个合作伙伴,您可以根据您的自定义添加一些独特的条件而不会出错。
在内置的销售订单报告中,如果产品设置了“供应商产品代码”,则会在产品名称前显示该编号。如果不设置,则显示“内部引用”。
我们创建了一个新报告,并希望在其自己的列中显示内部 reference/vendor 产品代码。
我无法弄清楚如何为特定产品引用特定供应商并获取“供应商产品代码”。 IE。不知道用什么模型的什么字段。
在伪代码中(不是 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)
在包含 order-line
的 table 上的 custom
new report
上,因此您可以从这里获取在默认 odoo [=15 中进行测试的想法=] 报价报告.
Test-Product: On the purchase tab,
seller_ids
have vendor set with vendor_code & default_code(internal reference) too.
代码示例,
<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>
从上面的代码来看,只是为了在report
q-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"/>
像这样您可以检查您的当前合作伙伴是否有卖家列表。 但是您可以添加更精确的条件,以便在卖家中找到多个合作伙伴,您可以根据您的自定义添加一些独特的条件而不会出错。