[UPD] odex_benefit_project: change fields with the new logic

This commit is contained in:
Samir Ladoui 2025-01-02 09:19:22 +01:00
parent c1e49cb77d
commit f2298b864b
1 changed files with 19 additions and 29 deletions

View File

@ -33,7 +33,18 @@ class ServiceRequestInherit(models.Model):
)
rec.project_id = project
@api.onchange('requested_service_amount', 'benefit_type', 'date', 'service_cat','family_id','device_id','exception_or_steal','home_furnishing_exception','rent_period','has_marriage_course','member_id','home_age')
@api.onchange(
'requested_service_amount',
'benefit_type',
'date',
'service_cat',
'family_id',
'exception_or_steal',
'home_furnishing_exception',
'has_marriage_course',
'home_age',
'service_reason_id'
)
def onchange_requested_service_amount(self):
res = {}
today = fields.Date.today()
@ -245,34 +256,13 @@ class ServiceRequestInherit(models.Model):
return res
# Validation for 'family' benefit type with 'transportation_insurance' service type
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'transportation_insurance':
if rec.service_reason == 'government_transportation':
if rec.requested_service_amount > rec.max_government_transportation_amount:
self.benefit_type = False
res['warning'] = {'title': _('ValidationError'),
'message': _(
"You cannot request more than %s") % rec.max_government_transportation_amount}
return res
if rec.service_reason == 'universities_training_institutes_transportation':
if rec.requested_service_amount > rec.max_universities_training_institutes_transportation_amount:
self.benefit_type = False
res['warning'] = {'title': _('ValidationError'),
'message': _(
"You cannot request more than %s") % rec.max_universities_training_institutes_transportation_amount}
return res
if rec.service_reason == 'hospitals_transportation':
if rec.requested_service_amount > rec.max_hospitals_transportation_amount:
self.benefit_type = False
res['warning'] = {'title': _('ValidationError'),
'message': _(
"You cannot request more than %s") % rec.max_hospitals_transportation_amount}
return res
if rec.service_reason == 'programs_transportation':
if rec.requested_service_amount > rec.max_programs_transportation_amount:
self.benefit_type = False
res['warning'] = {'title': _('ValidationError'),
'message': _(
"You cannot request more than %s") % rec.max_hospitals_transportation_amount}
return res
if rec.service_reason_id and rec.requested_service_amount > rec.max_amount:
self.benefit_type = False
res['warning'] = {
'title': _('ValidationError'),
'message': _("You cannot request more than %s") % rec.max_amount
}
return res
# Validation for 'family' benefit type with 'recruiting_driver' service type
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'debits':
if rec.requested_service_amount > rec.service_cat.max_debits_amount: