From 76b513917b4dad6eeecb4decac24e8c2d2c75b00 Mon Sep 17 00:00:00 2001 From: "Audric Onockx (auon)" Date: Thu, 19 May 2022 13:31:12 +0000 Subject: [PATCH] [IMP] web,project: add and modify commands in the palette \- Add 'Move to next stage' Generic, we think it is a useful tool to have anywhere. \- Change the 'Set priority...' command to 'Set priority as Low/High' : Only 1 command will be available with the 'not current' priority. Specific, because it is used on selection fields, which means there could be more than 2 options. \- Transform the 'Set kanban state...' command into three commands Generic. 2 commands will be available. One for each 'not current' kanban state. task-2857447 closes odoo/odoo#91821 Signed-off-by: Laurent Stukkens (ltu) --- .../project_task_priority_switch_field.js | 32 ++++++++++++++ addons/project/views/project_views.xml | 4 +- .../state_selection/state_selection_field.js | 40 +++++++---------- .../views/fields/statusbar/statusbar_field.js | 44 ++++++++++++++++--- .../fields/state_selection_field_tests.js | 23 +++++----- 5 files changed, 102 insertions(+), 41 deletions(-) create mode 100644 addons/project/static/src/views/fields/project_task_priority_switch_field.js diff --git a/addons/project/static/src/views/fields/project_task_priority_switch_field.js b/addons/project/static/src/views/fields/project_task_priority_switch_field.js new file mode 100644 index 00000000000..c6c7acaa694 --- /dev/null +++ b/addons/project/static/src/views/fields/project_task_priority_switch_field.js @@ -0,0 +1,32 @@ +/** @odoo-module **/ + +import { sprintf } from "@web/core/utils/strings"; +import { registry } from "@web/core/registry"; +import { PriorityField } from "@web/views/fields/priority/priority_field"; +import { useCommand } from "@web/core/commands/command_hook"; +import { useState } from "@odoo/owl"; + +export class PrioritySwitchField extends PriorityField { + setup() { + this.state = useState({ + index: -1, + }); + if (this.props.record.activeFields[this.props.name].viewType !== "form") { + return; + } + + for (const [id, name] of this.options) { + useCommand( + sprintf(this.env._t("Set priority as %s"), name), + () => this.props.update(id), + { + category: "smart_action", + hotkey: "alt+r", + isAvailable: () => this.props.value !== id, + } + ); + } + } +} + +registry.category("fields").add("priority_switch", PrioritySwitchField); diff --git a/addons/project/views/project_views.xml b/addons/project/views/project_views.xml index 01bc0cbbb0a..b4ad612bb87 100644 --- a/addons/project/views/project_views.xml +++ b/addons/project/views/project_views.xml @@ -1090,7 +1090,7 @@