Skip to Content
Menu
This question has been flagged
1 Reply
2539 Views

I am posting this question for the third time cuz i dint get the relevant answer.. please its urgent
I want to sort the qweb report from descending to ascending based on the below marked field

the xml code for the report is as follows, the table must be sorted based on the field which is written in bold

<h3>Products</h3>

            <table class="table table-condensed">

                <thead><tr>

                    <th>Product</th>

                    <th>Quantity</th>

                    <th>Cost Price</th>

                    <th>Total Cost </th>

                    <th>Price Unit</th>

                    <th>Amount without VAT</th>

                    <th>VAT</th>

                    <th>VAT Amount</th>

                    <th>Total Amount</th>

                </tr></thead>

                <tbody>

                   <tr t-foreach="products" t-as="line">

                       <td>

                           <t t-esc="line['product_name']"/>

   </td>

                           <td>

                           <t t-esc="line['quantity']"/>

                           <t t-if="line[&quot;uom&quot;] != &quot;Unit(s)&quot;">

                           <t t-esc="line[&quot;uom&quot;]"/> 

                           </t>

                           </td>

                           <td>

                           <t t-esc="'%.2f'%(request.env['product.product'].browse(line['product_id']).standard_price)"/>

                           </td>

                           <td>

                           <t t-esc="'%.2f'%(line['quantity']*request.env['product.product'].browse(line['product_id']).standard_price)"/>

                           </td>                  

                           <td>

                           <t t-esc="'%.2f'%line[&quot;price_unit&quot;]"/>

                           <t t-if="line[&quot;discount&quot;] != 0">

                           Disc: <t t-esc="line[&quot;discount&quot;]"/>%

                           </t>

                           </td>

                           <td>

                           <t t-esc="'%.2f'%((line['quantity']*line['price_unit'])/1.05)"/>

                           </td>

                           <td>

                           5%

                           </td>

                           <td>

                           <t t-esc="'%.2f'%(((line['quantity']*line['price_unit'])/1.05)*0.05)"/>

                           </td>

                           <td>

                           <t t-esc="'%.2f'%(line['quantity']*line['price_unit'])"/>

                           </td>

                </tr>

                </tbody>

            </table>

kindly give the code for the same field, and where to place the code

Avatar
Discard
Best Answer

Hi,

While returning the products from python file/parser of reports, sort from there itself based on the total amount and then return it to the report.

Thanks

Avatar
Discard
Author

thanks but am only working on front-end as am not that much aware of python codes, so if you can help me out here on the xml qweb view, that would be great