Files
odoo_source/addons/todo/models/project_task.py
T
Hugo Carlier (Huca)andXavier Bol 0a59f37e7d [IMP] todo: add conversion form for todo->task
This commit:
- Restrict the actions available in To-do to the static ones (archive,
unarchive, delete, duplicate)
- Add a action to convert todo to task

The conversion form, available through the action menu, allows to convert a
to-do/a private task (task with no project) to a task linked to a
project by setting:
- a project
- assignees
- project tags

This conversion form is only available in the form view of to-dos.

To be improved:
- Better management of the information displayed in the chatter when
setting followers to a to-do

task-3085077

Co-authored-by: Xavier Bol (xbo) <xbo@odoo.com>
2023-05-15 09:01:27 +02:00

33 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models, _
from odoo.tools import html2plaintext
class Task(models.Model):
_inherit = 'project.task'
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if not vals.get('name') and not vals.get('project_id') and not vals.get('parent_id'):
if vals.get('description'):
# Generating name from first line of the description
text = html2plaintext(vals['description'])
name = text.strip().replace('*', '').partition("\n")[0]
vals['name'] = (name[:97] + '...') if len(name) > 100 else name
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',
}