From 5c10ffe2844912a5bb21cfadfabe453e5d5816db Mon Sep 17 00:00:00 2001 From: Adrien Widart Date: Mon, 26 Jul 2021 08:17:09 +0000 Subject: [PATCH] [FIX] fleet: use services dates in report start date computation When adding some services to a vehicle that does not have any immatriculation date, the costs report does not consider these services. To reproduce the error: (DB without any demo data) 1. Create a vehicle V - Remove the Immatriculation Date 2. Add a service for V - The category of the service type does not matter - Cost > 0 - Date: today 3. Fleet > Reporting > Costs Error: Costs Analysis is empty, the service is not considered In the SQL view, the date used as start point is the oldest immatriculation date. Therefore, if the vehicle doesn't have this date, the report lines won't be generated. OPW-2477004 X-original-commit: 8d362af654c1905535d78fbf8d73677633b65d63 --- addons/fleet/report/fleet_report.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/fleet/report/fleet_report.py b/addons/fleet/report/fleet_report.py index b3da16fb8a4..fe59895e145 100644 --- a/addons/fleet/report/fleet_report.py +++ b/addons/fleet/report/fleet_report.py @@ -50,8 +50,8 @@ WITH service_costs AS ( fleet_category fl ON fl.id = ve.fleet_id CROSS JOIN generate_series(( SELECT - min(acquisition_date) - FROM fleet_vehicle), CURRENT_DATE, '1 month') d + min(date) + FROM fleet_vehicle_log_services), CURRENT_DATE, '1 month') d LEFT JOIN fleet_vehicle_log_services se ON se.vehicle_id = ve.id AND date_trunc('month', se.date) = date_trunc('month', d) WHERE