diff options
| author | Romain Derie <rde@odoo.com> | 2020-11-04 11:39:25 +0000 |
|---|---|---|
| committer | Romain Derie <rde@odoo.com> | 2020-11-18 11:21:58 +0000 |
| commit | 06f954787cf60e657768e365a15ea4513d459c0b (patch) | |
| tree | 87f2c65a001f67b9f2316bbe1e833b5c9ebcc614 /addons/website/static | |
| parent | 26e26181c9680e89f8c8e1eb3b4c9dc2fc063d87 (diff) | |
[FIX] website: use correct action domain on dashboard
Without this commit, when clicking on a metric on the website dashboard, it
would not load the correct data.
Indeed, the dashboard is loaded for a specific website only, but clicking on a
metric opens the data for every website together.
Step to reproduce:
- Make some orders on 2 differents website ecommerce
- OPTIONAL: Get through the payment on some orders, then just leave some
products in the cart afterward to have some unpaid orders
- Go to the website dashboard, you see some metrics
- Change the selected website on top right, you see the metrics adapts
correctly
- Click on a metric, it doesn't fit the number you clicked on. For instance,
if you had 1 Unpaid Orders for website 1 and 3 Unpaid Orders for website 2,
you see 4 orders in the tree view once you have clicked the metric.
This commit ensures the correct website is appended to every dashboard action
domain.
opw-2369420
Fixes #44926, fixes #51125
Diffstat (limited to 'addons/website/static')
| -rw-r--r-- | addons/website/static/src/js/backend/dashboard.js | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/addons/website/static/src/js/backend/dashboard.js b/addons/website/static/src/js/backend/dashboard.js index c1dcfdb39d1..7b37557987c 100644 --- a/addons/website/static/src/js/backend/dashboard.js +++ b/addons/website/static/src/js/backend/dashboard.js @@ -6,6 +6,7 @@ var ajax = require('web.ajax'); var core = require('web.core'); var Dialog = require('web.Dialog'); var field_utils = require('web.field_utils'); +var pyUtils = require('web.py_utils'); var session = require('web.session'); var time = require('web.time'); var web_client = require('web.web_client'); @@ -353,6 +354,7 @@ var Dashboard = AbstractAction.extend({ on_dashboard_action: function (ev) { ev.preventDefault(); + var self = this var $action = $(ev.currentTarget); var additional_context = {}; if (this.date_range === 'week') { @@ -362,9 +364,18 @@ var Dashboard = AbstractAction.extend({ } else if (this.date_range === 'year') { additional_context = {search_default_year: true}; } - this.do_action($action.attr('name'), { - additional_context: additional_context, - on_reverse_breadcrumb: this.on_reverse_breadcrumb + this._rpc({ + route: '/web/action/load', + params: { + 'action_id': $action.attr('name'), + }, + }) + .then(function (action) { + action.domain = pyUtils.assembleDomains([action.domain, `[('website_id', '=', ${self.website_id})]`]); + return self.do_action(action, { + 'additional_context': additional_context, + 'on_reverse_breadcrumb': self.on_reverse_breadcrumb + }); }); }, |
