diff --git a/addons/todo/models/project_task.py b/addons/todo/models/project_task.py
index 00f014b4c58..00dd552228e 100644
--- a/addons/todo/models/project_task.py
+++ b/addons/todo/models/project_task.py
@@ -19,3 +19,14 @@ class Task(models.Model):
else:
vals['name'] = _('Untitled to-do')
return super().create(vals_list)
+
+ def action_convert_to_task(self):
+ self.ensure_one()
+ self.company_id = self.project_id.company_id
+ return {
+ 'view_mode': 'form',
+ 'res_model': 'project.task',
+ 'res_id': self.id,
+ 'type': 'ir.actions.act_window',
+ 'target': 'main',
+ }
diff --git a/addons/todo/static/src/scss/todo.scss b/addons/todo/static/src/scss/todo.scss
index 469a67aa3d4..ba6fb0291c7 100644
--- a/addons/todo/static/src/scss/todo.scss
+++ b/addons/todo/static/src/scss/todo.scss
@@ -21,6 +21,9 @@
flex: 1;
}
}
+ .o_widget_todo_archived > .ribbon {
+ margin-top: 0px;
+ }
}
.o_field_html .note-editable {
border: none !important;
diff --git a/addons/todo/static/src/views/todo_conversion_form/todo_conversion_form_controller.js b/addons/todo/static/src/views/todo_conversion_form/todo_conversion_form_controller.js
new file mode 100644
index 00000000000..48617b2ce23
--- /dev/null
+++ b/addons/todo/static/src/views/todo_conversion_form/todo_conversion_form_controller.js
@@ -0,0 +1,20 @@
+/** @odoo-module **/
+
+import { onMounted } from "@odoo/owl";
+import { FormController } from "@web/views/form/form_controller";
+
+export class TodoConversionFormController extends FormController {
+ /**
+ * Allows to autofocus the first element of the conversion form
+ *
+ * @override
+ * @private
+ */
+ setup() {
+ super.setup();
+ onMounted(() => {
+ const firstConversionInput = document.querySelector('div.o_todo_conversion_form_view input');
+ firstConversionInput.focus();
+ });
+ }
+}
diff --git a/addons/todo/static/src/views/todo_conversion_form/todo_conversion_form_view.js b/addons/todo/static/src/views/todo_conversion_form/todo_conversion_form_view.js
new file mode 100644
index 00000000000..4b4cc56ac86
--- /dev/null
+++ b/addons/todo/static/src/views/todo_conversion_form/todo_conversion_form_view.js
@@ -0,0 +1,12 @@
+/** @odoo-module **/
+
+import { registry } from "@web/core/registry";
+import { formView } from "@web/views/form/form_view";
+import { TodoConversionFormController } from "./todo_conversion_form_controller";
+
+export const todoConversionFormView = {
+ ...formView,
+ Controller: TodoConversionFormController,
+};
+
+registry.category("views").add("todo_conversion_form", todoConversionFormView);
diff --git a/addons/todo/static/src/views/todo_form/todo_form_controller.js b/addons/todo/static/src/views/todo_form/todo_form_controller.js
index 2efa8b70bd8..7aed69c4da0 100644
--- a/addons/todo/static/src/views/todo_form/todo_form_controller.js
+++ b/addons/todo/static/src/views/todo_form/todo_form_controller.js
@@ -2,13 +2,50 @@
import { FormController } from "@web/views/form/form_controller";
import { TodoEditableBreadcrumbName } from "@todo/components/todo_editable_breadcrumb_name/todo_editable_breadcrumb_name";
+import { onWillStart } from "@odoo/owl";
/**
* The FormController is overridden to be able to manage the edition of the name of a to-do directly
* in the breadcrumb.
*/
-export class TodoFormController extends FormController {}
+export class TodoFormController extends FormController {
+ static template = "todo.TodoFormView";
-Object.assign(TodoFormController.components, { TodoEditableBreadcrumbName });
-TodoFormController.template = 'todo.TodoFormView';
+ setup() {
+ super.setup();
+ onWillStart(async () => {
+ this.projectAccess = await this.user.hasGroup("project.group_project_user");
+ });
+ }
+
+ get actionMenuItems() {
+ const actionToKeep = ["archive", "unarchive", "duplicate", "delete"];
+ const menuItems = super.actionMenuItems;
+ const filteredActions =
+ menuItems.action?.filter((action) => actionToKeep.includes(action.key)) || [];
+
+ if (this.projectAccess) {
+ filteredActions.push({
+ description: this.env._t("Convert to Task"),
+ callback: () => {
+ this.model.actionService.doAction(
+ "todo.project_task_action_convert_todo_to_task",
+ {
+ props: {
+ resId: this.model.root.resId,
+ },
+ }
+ );
+ },
+ });
+ }
+ menuItems.action = filteredActions;
+ menuItems.print = [];
+ return menuItems;
+ }
+}
+
+Object.assign(TodoFormController.components, {
+ TodoEditableBreadcrumbName,
+});
diff --git a/addons/todo/static/src/views/todo_list/todo_list_controller.js b/addons/todo/static/src/views/todo_list/todo_list_controller.js
new file mode 100644
index 00000000000..445eeae7fe2
--- /dev/null
+++ b/addons/todo/static/src/views/todo_list/todo_list_controller.js
@@ -0,0 +1,15 @@
+/** @odoo-module */
+
+import { ListController } from "@web/views/list/list_controller";
+
+export class TodoListController extends ListController {
+ get actionMenuItems() {
+ this.archiveEnabled = true;
+ const actionToKeep = ["archive", "unarchive", "duplicate", "delete"];
+ const menuItems = super.actionMenuItems;
+ const filteredActions = menuItems.action?.filter(action => actionToKeep.includes(action.key)) || [];
+ menuItems.action = filteredActions;
+ menuItems.print = [];
+ return menuItems;
+ }
+}
diff --git a/addons/todo/static/src/views/todo_list/todo_list_view.js b/addons/todo/static/src/views/todo_list/todo_list_view.js
new file mode 100644
index 00000000000..1b4566227a0
--- /dev/null
+++ b/addons/todo/static/src/views/todo_list/todo_list_view.js
@@ -0,0 +1,12 @@
+/** @odoo-module **/
+
+import { registry } from "@web/core/registry";
+import { listView } from "@web/views/list/list_view";
+import { TodoListController } from "./todo_list_controller";
+
+export const todoListView = {
+ ...listView,
+ Controller: TodoListController,
+};
+
+registry.category("views").add("todo_list", todoListView);
diff --git a/addons/todo/views/project_task_views.xml b/addons/todo/views/project_task_views.xml
index 7b519af5573..1ff324fa714 100644
--- a/addons/todo/views/project_task_views.xml
+++ b/addons/todo/views/project_task_views.xml
@@ -80,7 +80,7 @@
default_group_by="personal_stage_type_ids"
editable="bottom"
multi_edit="1"
- sample="1">
+ js_class="todo_list">
@@ -146,6 +146,40 @@
+
+
+ project.task
+ project.task.view.todo.conversion.form
+ 999
+
+
+
+
+
project.task.view.todo.activity
@@ -242,4 +276,18 @@
+
+
+ Convert to Task
+ project.task
+ form
+ new
+
+
+
+ form
+
+
+
+