[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.
This commit is contained in:
committed by
Aaron Bohy
parent
a76f8715fb
commit
f787ac9edb
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user