From 4d20d315e9db287977fb42048cef57edeb860348 Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Mon, 7 Mar 2022 08:04:08 +0100 Subject: [PATCH] [IMP] project: get action for profitability sections This commit adds a generic method for all sections in the project profitability to get the correct action based on the which section the user clicks. Moreover, a new parameter is added into `_get_profitability_items` method to add the action data in the profitability items or not. This parameter will be useful for the unit tests. task-2710808 --- addons/project/models/project.py | 5 ++++- addons/project/tests/test_project_profitability.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/project/models/project.py b/addons/project/models/project.py index fa4c4eed10c..00b08ae37bf 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -712,6 +712,9 @@ class Project(models.Model): # PROJECT UPDATES # --------------------------------------------- + def action_profitability_items(self, section_name, domain=None, res_id=False): + return {} + def get_last_update_or_default(self): self.ensure_one() labels = dict(self._fields['last_update_status']._description_selection(self.env)) @@ -746,7 +749,7 @@ class Project(models.Model): def _get_profitability_aal_domain(self): return [('account_id', 'in', self.analytic_account_id.ids)] - def _get_profitability_items(self): + def _get_profitability_items(self, with_action=True): return { 'revenues': {'data': [], 'total': {'invoiced': 0.0, 'to_invoice': 0.0}}, 'costs': {'data': [], 'total': {'billed': 0.0, 'to_bill': 0.0}}, diff --git a/addons/project/tests/test_project_profitability.py b/addons/project/tests/test_project_profitability.py index b3d4dcb1959..a42ef01a2e4 100644 --- a/addons/project/tests/test_project_profitability.py +++ b/addons/project/tests/test_project_profitability.py @@ -40,7 +40,7 @@ class TestProfitability(TestProjectProfitabilityCommon): In this module, the project profitability should have no data. So the no revenue and cost should be found. """ - profitability_items = self.project._get_profitability_items() + profitability_items = self.project._get_profitability_items(False) self.assertDictEqual( profitability_items, self.project_profitability_items_empty,