Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
1499 Vistas

hi, this is an SQL that generates the report by Sales Order in detail.  I have made some changes to the query according to my need but now I want a summarized row that displays the sum of quantity, sub-total and total amount of all rows at the bottom.

Please help on how to achieve this.

elif data.get('report_type') == 'report_by_order_detail':

            query = '''

            SELECT  ru.id

                 so_line.product_id, res_users.partner_id, so.payment_status 

            '''         

            self._cr.execute(query)

            report_by_order_details = self._cr.dictfetchall()

            report_sub_lines.append(report_by_order_details)

Avatar
Descartar
Mejor respuesta

elif data.get('report_type') == 'report_by_order_detail':


    query = '''

    SELECT

        ru.id

        so_line.product_id, 

        res_users.partner_id, 

        so.payment_status,

        so_line.quantity,

        so_line.sub_total,

        so_line.total_amount

    FROM

        your_table_name ru

    JOIN

        your_other_tables so ON ru.id = so.ru_id

    JOIN

        your_other_tables so_line ON so.id = so_line.so_id

    JOIN

        your_other_tables res_users ON so.user_id = res_users.id

    '''


    # Append GROUP BY and SUM functions for summarized row

    query += '''

    GROUP BY

        ru.id,

        so_line.product_id,

        res_users.partner_id,

        so.payment_status

    WITH ROLLUP

    '''


    self._cr.execute(query)


    report_by_order_details = self._cr.dictfetchall()


    report_sub_lines.append(report_by_order_details)


Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
ene 16
3702
0
ago 16
3630
0
mar 15
3705
1
abr 24
1549
4
oct 23
5774