diff --git a/project_task_line/__init__.py b/project_task_line/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/project_task_line/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/project_task_line/__manifest__.py b/project_task_line/__manifest__.py new file mode 100644 index 00000000..17df456e --- /dev/null +++ b/project_task_line/__manifest__.py @@ -0,0 +1,21 @@ +{ + 'name': 'Project Task Lines', + 'version': '13.0.1.0.0', + 'author': 'Hibou Corp. ', + 'website': 'https://hibou.io/', + 'license': 'AGPL-3', + 'category': 'Tools', + 'complexity': 'easy', + 'description': """ +Adds "todo" lines onto Project Tasks, and improves sub-tasks. + """, + 'depends': [ + 'project', + ], + 'data': [ + 'security/ir.model.access.csv', + 'views/project_views.xml', + ], + 'installable': True, + 'auto_install': False, +} diff --git a/project_task_line/models/__init__.py b/project_task_line/models/__init__.py new file mode 100644 index 00000000..351a3ad3 --- /dev/null +++ b/project_task_line/models/__init__.py @@ -0,0 +1 @@ +from . import project diff --git a/project_task_line/models/project.py b/project_task_line/models/project.py new file mode 100644 index 00000000..0d0f4ab7 --- /dev/null +++ b/project_task_line/models/project.py @@ -0,0 +1,42 @@ +from odoo import api, fields, models + + +class ProjectTask(models.Model): + _inherit = 'project.task' + + line_ids = fields.One2many('project.task.line', 'task_id', string='Todo List') + subtask_count_done = fields.Integer(compute='_compute_subtask_count', string="Sub-task Done count") + + def _compute_subtask_count(self): + for task in self: + task.subtask_count = self.search_count([('id', 'child_of', task.id), ('id', '!=', task.id)]) + if task.subtask_count: + task.subtask_count_done = self.search_count([('id', 'child_of', task.id), ('id', '!=', task.id), + ('stage_id.fold', '=', True)]) + else: + task.subtask_count_done = 0 + + +class ProjectTaskLine(models.Model): + _name = 'project.task.line' + _description = 'Task Todos' + _order = 'sequence, id asc' + + task_id = fields.Many2one('project.task', required=True) + name = fields.Char(string='Name') + user_id = fields.Many2one('res.users', string='User') + sequence = fields.Integer(string='Sequence') + kanban_state = fields.Selection([ + ('normal', 'Grey'), + ('done', 'Green'), + ('blocked', 'Red')], string='Kanban State', + copy=False, default='normal', required=True, + help="A task's kanban state indicates special situations affecting it:\n" + " * Grey is the default situation\n" + " * Red indicates something is preventing the progress of this task\n" + " * Green indicates the task is complete") + + @api.onchange('kanban_state') + def _onchange_kanban_state(self): + if self.kanban_state == 'done': + self.user_id = self.env.user diff --git a/project_task_line/security/ir.model.access.csv b/project_task_line/security/ir.model.access.csv new file mode 100644 index 00000000..a4846d4f --- /dev/null +++ b/project_task_line/security/ir.model.access.csv @@ -0,0 +1,3 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +"access_project_task_line","access_project_task_line","model_project_task_line","base.group_user",1,1,1,1 +"access_project_task_line_public","access_project_task_line public","model_project_task_line","base.group_public",1,0,0,0 \ No newline at end of file diff --git a/project_task_line/views/project_views.xml b/project_task_line/views/project_views.xml new file mode 100644 index 00000000..81bdf9a5 --- /dev/null +++ b/project_task_line/views/project_views.xml @@ -0,0 +1,28 @@ + + + + project.task.form.inherit + project.task + + + +
+ / + Sub-Tasks +
+
+ + + + + + + + + + + + +
+
+
\ No newline at end of file