[FIX] hr_timesheet: project stat button on analytic account
Before this commit, when more than 1 projects are linked to a same analytic account, clicking on the stat button from the form view of analytic account, nothing happens. This commit fixes this case by displaying the kanban view of all the project linked to this analytic account. closes odoo/odoo#29131
This commit is contained in:
@@ -31,18 +31,16 @@ class AccountAnalyticAccount(models.Model):
|
||||
|
||||
@api.multi
|
||||
def action_view_projects(self):
|
||||
projects = self.mapped('project_ids')
|
||||
kanban_view_id = self.env.ref('project.view_project_kanban').id
|
||||
result = {
|
||||
"type": "ir.actions.act_window",
|
||||
"res_model": "project.project",
|
||||
"views": [[False, "tree"], [False, "form"]],
|
||||
"domain": [["id", "in", projects.ids]],
|
||||
"views": [[kanban_view_id, "kanban"], [False, "form"]],
|
||||
"domain": [['analytic_account_id', '=', self.id]],
|
||||
"context": {"create": False},
|
||||
"name": "Projects",
|
||||
}
|
||||
if len(projects) == 1:
|
||||
if len(self.project_ids) == 1:
|
||||
result['views'] = [(False, "form")]
|
||||
result['res_id'] = projects.id
|
||||
else:
|
||||
result = {'type': 'ir.actions.act_window_close'}
|
||||
result['res_id'] = self.project_ids.id
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user