diff --git a/project_task_line/__manifest__.py b/project_task_line/__manifest__.py index d8023b12..6db1ed20 100644 --- a/project_task_line/__manifest__.py +++ b/project_task_line/__manifest__.py @@ -1,6 +1,6 @@ { 'name': 'Project Task Lines', - 'version': '16.0.1.0.0', + 'version': '17.0.1.0.0', 'author': 'Hibou Corp. ', 'website': 'https://hibou.io/', 'license': 'AGPL-3', diff --git a/project_task_line/migrations/17.0.1.0.0/pre-migration.py b/project_task_line/migrations/17.0.1.0.0/pre-migration.py new file mode 100644 index 00000000..85d8bd0c --- /dev/null +++ b/project_task_line/migrations/17.0.1.0.0/pre-migration.py @@ -0,0 +1,14 @@ +def migrate(cr, installed_version): + cr.execute( + """ + ALTER TABLE project_task_line + ADD COLUMN IF NOT EXISTS state VARCHAR + """, + ) + cr.execute( + """ + UPDATE project_task_line + SET state = kanban_state + WHERE kanban_state IN ('done', 'blocked') + """, + ) diff --git a/project_task_line/models/project.py b/project_task_line/models/project.py index 3557f69c..1a467a7f 100644 --- a/project_task_line/models/project.py +++ b/project_task_line/models/project.py @@ -5,32 +5,6 @@ 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") - - @api.depends('child_ids') - def _compute_subtask_count(self): - for task in self: - subtasks = task._get_all_subtasks() - task.subtask_count = len(subtasks) - task.subtask_count_done = len(subtasks.filtered(lambda t: t.is_closed)) - - def action_subtask(self): - action = self.env.ref('project.action_view_all_task').sudo().read()[0] - - # display all subtasks of current task - action['domain'] = [('id', 'child_of', self.id), ('id', '!=', self.id)] - - ctx = dict(self.env.context) - ctx = {k: v for k, v in ctx.items() if not k.startswith('search_default_')} - ctx.update({ - 'default_name': self.env.context.get('name', self.name) + ':', - 'default_parent_id': self.id, # will give default subtask field in `default_get` - 'default_company_id': self.env.company.id, - }) - - action['context'] = ctx - - return action class ProjectTaskLine(models.Model): @@ -40,19 +14,19 @@ class ProjectTaskLine(models.Model): task_id = fields.Many2one('project.task', required=True) name = fields.Char(string='Name') - user_id = fields.Many2one('res.users', string='User') + user_id = fields.Many2one( + 'res.users', string='Completed By', + context={'active_test': False}, + compute='_compute_user_id', + store=True, readonly=False, precompute=True, + ) sequence = fields.Integer(string='Sequence') - kanban_state = fields.Selection([ - ('normal', ''), + state = fields.Selection([ ('done', 'Done'), - ('blocked', 'Blocked')], string='State', - copy=False, default='normal', required=True, - help="A task's kanban state indicates special situations affecting it:\n" - " * Blank is the default situation\n" - " * Blocked indicates something is preventing the progress of this task\n" - " * Done indicates the task is complete") + ('blocked', 'Blocked'), + ], string='State', copy=False) - @api.onchange('kanban_state') - def _onchange_kanban_state(self): - if self.kanban_state == 'done': - self.user_id = self.env.user + @api.depends('state') + def _compute_user_id(self): + for line in self.filtered(lambda l: l.state == 'done' and not l.user_id): + line.user_id = self.env.user diff --git a/project_task_line/views/project_views.xml b/project_task_line/views/project_views.xml index c7614426..8df89a1f 100644 --- a/project_task_line/views/project_views.xml +++ b/project_task_line/views/project_views.xml @@ -5,24 +5,21 @@ project.task - - + + {'default_name': name + ':', 'default_user_ids': user_ids, 'default_project_id': project_id, 'default_milestone_id': milestone_id, 'subtask_action': True} - + - - + + - \ No newline at end of file +