diff --git a/addons/todo/__manifest__.py b/addons/todo/__manifest__.py index 401bb97f71e..c29a82a26bc 100644 --- a/addons/todo/__manifest__.py +++ b/addons/todo/__manifest__.py @@ -15,6 +15,7 @@ 'security/ir.model.access.csv', 'security/todo_security.xml', 'data/mail_activity_type_data.xml', + 'data/todo_template.xml', 'views/project_task_views.xml', 'views/todo_menus.xml', ], diff --git a/addons/todo/data/todo_template.xml b/addons/todo/data/todo_template.xml new file mode 100644 index 00000000000..7db59aa41d4 --- /dev/null +++ b/addons/todo/data/todo_template.xml @@ -0,0 +1,127 @@ + + + + + + + diff --git a/addons/todo/models/project_task.py b/addons/todo/models/project_task.py index 00dd552228e..6ebd1cfab37 100644 --- a/addons/todo/models/project_task.py +++ b/addons/todo/models/project_task.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, models, _ +from odoo import api, models, _, _lt, Command from odoo.tools import html2plaintext class Task(models.Model): @@ -20,6 +20,29 @@ class Task(models.Model): vals['name'] = _('Untitled to-do') return super().create(vals_list) + def _ensure_onboarding_todo(self): + if not self.env.user.has_group('todo.group_onboarding_todo'): + self._generate_onboarding_todo(self.env.user) + onboarding_group = self.env.ref('todo.group_onboarding_todo').sudo() + onboarding_group.write({'users': [Command.link(self.env.user.id)]}) + + def _generate_onboarding_todo(self, user): + user.ensure_one() + body = self.with_context(lang=user.lang or self.env.user.lang).env['ir.qweb']._render( + 'project_todo.todo_user_onboarding', + {'object': user}, + minimal_qcontext=True, + raise_if_not_found=False + ) + if not body: + return + title = _lt('Welcome %s!', user.name) + self.env['project.task'].create([{ + 'user_ids': user.ids, + 'description': body, + 'name': title, + }]) + def action_convert_to_task(self): self.ensure_one() self.company_id = self.project_id.company_id diff --git a/addons/todo/security/todo_security.xml b/addons/todo/security/todo_security.xml index ec80ae8bea4..eda32e0fe67 100644 --- a/addons/todo/security/todo_security.xml +++ b/addons/todo/security/todo_security.xml @@ -1,6 +1,13 @@ + + + Onboarding todo already generated for those users + + + + diff --git a/addons/todo/views/project_task_views.xml b/addons/todo/views/project_task_views.xml index 1ff324fa714..1b4b4584ed2 100644 --- a/addons/todo/views/project_task_views.xml +++ b/addons/todo/views/project_task_views.xml @@ -276,6 +276,16 @@ + + + menu load To-dos + + code + + model._ensure_onboarding_todo(); action = env["ir.actions.actions"]._for_xml_id("todo.project_task_action_todo") + + + Convert to Task diff --git a/addons/todo/views/todo_menus.xml b/addons/todo/views/todo_menus.xml index 9362e720e4f..d4d43598679 100644 --- a/addons/todo/views/todo_menus.xml +++ b/addons/todo/views/todo_menus.xml @@ -3,7 +3,7 @@