Merge pull request #5790 from expsa/yokch

[IMP] odex_benefit: Add grace period for benefiting from services aft…
This commit is contained in:
kchyounes19 2025-12-23 08:07:54 +01:00 committed by GitHub
commit e041d1ccfd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 47 additions and 5 deletions

View File

@ -8407,6 +8407,7 @@ msgstr "نهاية الوقت المعين للنشاط"
#: model_terms:ir.ui.view,arch_db:odex_benefit.external_benefit_view_form #: model_terms:ir.ui.view,arch_db:odex_benefit.external_benefit_view_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.family_member_form #: model_terms:ir.ui.view,arch_db:odex_benefit.family_member_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_form #: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_form
#: model:ir.model.fields,field_description:odex_benefit.field_property_type_settings__name
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_benefit_category_form #: model_terms:ir.ui.view,arch_db:odex_benefit.view_benefit_category_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_benefit_housing_form #: model_terms:ir.ui.view,arch_db:odex_benefit.view_benefit_housing_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.benefit_vehicle_model_form_view #: model_terms:ir.ui.view,arch_db:odex_benefit.benefit_vehicle_model_form_view
@ -17947,4 +17948,16 @@ msgstr "الخدمات غير المتاحة للأسر أو الأفراد ال
#. module: odex_benefit #. module: odex_benefit
#: model_terms:ir.actions.act_window,help:odex_benefit.action_property_type_settings #: model_terms:ir.actions.act_window,help:odex_benefit.action_property_type_settings
msgid "Create the Property Type" msgid "Create the Property Type"
msgstr "إنشاء نوع العقار" msgstr "إنشاء نوع العقار"
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_relation_settings__grace_period_days
msgid "Grace Period After Age Limit (Days)"
msgstr "فترة السماح للاستفادة من الخدمات بعد وصول العمر"
#. module: odex_benefit
#: model:ir.model.fields,help:odex_benefit.field_relation_settings__grace_period_days
msgid ""
"Number of days the member remains eligible for benefits after reaching the "
"configured age limit."
msgstr "عدد الأيام التي يظل فيها الفرد مؤهلاً للاستفادة من الخدمات بعد بلوغه الحد العمري المحدد."

View File

@ -783,6 +783,11 @@ class RelationSettings(models.Model):
relation_type = fields.Selection( relation_type = fields.Selection(
[('son', _('Son')), ('daughter', _('Daughter')),('mother', _('Mother')),('replacement_mother', _('Replacement Mother')),('other relation', _('Other Relation'))]) [('son', _('Son')), ('daughter', _('Daughter')),('mother', _('Mother')),('replacement_mother', _('Replacement Mother')),('other relation', _('Other Relation'))])
age_difference = fields.Integer() age_difference = fields.Integer()
grace_period_days = fields.Integer(
string="Grace Period After Age Limit (Days)",
default=0,
help="Number of days the member remains eligible for benefits after reaching the configured age limit."
)
class LocationSettings(models.Model): class LocationSettings(models.Model):
_name = 'location.settings' _name = 'location.settings'

View File

@ -539,10 +539,28 @@ class FamilyMemberProfile(models.Model):
exceptional_age_has_disabilities = validation_setting.exceptional_age_has_disabilities exceptional_age_has_disabilities = validation_setting.exceptional_age_has_disabilities
minor_siblings_age = validation_setting.minor_siblings_age minor_siblings_age = validation_setting.minor_siblings_age
max_income_for_benefit = validation_setting.max_income_for_benefit max_income_for_benefit = validation_setting.max_income_for_benefit
grace_days = rec.relationn.grace_period_days or 0
if rec.relationn.relation_type == 'daughter':
limit_age = female_benefit_age
elif rec.relationn.relation_type == 'son':
limit_age = male_benefit_age
else:
limit_age = 0
if limit_age > 0:
start_of_next_year = rec.birth_date + rd(years=limit_age + 1)
end_benefit_date = start_of_next_year + rd(days=grace_days)
age_exceeded = date.today() > end_benefit_date
else:
age_exceeded = False
rec.member_status = 'benefit' # Default to benefit rec.member_status = 'benefit' # Default to benefit
benefiting_children = rec.benefit_id.member_ids.filtered( benefiting_children = rec.benefit_id.member_ids.filtered(
lambda m: m.relationn.relation_type in ['son', 'daughter'] and m.member_status == 'benefit' lambda m: m.relationn.relation_type in ['son', 'daughter'] and m.member_status == 'benefit'
) )
if rec.relationn.relation_type == 'mother': if rec.relationn.relation_type == 'mother':
if not benefiting_children: if not benefiting_children:
rec.write({'member_status': 'non_benefit'}) rec.write({'member_status': 'non_benefit'})
@ -550,6 +568,7 @@ class FamilyMemberProfile(models.Model):
else: else:
rec.member_status, mother_reasons = rec.benefit_id.check_mother_status() rec.member_status, mother_reasons = rec.benefit_id.check_mother_status()
reasons.append(mother_reasons) reasons.append(mother_reasons)
elif rec.relationn.relation_type == 'replacement_mother': elif rec.relationn.relation_type == 'replacement_mother':
rec.member_status, repl_reasons = rec.benefit_id.check_replacement_mother_status() rec.member_status, repl_reasons = rec.benefit_id.check_replacement_mother_status()
reasons.append(repl_reasons) reasons.append(repl_reasons)
@ -558,9 +577,10 @@ class FamilyMemberProfile(models.Model):
reasons.append( reasons.append(
_("The application has been rejected due to missing required documents, lack of official proofs, or the family's ineligibility for the association's services.")) _("The application has been rejected due to missing required documents, lack of official proofs, or the family's ineligibility for the association's services."))
# continue # Skip further checks for mothers # continue # Skip further checks for mothers
# Gender-specific checks # Gender-specific checks
elif rec.relationn.relation_type == 'son': elif rec.relationn.relation_type == 'son':
if rec.age > male_benefit_age: if age_exceeded:
if rec.age <= exceptional_age_has_disabilities and rec.disabilities_attachment_ids and rec.minor_siblings: if rec.age <= exceptional_age_has_disabilities and rec.disabilities_attachment_ids and rec.minor_siblings:
rec.member_status = 'benefit' rec.member_status = 'benefit'
else: else:
@ -606,6 +626,7 @@ class FamilyMemberProfile(models.Model):
rec.member_status = 'non_benefit' rec.member_status = 'non_benefit'
reasons.append( reasons.append(
_("Failure to complete the required documents or official proofs, or the familys ineligibility for the associations services, and the application has been rejected.")) _("Failure to complete the required documents or official proofs, or the familys ineligibility for the associations services, and the application has been rejected."))
elif rec.relationn.relation_type == 'daughter': elif rec.relationn.relation_type == 'daughter':
if rec.age < female_benefit_age and rec.is_married: if rec.age < female_benefit_age and rec.is_married:
rec.member_status = 'non_benefit' rec.member_status = 'non_benefit'
@ -614,7 +635,7 @@ class FamilyMemberProfile(models.Model):
'educated'] and current_education_status_id.case_study != 'continuous': 'educated'] and current_education_status_id.case_study != 'continuous':
rec.member_status = 'non_benefit' rec.member_status = 'non_benefit'
reasons.append(_("She is employed and not enrolled in an educational institution.")) reasons.append(_("She is employed and not enrolled in an educational institution."))
if rec.age > female_benefit_age: if age_exceeded:
if rec.age > minor_siblings_age and not rec.minor_siblings: if rec.age > minor_siblings_age and not rec.minor_siblings:
rec.member_status = 'non_benefit' rec.member_status = 'non_benefit'
reasons.append( reasons.append(

View File

@ -1022,8 +1022,11 @@
<group> <group>
<field name="name"/> <field name="name"/>
<field name="relation_type"/> <field name="relation_type"/>
</group>
<group>
<field name="age_difference" <field name="age_difference"
attrs="{'invisible': [('relation_type', 'not in', ['son', 'daughter'])]}"/> attrs="{'invisible': [('relation_type', 'not in', ['son', 'daughter'])]}"/>
<field name="grace_period_days"/>
</group> </group>
</group> </group>
</sheet> </sheet>

View File

@ -435,9 +435,9 @@
<group> <group>
<field name="is_driver_family_member" widget="boolean_toggle"/> <field name="is_driver_family_member" widget="boolean_toggle"/>
<field name="driver_name" <field name="driver_name"
attrs="{'invisible': [('is_driver_family_member', '=', True)], 'required': [('is_driver_family_member', '=', False)]}"/> attrs="{'invisible': [('is_driver_family_member', '=', True)], 'required': [('service_type', '=', 'buy_car'),('is_driver_family_member', '=', False)]}"/>
<field name="car_owner_id" <field name="car_owner_id"
attrs="{'invisible': [('is_driver_family_member', '=', False)], 'required': [('is_driver_family_member', '=', True)]}"/> attrs="{'invisible': [('is_driver_family_member', '=', False)], 'required': [('service_type', '=', 'buy_car'),('is_driver_family_member', '=', True)]}"/>
<field name="car_name"/> <field name="car_name"/>
<field name="car_model_id"/> <field name="car_model_id"/>
</group> </group>