Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
1521 มุมมอง

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)

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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)


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ม.ค. 16
3702
0
ส.ค. 16
3630
0
มี.ค. 15
3720
1
เม.ย. 24
1554
4
ต.ค. 23
5788