Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
1528 Ansichten

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
Verwerfen
Beste Antwort

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
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
0
Jan. 16
3705
0
Aug. 16
3635
0
März 15
3736
1
Apr. 24
1567
4
Okt. 23
5794