From a7754e77a9a1719e9f019d19c0079732f4b7a12d Mon Sep 17 00:00:00 2001 From: Kevin Baptiste Date: Mon, 20 Dec 2021 10:01:03 +0000 Subject: [PATCH] [FIX] fleet: fleet cost report Steps to reproduce: - Install Fleet - Go on report-cost - Click on a specifi vehicles -> The cost associated are not correct Solution: Correction of the SQL-query which was not correct (id not unique) closes odoo/odoo#81688 X-original-commit: e06114b3b7e188d8ce293f77d8395592193eb83d Signed-off-by: yosa-odoo Signed-off-by: Kevin Baptiste --- addons/fleet/report/fleet_report.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/addons/fleet/report/fleet_report.py b/addons/fleet/report/fleet_report.py index 312e8fd3752..9ff4e9bef09 100644 --- a/addons/fleet/report/fleet_report.py +++ b/addons/fleet/report/fleet_report.py @@ -111,8 +111,7 @@ contract_costs AS ( ve.id, date_start ) -SELECT - vehicle_id AS id, +SELECT row_number() OVER (ORDER BY vehicle_id ASC) as id, company_id, vehicle_id, name, @@ -121,12 +120,9 @@ SELECT date_start, vehicle_type, COST, - 'service' as cost_type -FROM - service_costs sc -UNION ALL ( + cost_type +FROM ( SELECT - vehicle_id AS id, company_id, vehicle_id, name, @@ -135,9 +131,23 @@ UNION ALL ( date_start, vehicle_type, COST, - 'contract' as cost_type + 'service' as cost_type FROM - contract_costs cc) + service_costs sc + UNION ALL ( + SELECT + company_id, + vehicle_id, + name, + driver_id, + fuel_type, + date_start, + vehicle_type, + COST, + 'contract' as cost_type + FROM + contract_costs cc) +) c """ tools.drop_view_if_exists(self.env.cr, self._table) self.env.cr.execute(