[IMP]odex_benefit: IMP benefit

This commit is contained in:
younes 2026-01-21 11:17:54 +01:00
parent 5b5e077d77
commit 574f3d4576
3 changed files with 19 additions and 16 deletions

View File

@ -1405,8 +1405,10 @@ class GrantBenefitProfile(models.Model):
reasons.append(_("The mother's marital or location conditions are not eligible."))
status = 'non_benefit'
elif rec.mother_marital_conf.is_benefit :
if rec.is_mother_work and rec.mother_country_id.code == 'SA' or (
rec.mother_country_id.code != 'SA' and rec.father_country_id.code == 'SA'):
if rec.mother_country_id.code != 'SA' and rec.father_country_id.code != 'SA' and not rec.mother_country_id.is_excluded and not rec.father_country_id.is_excluded:
reasons.append(_("Non-Saudi mothers and fathers cannot register."))
status = 'non_benefit'
else:
if mini_income_for_mother < rec.mother_net_income <= max_income_for_mother:
reasons.append(_("The mother's income is between minimum and maximum thresholds."))
status = 'non_benefit'
@ -1414,9 +1416,6 @@ class GrantBenefitProfile(models.Model):
status = 'benefit'
elif rec.mother_net_income > max_income_for_mother:
status = 'benefit'
elif not rec.is_mother_work and rec.mother_country_id.code == 'SA' or (
rec.mother_country_id.code != 'SA' and rec.father_country_id.code == 'SA'):
status = 'benefit'
return status, reasons
def check_replacement_mother_status(self):
@ -2190,7 +2189,7 @@ class GrantBenefitProfile(models.Model):
validation_setting = self.env["family.validation.setting"].search([], limit=1)
max_income_for_mother = validation_setting.max_income_for_mother
for rec in self:
add_mother_net_income = (rec.mother_status == 'benefit' and rec.mother_net_income > max_income_for_mother)
add_mother_net_income = (rec.mother_location_conf.is_benefit and rec.mother_marital_conf.is_benefit and rec.mother_net_income > max_income_for_mother)
if add_mother_net_income:
rec.mother_income = rec.mother_net_income
else:

View File

@ -649,10 +649,15 @@ class FamilyMemberProfile(models.Model):
m.relationn.relation_type == 'son' and m.member_status == 'benefit'
for m in rec.benefit_id.member_ids
)
has_younger_benefiting_daughter = any(
m.relationn.relation_type == 'daughter'
and m.member_status == 'benefit'
and m.age < female_benefit_age
and m.birth_date
and (
m.birth_date + rd(years=female_benefit_age) + rd(days=(m.relationn.grace_period_days or 0))
> date.today()
)
for m in rec.benefit_id.member_ids
if m.id != rec.id
)

View File

@ -1,3 +1,5 @@
from Tools.scripts.dutree import store
from odoo import fields, models, api, _
from odoo.exceptions import UserError, ValidationError
from datetime import date, datetime, timedelta
@ -20,9 +22,9 @@ class ServiceRequest(models.Model):
researcher_id = fields.Many2one("committees.line", string="Researcher", related="family_id.researcher_id",
store=True)
family_category = fields.Many2one('benefit.category', string='Family Category',
related='family_id.benefit_category_id', search="_search_benefit_category_id")
related='family_id.benefit_category_id', store=True)
family_code = fields.Char(string='Family Code', related='family_id.code', store=True)
benefit_member_count = fields.Integer(string="Benefit Member count", related='family_id.benefit_member_count')
benefit_member_count = fields.Integer(string="Benefit Member count", related='family_id.benefit_member_count',store=True)
branch_custom_id = fields.Many2one('branch.settings', string="Branch", related='family_id.branch_custom_id',
store=True)
member_id = fields.Many2one('family.member', string='Member')
@ -205,9 +207,6 @@ class ServiceRequest(models.Model):
compute='_compute_related_information_html', store=True, )
researcher_opinion = fields.Html(string='Specialist Opinion', tracking=True)
def _search_benefit_category_id(self, operator, value):
return [('family_id.benefit_category_id', operator, value)]
def action_create_project(self):
pass
@ -1060,7 +1059,7 @@ class ServiceRequest(models.Model):
if service_type == 'rent':
rec.service_max_amount += rec.added_amount_if_mother_dead
rec.requested_service_amount = min(rec.rent_amount_payment,
rec.estimated_rent_amount_payment) + rec.added_amount_if_mother_dead
rec.estimated_rent_amount_payment + rec.added_amount_if_mother_dead)
elif rec.max_limit_period == "calendar_year":
current_date = rec.date.date() if isinstance(rec.date, datetime) else rec.date
allowed_years = rec.service_cat.allowed_period or 1