[IMP] project: hide Archive button on delete wizard

... when all the projects are already archived.

closes odoo/odoo#48728

Taskid: 2228556
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
Kevin Baptiste
2020-05-06 09:16:32 +00:00
parent cd9dfc9da4
commit 430cfa76f5
2 changed files with 8 additions and 3 deletions
@@ -10,6 +10,11 @@ class ProjectDelete(models.TransientModel):
project_ids = fields.Many2many('project.project', string='Projects')
task_count = fields.Integer(compute='_compute_task_count')
projects_archived = fields.Boolean(compute='_compute_projects_archived')
def _compute_projects_archived(self):
for wizard in self.with_context(active_test=False):
wizard.projects_archived = all([not p.active for p in wizard.project_ids])
def _compute_task_count(self):
for wizard in self:
@@ -17,8 +22,7 @@ class ProjectDelete(models.TransientModel):
def action_archive(self):
self.project_ids.write({'active': False})
return self.env.ref('project.open_view_project_all').read()[0]
def confirm_delete(self):
self.with_context(active_test=False).project_ids.unlink()
return self.env.ref('project.open_view_project_all').read()[0]
return self.env.ref('project.open_view_project_all_config').read()[0]
@@ -7,6 +7,7 @@
<field name="arch" type="xml">
<form string="Delete Project">
<field name="task_count" invisible="1" />
<field name="projects_archived" invisible="1" />
<group attrs="{'invisible': [('task_count', '=', 0)]}">
<span>You cannot delete a project containing tasks. You can either archive it or first delete all of its tasks.</span>
</group>
@@ -14,7 +15,7 @@
<span>Are you sure you want to delete this project ?</span>
</group>
<footer attrs="{'invisible': [('task_count', '=', 0)]}">
<button string="Archive project" type="object" name="action_archive" class="btn btn-primary" />
<button string="Archive project" type="object" name="action_archive" class="btn btn-primary" attrs="{'invisible': [('projects_archived', '=', True)]}" />
<button string="Discard" special="cancel" />
</footer>
<footer attrs="{'invisible': [('task_count', '>', 0)]}">