summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/backend/dashboard.js
diff options
context:
space:
mode:
authorMeghna Jaswani <mja@odoo.com>2019-04-24 12:51:48 +0000
committerNicolas Lempereur <nle@odoo.com>2019-05-03 11:29:34 +0000
commit8df4bbf1ed759db18e55b63cd06c500971221a21 (patch)
tree6eef3a69a0267e881d91045f7f0257dc2f6067b1 /addons/website/static/src/js/backend/dashboard.js
parent97b44806f5121e97b62ba25da910e77e26a9424d (diff)
[FIX] website{,_sale_link_tracker}: ecommerce graph today
The UTM graph data in Website > Dasboard > Analytics is not getting properly filtered on the basis of values of date_from and date_to on website_sale dashboard. The field confirmation date which is of type datetime while date_from and date_to are of date string in local browser timezone. Hence date_domain is not perfect as shown below on local date 29th april 2019, we would send: ('confirmation_date', '>=', '2019-04-22'), ('confirmation_date', '<=', '2019-04-29') But in reality we could want a from midnight of week before the current UTC day, and to current UTC now or 23:59:59 of current UTC day. This way, the data sent back matches more what is expected, instead of the preceding domain, we would then have the following: - if UTC now corresponding to local now is on '2019-04-29' ('confirmation_date', '>=', '2019-04-22 00:00:00'), ('confirmation_date', '<=', '2019-04-29 23:59:59') - if UTC now corresponding to local now is on '2019-04-28': ('confirmation_date', '>=', '2019-04-21 00:00:00'), ('confirmation_date', '<=', '2019-04-28 23:59:59') - if UTC now corresponding to local now is on '2019-04-30': ('confirmation_date', '>=', '2019-04-23 00:00:00'), ('confirmation_date', '<=', '2019-04-30 23:59:59') And each one will be displayed as days 22 up to 29 in line chart (with local today 29 being the last day of the chart and contening orders of the current UTC day). With these change in the UTM pie chart: - a local date that is before a UTC date => we see the sales from up to today UTC instead of from up to before yesterday UTC - a local date that is the same as an UTC date => we see the sale from up to today UTC instead of yesterday UTC And in the line chart (that already had half of the fix in f6fc7c23192): - a local date that is before a UTC date => we see the sales from up to today UTC instead of from up to yesterday UTC - a local date that is after a UTC date => we see the sales of current UTC day + range of days (eg. for a week 7) instead of current UTC day + range of days minus 1 (eg. for a week 6). opw-1971539 closes #33041 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com> Co-authored-by: Nicolas Lempereur <nle-odoo@users.noreply.github.com>
Diffstat (limited to 'addons/website/static/src/js/backend/dashboard.js')
-rw-r--r--addons/website/static/src/js/backend/dashboard.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/addons/website/static/src/js/backend/dashboard.js b/addons/website/static/src/js/backend/dashboard.js
index f88dc249296..9dca1251f59 100644
--- a/addons/website/static/src/js/backend/dashboard.js
+++ b/addons/website/static/src/js/backend/dashboard.js
@@ -33,8 +33,8 @@ var Dashboard = AbstractAction.extend(ControlPanelMixin, {
this._super(parent, context);
this.date_range = 'week'; // possible values : 'week', 'month', year'
- this.date_from = moment().subtract(1, 'week');
- this.date_to = moment();
+ this.date_from = moment.utc().subtract(1, 'week');
+ this.date_to = moment.utc();
this.dashboards_templates = ['website.dashboard_header', 'website.dashboard_content'];
this.graphs = [];
@@ -230,13 +230,13 @@ var Dashboard = AbstractAction.extend(ControlPanelMixin, {
on_date_range_button: function(date_range) {
if (date_range === 'week') {
this.date_range = 'week';
- this.date_from = moment().subtract(1, 'weeks');
+ this.date_from = moment.utc().subtract(1, 'weeks');
} else if (date_range === 'month') {
this.date_range = 'month';
- this.date_from = moment().subtract(1, 'months');
+ this.date_from = moment.utc().subtract(1, 'months');
} else if (date_range === 'year') {
this.date_range = 'year';
- this.date_from = moment().subtract(1, 'years');
+ this.date_from = moment.utc().subtract(1, 'years');
} else {
console.log('Unknown date range. Choose between [week, month, year]');
return;