summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorPriyanka Kakadiya <pka@odoo.com>2018-01-23 16:58:50 +0530
committerAaron Bohy <aab@odoo.com>2018-02-05 14:55:30 +0100
commitf787ac9edb5fe291f0088c11fbcaa9ebf268f3f5 (patch)
tree30042d10d23190c0f28f85126902b5c8e4e269ce /addons
parenta76f8715fb6e1642c169c92452180486634e3a9d (diff)
[FIX] web: ActionManager: switch to unknown view
A traceback occurred on the Intrastat list view (Accounting > Reporting > Management > Intrastat), when the user clicked on a row of the list. This action only specifies 2 view modes: list and kanban. When a record is clicked, the ActionManager tries to open that record in a form view. As the view isn't in the action, this request should be ignored. Before this rev., this case wasn't correctly supported.
Diffstat (limited to 'addons')
-rw-r--r--addons/web/static/src/js/chrome/action_manager_act_window.js9
-rw-r--r--addons/web/static/tests/chrome/action_manager_tests.js41
2 files changed, 49 insertions, 1 deletions
diff --git a/addons/web/static/src/js/chrome/action_manager_act_window.js b/addons/web/static/src/js/chrome/action_manager_act_window.js
index 56c6e45a08d..7963af8ec32 100644
--- a/addons/web/static/src/js/chrome/action_manager_act_window.js
+++ b/addons/web/static/src/js/chrome/action_manager_act_window.js
@@ -159,6 +159,14 @@ ActionManager.include({
*/
_createViewController: function (action, viewType, viewOptions, options) {
var self = this;
+ var viewDescr = _.findWhere(action.views, {type: viewType});
+ if (!viewDescr) {
+ // the requested view type isn't specified in the action (e.g.
+ // action with list view only, user clicks on a row in the list, it
+ // tries to switch to form view)
+ return $.Deferred().reject();
+ }
+
var controllerID = _.uniqueId('controller_');
var controller = {
actionID: action.jsID,
@@ -184,7 +192,6 @@ ActionManager.include({
// communication with trigger_up (e.g. for 'env_updated' event)
viewOptions = _.extend(viewOptions, { controllerID: controllerID });
- var viewDescr = _.findWhere(action.views, {type: viewType});
var view = new viewDescr.Widget(viewDescr.fieldsView, viewOptions);
var def = $.Deferred();
action.controllers[viewType] = def;
diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js
index f6a0007c1a9..1ee50daaf65 100644
--- a/addons/web/static/tests/chrome/action_manager_tests.js
+++ b/addons/web/static/tests/chrome/action_manager_tests.js
@@ -2270,6 +2270,47 @@ QUnit.module('ActionManager', {
actionManager.destroy();
});
+ QUnit.test('switch request to unknown view type', function (assert) {
+ assert.expect(7);
+
+ this.actions.push({
+ id: 33,
+ name: 'Partners',
+ res_model: 'partner',
+ type: 'ir.actions.act_window',
+ views: [[false, 'list'], [1, 'kanban']], // no form view
+ });
+
+ var actionManager = createActionManager({
+ actions: this.actions,
+ archs: this.archs,
+ data: this.data,
+ mockRPC: function (route, args) {
+ assert.step(args.method || route);
+ return this._super.apply(this, arguments);
+ },
+ });
+ actionManager.doAction(33);
+
+ assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ "should display the list view");
+
+ // try to open a record in a form view
+ actionManager.$('.o_list_view .o_data_row:first').click();
+ assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ "should still display the list view");
+ assert.strictEqual(actionManager.$('.o_form_view').length, 0,
+ "should not display the form view");
+
+ assert.verifySteps([
+ '/web/action/load',
+ 'load_views',
+ '/web/dataset/search_read',
+ ]);
+
+ actionManager.destroy();
+ });
+
QUnit.module('Actions in target="new"');
QUnit.test('can execute act_window actions in target="new"', function (assert) {