[IMP] project: unarchive tasks when unarchiving stages
Currently, all of the tasks contained in a stage are archived when the stage is archived. However, the tasks remained archived when the stage is unarchived. So in this commit, If the user unarchives a stage, ask the user to unarchive the tasks it contains in the process. task-2835624 closes odoo/odoo#94008 Related: odoo/enterprise#28301 Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
This commit is contained in:
@@ -138,6 +138,27 @@ class ProjectTaskType(models.Model):
|
||||
self.env['project.task'].search([('stage_id', 'in', self.ids)]).write({'active': False})
|
||||
return super(ProjectTaskType, self).write(vals)
|
||||
|
||||
def toggle_active(self):
|
||||
res = super().toggle_active()
|
||||
stage_active = self.filtered('active')
|
||||
inactive_tasks = self.env['project.task'].with_context(active_test=False).search(
|
||||
[('active', '=', False), ('stage_id', 'in', stage_active.ids)], limit=1)
|
||||
if stage_active and inactive_tasks:
|
||||
wizard = self.env['project.task.type.delete.wizard'].create({
|
||||
'stage_ids': stage_active.ids,
|
||||
})
|
||||
|
||||
return {
|
||||
'name': _('Unarchive Tasks'),
|
||||
'view_mode': 'form',
|
||||
'res_model': 'project.task.type.delete.wizard',
|
||||
'views': [(self.env.ref('project.view_project_task_type_unarchive_wizard').id, 'form')],
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_id': wizard.id,
|
||||
'target': 'new',
|
||||
}
|
||||
return res
|
||||
|
||||
@api.depends('project_ids', 'project_ids.rating_active')
|
||||
def _compute_disabled_rating_warning(self):
|
||||
for stage in self:
|
||||
|
||||
@@ -41,6 +41,11 @@ class ProjectTaskTypeDelete(models.TransientModel):
|
||||
'context': self.env.context,
|
||||
}
|
||||
|
||||
def action_unarchive_task(self):
|
||||
inactive_tasks = self.env['project.task'].with_context(active_test=False).search(
|
||||
[('active', '=', False), ('stage_id', 'in', self.stage_ids.ids)])
|
||||
inactive_tasks.action_unarchive()
|
||||
|
||||
def action_confirm(self):
|
||||
tasks = self.with_context(active_test=False).env['project.task'].search([('stage_id', 'in', self.stage_ids.ids)])
|
||||
tasks.write({'active': False})
|
||||
|
||||
@@ -46,4 +46,21 @@
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_project_task_type_unarchive_wizard" model="ir.ui.view">
|
||||
<field name="name">project.task.type.delete.wizard.form</field>
|
||||
<field name="model">project.task.type.delete.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Delete Stage">
|
||||
<div>
|
||||
<p>Would you like to unarchive all of the tasks contained in these stages as well?</p>
|
||||
</div>
|
||||
<footer>
|
||||
<button string="Confirm" type="object" name="action_unarchive_task" class="btn btn-primary"/>
|
||||
<button string="Discard" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user