From 8f86108493a1f615590e7411d0b753b3efd1e97f Mon Sep 17 00:00:00 2001 From: Juliana <juliana@le-filament.com> Date: Thu, 23 Jun 2022 18:05:19 +0200 Subject: [PATCH] [FIX]Error last month when date is last day of the month --- models/acc_operation.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/models/acc_operation.py b/models/acc_operation.py index 4537242..e8ee8bf 100644 --- a/models/acc_operation.py +++ b/models/acc_operation.py @@ -156,7 +156,11 @@ class AccOperation(models.Model): last_day_start = last_record.date_slot.replace(hour=0, minute=0, second=0) last_day_end = last_day_start + relativedelta(days=1) # Get end time slot for previous month with timezone - end_month = last_day_start.replace(day=1) + # Manage if date is the last day of the month + if fields.Date.to_date(last_day_start) == fields.Date.to_date(date_utils.end_of(last_record.date_slot, "month")): + end_month = last_day_end.replace(day=1) + else: + end_month = last_day_start.replace(day=1) if scale == "semestre": date_end = end_month -- GitLab