diff options
| author | Aaron Bohy <aab@odoo.com> | 2018-08-31 08:54:06 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2018-10-08 09:21:39 +0000 |
| commit | 60f143c8e7b7ea2387031c968dfa0f31a288afb2 (patch) | |
| tree | aacc1c4c570048dfe77aa6fe679a65eb5f23e9e2 /addons/board/static/src/js/board_view.js | |
| parent | cfaf1f5ac5b634f32b6a3b65f54bf2e6761ec77c (diff) | |
[FIX] board: handle actions with no view_mode
The view_mode attribute is automatically set to the 'action' nodes
when the action is added to the dashboard using the 'Add to
dashboard' button in the searchview. However, other dashboard views
can be written by hand (see openacademy tutorial), and in this
case, we don't want to hardcode action's params (like context or
domain), as the dashboard can directly retrieve them from the
action. Same applies for the view_type, as the first view of the
action can be used, by default.
Before this rev., the second usecase wasn't handled, and it crashed
when no view_mode was specified. This rev. also ensure that the
context and domain are correctly retrieved from the action.
Closes #24088
closes odoo/odoo#27519
Diffstat (limited to 'addons/board/static/src/js/board_view.js')
| -rw-r--r-- | addons/board/static/src/js/board_view.js | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/addons/board/static/src/js/board_view.js b/addons/board/static/src/js/board_view.js index b2d57903a3d..126214cedf1 100644 --- a/addons/board/static/src/js/board_view.js +++ b/addons/board/static/src/js/board_view.js @@ -9,6 +9,7 @@ var Domain = require('web.Domain'); var FormController = require('web.FormController'); var FormRenderer = require('web.FormRenderer'); var FormView = require('web.FormView'); +var pyUtils = require('web.py_utils'); var viewRegistry = require('web.view_registry'); var _t = core._t; @@ -236,7 +237,6 @@ var BoardRenderer = FormRenderer.extend({ */ _createController: function (params) { var self = this; - var context = params.context.eval(); return this._rpc({ route: '/web/action/load', params: {action_id: params.actionID} @@ -246,18 +246,21 @@ var BoardRenderer = FormRenderer.extend({ // the action does not exist anymore return $.when(); } + var context = pyUtils.eval('context', new Context(params.context, action.context)); + var domain = params.domain || pyUtils.eval('domain', action.domain || '[]', action.context); + var viewType = params.viewType || action.views[0][1]; var view = _.find(action.views, function (descr) { - return descr[1] === params.viewType; - }) || [false, params.viewType]; + return descr[1] === viewType; + }) || [false, viewType]; return self.loadViews(action.res_model, context, [view]) .then(function (viewsInfo) { - var viewInfo = viewsInfo[params.viewType]; - var View = viewRegistry.get(params.viewType); + var viewInfo = viewsInfo[viewType]; + var View = viewRegistry.get(viewType); var view = new View(viewInfo, { action: action, context: context, - domain: params.domain, - groupBy: context.group_by, + domain: domain, + groupBy: context.group_by || [], modelName: action.res_model, hasSelectors: false, }); |
