Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
1735 Tampilan

How to print report and grouping records based on product_id using search function

           docs=self.env[(stock.move].search([domain) ]

    Return{

}

How to group the result in the xml using foreach and get table as follow:

Product_id

   Partner_id

   Product_qty_uom

   Origin


Product_id

   Partner_id

   Product_qty_uom

   Origi


Avatar
Buang
Jawaban Terbai

Hi

create a Template:


<template id="report_template">

<t t-call="report.html_container">

        <t t-foreach="docs" t-as="doc">

            <div class="page">

                <table class="table table-condensed">

                    <thead>

                        <tr>

                            <th>Product ID</th>

                            <th>Partner ID</th>

                            <th>Product Quantity</th>

                            <th>Origin</th>

                        </tr>

                    </thead>

                    <tbody>

                        <tr>

<td><span t-field="doc.product_id"/></td>

<td><span t-field="doc.partner_id"/></td>

<td><span t-field="doc.product_qty_men"/></td>

                            <td><span t-field="doc.origin"/></td>

                        </tr>

                    </tbody>

                </table>

            </div>

        </t>

    </t>

</template>


python code , you may write this code:
product = self.env['stock.move'].search([domain], order='product_id, partner_id')

return {
    'docs': product,
    'report_template': 'module_name.report_template'
}

Hope it helps

Avatar
Buang