[IMP] todo, *: add an onboarding to-do

- Impacted modules:
    - todo
    - project (test adaptation)
    - mail (test adaptation)
    - test_discuss_full (test adaptation)

All users will get a personalized  onboarding to-do displayed in their
To-do app. This onboarding to-do shows:
- Tips on how to use the editor
- Guidance on how to use the mark as done and the convert to task action
- Information about to-dos visibility and sharing

task-3085077
This commit is contained in:
Hugo Carlier (Huca)
2023-05-15 09:01:27 +02:00
parent 0a59f37e7d
commit 71d3115ac6
6 changed files with 170 additions and 2 deletions
+1
View File
@@ -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',
],
+127
View File
@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<template id="todo_user_onboarding">
<h1>
<span style="font-size: 36px;">Hey <t t-out="object.name"/> &#128075; <br />
Welcome to the To-do app! </span>
</h1>
<p>
<span style="font-size: 14px;">
Use it to manage your urgent work, take notes on the go, and create tasks based on them.
</span>
</p>
<p><br /></p>
<h3>Using the editor</h3>
<hr />
<p>
<span style="font-size: 14px;">This private to-do is for you to play around with.</span>
<br />
<span style="font-size: 14px;">Ready to give it a spin?</span>
</p>
<p>
<span style="font-size: 14px;">Try the following</span>
</p>
<ul class="o_checklist">
<li id="checkId-140908257281">
<span style="font-size: 14px;">Click anywhere, and just start typing</span>
</li>
<li id="checkId-441216037148">
<span style="font-size: 14px;">Press Ctrl-Z to undo any change</span>
</li>
<li id="checkId-948702291173">
<span style="font-size: 14px;">Check this box to indicate it's done</span>
</li>
<li id="checkId-980463482772">
<span style="font-size: 14px;">
Select text to
<font class="bg-o-color-2">Highlight</font>,
<span style="text-decoration-line: line-through;">strikethrough</span>
or
<span style="font-weight: bolder;">style</span>
<span style="font-style: italic; text-decoration-line: underline;">it</span>
</span>
</li>
<li id="checkId-152369821198">
<span style="font-size: 14px;">
Below this list, try
<span style="font-weight: bolder;">commands</span>
by
<span style="font-weight: bolder;">
<font class="text-o-color-2">typing</font>
</span>
"<span style="font-weight: bolder;">/</span>"
</span>
</li>
<li class="oe-nested" id="checkId-947916154443">
<ul class="o_checklist">
<li id="checkId-1422510558483">
<span style="font-size: 14px;">
Add a checklist
(/<span style="font-style: italic;">checklist</span>)
</span>
</li>
<li id="checkId-109605733655">
<span style="font-size: 14px;">
Add a separator
(/<span style="font-style: italic;">separator</span>)
</span>
</li>
<li id="checkId-1518315885641">
<span style="font-size: 14px;">
Use
/<span style="font-style: italic;">heading</span>
to convert a text into a title
</span>
</li>
</ul>
</li>
</ul>
<p><br /></p>
<h3 id="">Create a task</h3>
<hr />
<p>
<span style="font-size: 14px;">
You can convert your to-dos into tasks and assign them to a project. To do this, you need to access the
<span style="font-weight: bolder;">
<font class="text-o-color-2">Convert to Task</font>
</span>
pop-up from the action menu of the to-do.
</span>
</p>
<p>
<span style="font-size: 14px;">
To-dos are now like
<span style="font-weight: bolder;">
<font class="text-o-color-2">private tasks</font>
</span>
and will appear in the Project app under
<span>
<font style="font-weight: bolder;" class="text-o-color-2">My Tasks</font>.
</span>
Similarly, private tasks created in the Project app will also appear in your to-dos.
</span>
</p>
<p><br /></p>
<h3>Who has access to what?</h3>
<hr />
<p>
<span style="font-size: 14px;">
To-dos, like private tasks, are only accessible to the users specified as assignees. You can use the
<span style="font-weight: bolder;">
<font class="text-o-color-2">assignees</font>
</span>
field above to share this to-do with other users.
</span>
</p>
<p>
<span style="font-size: 14px;">
During the conversion of a to-do to a task, you will be able to add or remove assignees to control who has access to the created task. Note that its visibility will also depend on the visibility settings of the project you are assigning it to.
</span>
</p>
</template>
</data></odoo>
+24 -1
View File
@@ -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
+7
View File
@@ -1,6 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="group_onboarding_todo" model="res.groups">
<field name="name">Onboarding todo already generated for those users</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>
<data noupdate="1">
<record model="ir.rule" id="project.task_visibility_rule">
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
+10
View File
@@ -276,6 +276,16 @@
<field name="act_window_id" ref="project_task_action_todo"/>
</record>
<!-- Todo pre-loading action -->
<record id="project_task_preload_action_todo" model="ir.actions.server">
<field name="name">menu load To-dos</field>
<field name="model_id" ref="project.model_project_task"/>
<field name="state">code</field>
<field name="code">
model._ensure_onboarding_todo(); action = env["ir.actions.actions"]._for_xml_id("todo.project_task_action_todo")
</field>
</record>
<!-- Conversion actions-->
<record id="project_task_action_convert_todo_to_task" model="ir.actions.act_window">
<field name="name">Convert to Task</field>
+1 -1
View File
@@ -3,7 +3,7 @@
<menuitem
id="menu_todo_todos"
name="To-do"
action="todo.project_task_action_todo"
action="todo.project_task_preload_action_todo"
web_icon="todo,static/description/icon.svg">
</menuitem>
</odoo>