summaryrefslogtreecommitdiff
path: root/odoo/modules/loading.py
diff options
context:
space:
mode:
authorGoffin Simon <sig@odoo.com>2018-07-04 15:34:01 +0200
committerGoffin Simon <sig@odoo.com>2018-07-04 13:21:46 +0200
commit30ede6a16afbb9f46033ef58c81ed7a7229959d4 (patch)
tree6e5476f11983733709e447d52b94a6a9e503b281 /odoo/modules/loading.py
parente338542f9321cb73cce546bf3be6e77c540a8c8b (diff)
[FIX] pos_sale, sales_team: Timezone problem in dashboard graph
The function _get_graph computing the dashboard graph must take the timezone of the user into account to compute the right start_date S and the right end_date E. The query made on model 'report.pos.order' by read_group in _graph_data must take the timezone of the user into account to substract the right offset to compute the start_date S and end_date E in UTC because the result returned by read_group is formated in the timezone of the user afterwards. Example: In function _get_graph: Start_date in 'Asia/Ulaanbaatar' timezone = 2018-06-05 End_date in 'Asia/Ulaanbaatar' timezone = 2018-07-04 So End_date - Start_date + 1 = 30 In function _graph_data: Start_date in 'Asia/Ulaanbaatar' timezone = 2018-06-05 00:00:00 End_date in 'Asia/Ulaanbaatar' timezone = 2018-07-04 23:59:59 So in UTC -9 hours: Start_date in UTC = 2018-06-04 15:00:00 End_date in UTC = 2018-07-04 14:59:59 SELECT min("report_pos_order".id) AS id, count("report_pos_order".id) AS "date_count" , sum("report_pos_order"."price_total") AS "price_total" , date_trunc('day', timezone('Asia/Ulaanbaatar', timezone('UTC',"report_pos_order"."date"))) as "date:day" FROM "report_pos_order" WHERE (((("report_pos_order"."date" >= Start_date) AND ("report_pos_order"."date" <= End_date)) AND ("report_pos_order"."config_id" in (1,2,3))) AND ("report_pos_order"."state" in ('paid','done','invoiced'))) GROUP BY date_trunc('day', timezone('Asia/Ulaanbaatar', timezone('UTC',"report_pos_order"."date"))) ORDER BY "date:day" And the result of this request will be between 2018-06-05 00:00:00 and 2018-07-04 23:59:59 but before the fix the result was between 2018-06-05 00:09:00 and 2018-07-05 08:59:59 and then End_date - Start_date + 1 was equal to 31. That's why a "IndexError: list index out of range" can be raised in _get_graph. In this way, no mismatch is possible between the datas computed by _graph_data and the dict "values" allocated by _get_graph. opw:1862996
Diffstat (limited to 'odoo/modules/loading.py')
0 files changed, 0 insertions, 0 deletions