[FIX] project_todo: missing "add a to-do" in the command palette

Task 3300854 would remove the "add a to-do" action in the systray, but
by doing so, it removed the action in the command palette as well. This
PR will re-add the action in the command palette.

The ActivityMenu component is patched to add the command each time it is
loaded.

task-3580533

closes odoo/odoo#141168

Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
This commit is contained in:
dise-odoo
2023-11-07 19:32:25 +00:00
parent f3a2ba5e7e
commit 6d9302c786
3 changed files with 54 additions and 0 deletions
+1
View File
@@ -28,6 +28,7 @@
'project_todo/static/src/components/**/*',
'project_todo/static/src/scss/todo.scss',
'project_todo/static/src/views/**/*',
'project_todo/static/src/web/**/*',
],
},
'license': 'LGPL-3',
@@ -186,6 +186,14 @@ msgstr ""
msgid "Add To-Do"
msgstr ""
#. module: project_todo
#. odoo-javascript
#: code:addons/project_todo/static/src/web/activity/activity_menu_patch.js:0
#: code:addons/project_todo/static/src/web/activity/activity_menu_patch.js:0
#, python-format
msgid "Add a To-Do"
msgstr ""
#. module: project_todo
#: model_terms:ir.ui.view,arch_db:project_todo.mail_activity_todo_create_popup
msgid "Add details about your to-do..."
@@ -0,0 +1,45 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { ActivityMenu } from "@mail/core/web/activity_menu";
import { FormViewDialog } from "@web/views/view_dialogs/form_view_dialog";
import { useCommand } from "@web/core/commands/command_hook";
import { useService } from "@web/core/utils/hooks";
import { patch } from "@web/core/utils/patch";
import { registry } from "@web/core/registry";
// Add a to-do category for the command palette
registry.category("command_categories").add("to-do", {}, { sequence: 105 });
patch(ActivityMenu.prototype, {
setup() {
super.setup(...arguments);
this.orm = useService("orm");
this.dialogService = useService("dialog");
useCommand(
_t("Add a To-Do"),
() => {
document.body.click(); // hack to close command palette
this.createActivityTodo();
},
{
category: "to-do",
hotkey: "alt+control+l",
global: true,
}
);
},
async createActivityTodo() {
const wizard = await this.orm.call("mail.activity.todo.create", "create", [{
"user_id": this.userId,
}]);
this.dialogService.add(FormViewDialog, {
title: _t("Add a To-Do"),
resModel: "mail.activity.todo.create",
resId: wizard,
preventCreate: true,
size: "md",
});
},
});