odoo:如何在透视报表中更改总计的值

时间:2018-10-24 09:07:42

标签: pivot reporting odoo

我想获取数据透视中总计的值
例如

        | total_HT  | total_con | con(%)| 
-----------------------------------------
Total   |     1110  |      1010 |    200| 
-----------------------------------------
  Table |      100  |         0 |      0| 
 chaire |       10  |        10 |    100| 
desktop |     1000  |      1000 |    100| 

con(%)200 的值不是预期值 如何在“总计”行中获取值 1010/1110 = 91%

这是对sale_report的查询:

SELECT min(l.id) AS id
    ,l.product_id
    ,sum(l.price_total) AS total_ht
    ,sum(CASE 
            WHEN t.purchase_ok
                THEN l.price_total
            ELSE 0
            END) AS total_con
    ,sum(CASE 
            WHEN t.purchase_ok
                THEN l.price_total
            ELSE 0
            END) / sum(l.price_total)*100 AS con_percent
FROM sale_order_line l
INNER JOIN sale_order s ON l.order_id = s.id
LEFT JOIN product_product p ON l.product_id = p.id
LEFT JOIN product_template t ON p.product_tmpl_id = t.id
GROUP BY l.product_id

0 个答案:

没有答案