From 5dd5149df10078f7dbf8f68c86c216e0e40f0eee Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Wed, 6 Apr 2022 16:10:35 +0000 Subject: [PATCH] [FIX] sale_timesheet: group by invoice for timesheet billed on time Before this commit, all rows about timesheets in the revenues of project profitability section can be clickable and shown the timesheets related grouped by invoice. However, the invoice is only linked to the timesheets containing a SOL with the invoice type of the product is set to 'delivered' and the service_type of this product is set to 'timesheet'. It means only one timesheet row in the revenues has some timesheets with an invoice linked. This commit only group by invoice the views in the action called when the user clicks on 'Timesheet (Billed on Time)' row name. task-2814466 Part-of: odoo/odoo#88219 --- addons/sale_timesheet/models/project.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/sale_timesheet/models/project.py b/addons/sale_timesheet/models/project.py index a98963c9bea..653dbf38a25 100644 --- a/addons/sale_timesheet/models/project.py +++ b/addons/sale_timesheet/models/project.py @@ -474,8 +474,7 @@ class Project(models.Model): if record_ids: if invoice_type not in ['other_costs', 'other_revenues'] and can_see_timesheets: # action to see the timesheets action = get_timesheets_action(invoice_type, record_ids) - if not cost: - action['context'] = json.dumps({'search_default_groupby_invoice': 1}) + action['context'] = json.dumps({'search_default_groupby_invoice': 1 if not cost and invoice_type == 'billable_time' else 0}) data['action'] = action profitability_data.append(data) return profitability_data @@ -494,7 +493,7 @@ class Project(models.Model): record_ids = aal_revenue.get('record_ids', []) if can_see_timesheets and record_ids: action = get_timesheets_action(revenue_id, record_ids) - action['context'] = json.dumps({'search_default_groupby_invoice': 1}) + action['context'] = json.dumps({'search_default_groupby_invoice': 1 if revenue_id == 'billable_time' else 0}) revenue['action'] = action for cost in profitability_items['costs']['data']: