首先,对语法错误感到抱歉。您能帮我有关继承报告的问题吗?我在product.product
中将交货说明和收货说明分开。我继承了stock.report_picking
我要在其中打印基于picking_type_id
的产品交付/收货说明。它工作正常。但它会为报告中的所有产品打印相同的描述。这是我的摘录。
<template id="report_picking_inherit" inherit_id="stock.report_picking">
<xpath expr="//table[@class='table table-sm']//tbody//tr//td//span[2]" position="replace">
<t t-foreach="o.move_ids_without_package.sorted(key=lambda m: m.product_id.id)" t-as="move">
<t t-foreach="move.move_line_ids.sorted(key=lambda ml: ml.location_id.id)" t-as="ml">
<t t-if="docs.picking_type_id.name == 'Receipts'">
<span t-field="move.product_id.description_for_receipt"/>
</t>
<t t-if="docs.picking_type_id.name == 'Delivery Orders'">
<span t-field="move.product_id.description_for_delivery"/>
</t>
</t>
</t>
</xpath>
</template>
并生成此结果。
[[E-COM12]会议主席(钢)LEGS:钢,交货说明LEGS:ALUMINIUM,交货说明
[[E-COM13]会议主席(铝)LEGS:钢,交货说明LEGS:ALUMINIUM,交货说明
i有两条记录,并且为产品和相同的描述打印两次。对于会议主席(钢制),应打印钢制说明,然后会议椅(铝),应打印铝的说明
尝试此代码
<xpath expr="//table[@class='table table-sm']//tbody//tr//td//span[2]" position="replace">
<t t-if="docs.picking_type_id.name == 'Receipts'">
<span t-field="ml.product_id.description_for_receipt"/>
</t>
<t t-if="docs.picking_type_id.name == 'Delivery Orders'">
<span t-field="ml.product_id.description_for_delivery"/>
</t>
</xpath>