Merge pull request #6287 from expsa/fg

[IMP]odex_benefit: IMP benefit
This commit is contained in:
kchyounes19 2026-01-21 11:19:25 +01:00 committed by GitHub
commit 9415a3d503
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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.")) reasons.append(_("The mother's marital or location conditions are not eligible."))
status = 'non_benefit' status = 'non_benefit'
elif rec.mother_marital_conf.is_benefit : elif rec.mother_marital_conf.is_benefit :
if rec.is_mother_work and rec.mother_country_id.code == 'SA' or ( 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:
rec.mother_country_id.code != 'SA' and rec.father_country_id.code == 'SA'): 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: 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.")) reasons.append(_("The mother's income is between minimum and maximum thresholds."))
status = 'non_benefit' status = 'non_benefit'
@ -1414,9 +1416,6 @@ class GrantBenefitProfile(models.Model):
status = 'benefit' status = 'benefit'
elif rec.mother_net_income > max_income_for_mother: elif rec.mother_net_income > max_income_for_mother:
status = 'benefit' 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 return status, reasons
def check_replacement_mother_status(self): def check_replacement_mother_status(self):
@ -2190,7 +2189,7 @@ class GrantBenefitProfile(models.Model):
validation_setting = self.env["family.validation.setting"].search([], limit=1) validation_setting = self.env["family.validation.setting"].search([], limit=1)
max_income_for_mother = validation_setting.max_income_for_mother max_income_for_mother = validation_setting.max_income_for_mother
for rec in self: 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: if add_mother_net_income:
rec.mother_income = rec.mother_net_income rec.mother_income = rec.mother_net_income
else: else:

View File

@ -649,10 +649,15 @@ class FamilyMemberProfile(models.Model):
m.relationn.relation_type == 'son' and m.member_status == 'benefit' m.relationn.relation_type == 'son' and m.member_status == 'benefit'
for m in rec.benefit_id.member_ids for m in rec.benefit_id.member_ids
) )
has_younger_benefiting_daughter = any( has_younger_benefiting_daughter = any(
m.relationn.relation_type == 'daughter' m.relationn.relation_type == 'daughter'
and m.member_status == 'benefit' 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 for m in rec.benefit_id.member_ids
if m.id != rec.id 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 import fields, models, api, _
from odoo.exceptions import UserError, ValidationError from odoo.exceptions import UserError, ValidationError
from datetime import date, datetime, timedelta 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", researcher_id = fields.Many2one("committees.line", string="Researcher", related="family_id.researcher_id",
store=True) store=True)
family_category = fields.Many2one('benefit.category', string='Family Category', 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) 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', branch_custom_id = fields.Many2one('branch.settings', string="Branch", related='family_id.branch_custom_id',
store=True) store=True)
member_id = fields.Many2one('family.member', string='Member') member_id = fields.Many2one('family.member', string='Member')
@ -79,7 +81,7 @@ class ServiceRequest(models.Model):
start = fields.Date(string="Start Date") start = fields.Date(string="Start Date")
end = fields.Date(string='End Date') end = fields.Date(string='End Date')
added_amount_if_mother_dead = fields.Float(string="Added Amount (If mother dead)", added_amount_if_mother_dead = fields.Float(string="Added Amount (If mother dead)",
compute="_get_added_amount_if_mother_dead",store=True) compute="_get_added_amount_if_mother_dead", store=True)
attachment_lines = fields.One2many( attachment_lines = fields.One2many(
'service.attachments.settings', 'service.attachments.settings',
'service_request_id', 'service_request_id',
@ -205,9 +207,6 @@ class ServiceRequest(models.Model):
compute='_compute_related_information_html', store=True, ) compute='_compute_related_information_html', store=True, )
researcher_opinion = fields.Html(string='Specialist Opinion', tracking=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): def action_create_project(self):
pass pass
@ -1060,7 +1059,7 @@ class ServiceRequest(models.Model):
if service_type == 'rent': if service_type == 'rent':
rec.service_max_amount += rec.added_amount_if_mother_dead rec.service_max_amount += rec.added_amount_if_mother_dead
rec.requested_service_amount = min(rec.rent_amount_payment, 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": elif rec.max_limit_period == "calendar_year":
current_date = rec.date.date() if isinstance(rec.date, datetime) else rec.date current_date = rec.date.date() if isinstance(rec.date, datetime) else rec.date
allowed_years = rec.service_cat.allowed_period or 1 allowed_years = rec.service_cat.allowed_period or 1
@ -1359,7 +1358,7 @@ class ServiceRequest(models.Model):
else: else:
rec.rent_amount_payment = 0.0 rec.rent_amount_payment = 0.0
@api.depends('family_id','service_cat','payment_type') @api.depends('family_id', 'service_cat', 'payment_type')
def _get_added_amount_if_mother_dead(self): def _get_added_amount_if_mother_dead(self):
for rec in self: for rec in self:
added_amount_if_mother_dead = 0.0 added_amount_if_mother_dead = 0.0