[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
This commit is contained in:
Xavier BOL (xbo)
2022-04-01 15:33:00 +02:00
committed by Laurent Stukkens (LTU)
parent b4abfd9ad3
commit 4d20d315e9
2 changed files with 5 additions and 2 deletions
+4 -1
View File
@@ -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}},
@@ -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,