Search code examples
python-3.xodooodoo-12qweb

print product description on inherited delivery/receipt qweb report based on picking type in odoo


firstly, sorry for bad grammar. can you please help me regarding inherit report.
i separated description for delivery and description for receipt in product.product.
i have inherited stock.report_picking in which i want to print product delivery/receipt description based on it's picking_type_id. it works fine.
but it prints the same description for all products in report.
here is my snippet.

<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>

and this result generated.

[E-COM12] Conference Chair (Steel)
LEGS:STEEL, description for delivery LEGS:ALUMINIUM, description for delivery

[E-COM13] Conference Chair (Aluminium)
LEGS:STEEL, description for delivery LEGS:ALUMINIUM, description for delivery

i have two records and it prints twice for both the products and same description.
for Conference Chair (Steel) it should print description for Steel and
for Conference Chair (Aluminium) it should print description for Aluminium


Solution

  • Try this code

    <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>