Skip to content

Commit

Permalink
[FIX] fleet: use services dates in report start date computation
Browse files Browse the repository at this point in the history
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
  • Loading branch information
adwid committed Jul 26, 2021
1 parent c9d3120 commit 8d362af
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions addons/fleet/report/fleet_report.py
Expand Up @@ -42,8 +42,8 @@ def init(self):
fleet_vehicle ve
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
Expand Down

0 comments on commit 8d362af

Please sign in to comment.