[FIX] odex_benefit: Fix bug

This commit is contained in:
younes 2025-10-29 09:18:07 +01:00
parent 3722157ea2
commit 4692094e1d
1 changed files with 4 additions and 4 deletions

View File

@ -645,7 +645,7 @@ class ServiceRequest(models.Model):
else restoration_date + relativedelta(years=interval)
)
if today < next_allowed_restoration_date:
if rec.date < next_allowed_restoration_date:
raise ValidationError(_(
"You cannot request this service together with 'home_restoration' within the same recurrence period."
))
@ -688,7 +688,7 @@ class ServiceRequest(models.Model):
if service_type in special_services:
if service_type == 'home_furnishing':
delta_kwargs = {period: interval}
date_before = today - relativedelta(**delta_kwargs)
date_before = rec.date - relativedelta(**delta_kwargs)
domain = base_domain + [('date', '>', date_before)]
existing_requests = Service.search(domain)
total_amount = sum(existing_requests.mapped('requested_service_amount')) + sum(
@ -705,7 +705,7 @@ class ServiceRequest(models.Model):
rec.service_max_amount = rec.device_id.price_unit if rec.device_id else 0.0
if rec.device_id:
delta_kwargs = {period: interval}
date_before = today - relativedelta(**delta_kwargs)
date_before = rec.date - relativedelta(**delta_kwargs)
domain = base_domain + [
('device_id', '=', rec.device_id.id),
('date', '>', date_before)
@ -738,7 +738,7 @@ class ServiceRequest(models.Model):
if isinstance(next_allowed_date, datetime):
next_allowed_date = next_allowed_date.date()
if today < next_allowed_date:
if rec.date < next_allowed_date:
raise ValidationError(_(
"You can only request this service again after %s."
) % next_allowed_date.strftime('%Y-%m-%d'))