From ff2ffb9e0d99b11b958a4e7d5f0be8412a68a624 Mon Sep 17 00:00:00 2001 From: Krina Oza Date: Tue, 28 Sep 2021 13:05:20 +0000 Subject: [PATCH] [IMP] web,sale_(project): improve keyboard navigation The purpose of this commit is, to add keyboard shortcut to multiple actions. So in this commit, added keyboard shortcut to several actions in project, sale_project, web_calendar and added smart action in command palette on statusbar. task-2655790 closes odoo/odoo#79805 Related: odoo/enterprise#22267 Signed-off-by: Laurent Stukkens (ltu) --- .../wizard/mail_compose_message_views.xml | 2 +- .../project_control_panel.xml | 2 +- addons/project/views/project_views.xml | 4 +- .../sale_project/views/project_task_views.xml | 4 +- .../web/static/src/legacy/js/core/dialog.js | 1 + .../src/legacy/js/fields/relational_fields.js | 41 ++++++++++++++++ .../src/legacy/js/views/view_dialogs.js | 9 +++- addons/web/static/src/legacy/xml/kanban.xml | 6 +-- .../static/src/legacy/xml/web_calendar.xml | 10 ++-- .../legacy/fields/relational_fields_tests.js | 48 +++++++++++++++++++ 10 files changed, 112 insertions(+), 15 deletions(-) diff --git a/addons/mail/wizard/mail_compose_message_views.xml b/addons/mail/wizard/mail_compose_message_views.xml index e8b5bfb9c97..a9428de6eed 100644 --- a/addons/mail/wizard/mail_compose_message_views.xml +++ b/addons/mail/wizard/mail_compose_message_views.xml @@ -68,7 +68,7 @@ - - + + diff --git a/addons/web/static/src/legacy/xml/web_calendar.xml b/addons/web/static/src/legacy/xml/web_calendar.xml index 9d184e64006..19384e5bffd 100644 --- a/addons/web/static/src/legacy/xml/web_calendar.xml +++ b/addons/web/static/src/legacy/xml/web_calendar.xml @@ -121,16 +121,16 @@ - +
- - - - + + + +
diff --git a/addons/web/static/tests/legacy/fields/relational_fields_tests.js b/addons/web/static/tests/legacy/fields/relational_fields_tests.js index 8d842736cd8..8edffa39563 100644 --- a/addons/web/static/tests/legacy/fields/relational_fields_tests.js +++ b/addons/web/static/tests/legacy/fields/relational_fields_tests.js @@ -9,6 +9,12 @@ var ListView = require('web.ListView'); var RamStorage = require('web.RamStorage'); var relationalFields = require('web.relational_fields'); var testUtils = require('web.test_utils'); +const core = require('web.core'); +const makeTestEnvironment = require("web.test_env"); +const { makeLegacyCommandService } = require("@web/legacy/utils"); +const { createWebClient, doAction } = require('@web/../tests/webclient/helpers'); +const { triggerHotkey, nextTick, click } = require("@web/../tests/helpers/utils"); +const { registry } = require("@web/core/registry"); const { makeLegacyDialogMappingTestEnv } = require('@web/../tests/helpers/legacy_env_utils'); @@ -1019,6 +1025,48 @@ QUnit.module('relational_fields', { form.destroy(); }); + // TODO: Once the code base is converted with wowl, replace webclient by formview. + QUnit.test('statusbar edited by the smart action "Move to stage..."', async function (assert) { + assert.expect(3); + + const legacyEnv = makeTestEnvironment({ bus: core.bus }); + const serviceRegistry = registry.category("services"); + serviceRegistry.add("legacy_command", makeLegacyCommandService(legacyEnv)); + + const views = { + 'partner,false,form': '' + + '
' + + '', + 'partner,false,search': '', + }; + const serverData = { models: this.data, views} + const webClient = await createWebClient({serverData}); + await doAction(webClient, { + res_id: 1, + type: 'ir.actions.act_window', + target: 'current', + res_model: 'partner', + 'view_mode': 'form', + 'views': [[false, 'form']], + }); + assert.containsOnce(webClient, ".o_field_widget") + + triggerHotkey("control+k") + await nextTick(); + const movestage = webClient.el.querySelectorAll(".o_command"); + const idx = [...movestage].map(el => el.textContent).indexOf("Move to Trululu...ALT + SHIFT + X") + assert.ok(idx >= 0); + + await click(movestage[idx]) + await nextTick(); + assert.deepEqual([...webClient.el.querySelectorAll(".o_command")].map(el => el.textContent), [ + "first record", + "second record", + "aaa", + ]) + await click(webClient.el, "#o_command_2") + }); + QUnit.module('FieldSelection'); QUnit.test('widget selection in a list view', async function (assert) {