[FIX] web: data-mobile on action_manager_act_window
Commit ca4eaf4 introduced the data-mobile attribute, used to specify options to pass when executing an action, only in mobile (like using a fullscreen modal). However, we forgot to add the 'isMobile' check, so the option was passed in desktop as well. This commit fixes the issue and adds some tests. Task ID: 2155601 closes odoo/odoo#47333 X-original-commit: 6cb68a53106fa7326a7f818461418437d5a0df77 Signed-off-by: res-odoo <res-odoo@users.noreply.github.com>
This commit is contained in:
@@ -688,7 +688,7 @@ ActionManager.include({
|
||||
};
|
||||
}
|
||||
var options = {on_close: ev.data.on_closed};
|
||||
if (actionData.mobile) {
|
||||
if (config.device.isMobile && actionData.mobile) {
|
||||
options = Object.assign({}, options, actionData.mobile);
|
||||
}
|
||||
action.flags = _.extend({}, action.flags, {searchPanelDefaultNoFilter: true});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
odoo.define('web.action_manager_mobile_tests', function (require) {
|
||||
"use strict";
|
||||
|
||||
var ActionManager = require('web.ActionManager');
|
||||
var testUtils = require('web.test_utils');
|
||||
|
||||
var createActionManager = testUtils.createActionManager;
|
||||
@@ -131,6 +132,57 @@ QUnit.module('ActionManager', {
|
||||
|
||||
actionManager.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('data-mobile attribute on action button, in mobile', async function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
testUtils.mock.patch(ActionManager, {
|
||||
doAction(action, options) {
|
||||
if (typeof action !== 'number' && action.id === 1) {
|
||||
assert.strictEqual(options.plop, 28);
|
||||
} else {
|
||||
assert.strictEqual(options.plop, undefined);
|
||||
}
|
||||
return this._super(...arguments);
|
||||
},
|
||||
});
|
||||
|
||||
this.archs['partner,75,kanban'] = `
|
||||
<kanban>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div class="oe_kanban_global_click">
|
||||
<field name="display_name"/>
|
||||
<button
|
||||
name="1"
|
||||
string="Execute action"
|
||||
type="action"
|
||||
data-mobile='{"plop": 28}'/>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>`;
|
||||
|
||||
this.actions.push({
|
||||
id: 100,
|
||||
name: 'action 100',
|
||||
res_model: 'partner',
|
||||
type: 'ir.actions.act_window',
|
||||
views: [[75, 'kanban']],
|
||||
});
|
||||
|
||||
const actionManager = await createActionManager({
|
||||
actions: this.actions,
|
||||
archs: this.archs,
|
||||
data: this.data
|
||||
});
|
||||
|
||||
await actionManager.doAction(100, {});
|
||||
await testUtils.dom.click(actionManager.$('button[data-mobile]:first'));
|
||||
|
||||
actionManager.destroy();
|
||||
testUtils.mock.unpatch(ActionManager);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
odoo.define('web.action_manager_tests', function (require) {
|
||||
"use strict";
|
||||
|
||||
var ActionManager = require('web.ActionManager');
|
||||
var ReportClientAction = require('report.client_action');
|
||||
var Notification = require('web.Notification');
|
||||
var NotificationService = require('web.NotificationService');
|
||||
@@ -4218,6 +4219,53 @@ QUnit.module('ActionManager', {
|
||||
actionManager.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('data-mobile attribute on action button, in desktop', async function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
testUtils.mock.patch(ActionManager, {
|
||||
doAction(action, options) {
|
||||
assert.strictEqual(options.plop, undefined);
|
||||
return this._super(...arguments);
|
||||
},
|
||||
});
|
||||
|
||||
this.archs['partner,75,kanban'] = `
|
||||
<kanban>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div class="oe_kanban_global_click">
|
||||
<field name="display_name"/>
|
||||
<button
|
||||
name="1"
|
||||
string="Execute action"
|
||||
type="action"
|
||||
data-mobile='{"plop": 28}'/>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>`;
|
||||
|
||||
this.actions.push({
|
||||
id: 100,
|
||||
name: 'action 100',
|
||||
res_model: 'partner',
|
||||
type: 'ir.actions.act_window',
|
||||
views: [[75, 'kanban']],
|
||||
});
|
||||
|
||||
const actionManager = await createActionManager({
|
||||
actions: this.actions,
|
||||
archs: this.archs,
|
||||
data: this.data
|
||||
});
|
||||
|
||||
await actionManager.doAction(100, {});
|
||||
await testUtils.dom.click(actionManager.$('button[data-mobile]:first'));
|
||||
|
||||
actionManager.destroy();
|
||||
testUtils.mock.unpatch(ActionManager);
|
||||
});
|
||||
|
||||
QUnit.module('Search View Action');
|
||||
|
||||
QUnit.test('search view should keep focus during do_search', async function (assert) {
|
||||
|
||||
Reference in New Issue
Block a user