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 @@