From 3f8519f1a45ca0105beb3c65037e5f5eb11ab76f Mon Sep 17 00:00:00 2001 From: jem-odoo Date: Thu, 29 Nov 2018 09:40:13 +0000 Subject: [PATCH] [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 --- addons/hr_timesheet/models/analytic_account.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/addons/hr_timesheet/models/analytic_account.py b/addons/hr_timesheet/models/analytic_account.py index 8e794bf4255..574e73962d9 100644 --- a/addons/hr_timesheet/models/analytic_account.py +++ b/addons/hr_timesheet/models/analytic_account.py @@ -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