summaryrefslogtreecommitdiff
path: root/addons/board/static
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2020-11-23 16:06:28 +0000
committerNicolas Martinelli <nim@odoo.com>2020-12-01 13:34:28 +0000
commitdd42e8e2bef1a1e9157ffdfc0c5f59b64b9f83ee (patch)
treeb7bdaab089c02276612aac06d5c1a2eb2fc0febb /addons/board/static
parentdd3773e6b71e0fa687d4f0b5b1b4cbc6b2706ccc (diff)
[FIX] board: incorrect type in action.views
- Install the `board` module - Go to Accounting / Customer / Invoices - Go to the Pivot view - Add the view to the Dashboard - Go to Dashboard - Click on a cell of the pivot view to open the list view The list view is the supplier list view instead of the customer list views. The root cause of the issue is that in the case of the Dashboard, we receive an Array of Array, while in the regular access we receive an Array of Dict. In the former case, the `_findView` returns `false` for all views despite the fact that the correct list is already provided. Since the views are `false`, `load_views` chooses the default views for the model, which are in this case the supplier views. In the Dashboard, the view is created in: https://github.com/odoo/odoo/blob/1bdd0cc247d36c869ffdee7d501cb65d36be47a6/addons/board/static/src/js/board_view.js#L267-L274 When switching view, the action is set in: https://github.com/odoo/odoo/blob/1bdd0cc247d36c869ffdee7d501cb65d36be47a6/addons/web/static/src/js/chrome/action_manager_act_window.js#L895 and the view is created in: https://github.com/odoo/odoo/blob/1bdd0cc247d36c869ffdee7d501cb65d36be47a6/addons/web/static/src/js/chrome/action_manager_act_window.js#L235 The assumption that a list of dicts is received is used is several places: https://github.com/odoo/odoo/blob/7a35515e495d4fb8edbaf252988c8c3c144f4442/addons/web/static/src/js/views/calendar/calendar_view.js#L131 https://github.com/odoo/odoo/blob/7a35515e495d4fb8edbaf252988c8c3c144f4442/addons/web/static/src/js/views/pivot/pivot_view.js#L131 https://github.com/odoo/enterprise/blob/05a78e94073aea88b2314918cadc478a367afef0/web_cohort/static/src/js/cohort_view.js#L93 https://github.com/odoo/enterprise/blob/05a78e94073aea88b2314918cadc478a367afef0/web_grid/static/src/js/grid_view.js#L79-L84 opw-2387417 closes odoo/odoo#62686 X-original-commit: 5fc81820de49b78f70d471d0f9cc99afc874a550 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Diffstat (limited to 'addons/board/static')
-rw-r--r--addons/board/static/src/js/board_view.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/addons/board/static/src/js/board_view.js b/addons/board/static/src/js/board_view.js
index 4c4d6b92ae5..87b5034f04d 100644
--- a/addons/board/static/src/js/board_view.js
+++ b/addons/board/static/src/js/board_view.js
@@ -249,8 +249,14 @@ var BoardRenderer = FormRenderer.extend({
action.context = context;
action.domain = domain;
- var viewType = params.viewType || action.views[0][1];
- var view = _.find(action.views, function (descr) {
+
+ // When creating a view, `action.views` is expected to be an array of dicts, while
+ // '/web/action/load' returns an array of arrays.
+ action._views = action.views;
+ action.views = $.map(action.views, function (view) { return {viewID: view[0], type: view[1]}});
+
+ var viewType = params.viewType || action._views[0][1];
+ var view = _.find(action._views, function (descr) {
return descr[1] === viewType;
}) || [false, viewType];
return self.loadViews(action.res_model, context, [view])
@@ -281,7 +287,7 @@ var BoardRenderer = FormRenderer.extend({
});
return view.getController(self).then(function (controller) {
self._boardFormViewIDs[controller.handle] = _.first(
- _.find(action.views, function (descr) {
+ _.find(action._views, function (descr) {
return descr[1] === 'form';
})
);