From 574f3d4576ad5f628fc0f644b2918d1b48ecc927 Mon Sep 17 00:00:00 2001 From: younes Date: Wed, 21 Jan 2026 11:17:54 +0100 Subject: [PATCH] [IMP]odex_benefit: IMP benefit --- odex25_benefit/odex_benefit/models/benefit.py | 11 +++++------ .../odex_benefit/models/family_members.py | 7 ++++++- .../odex_benefit/models/service_request.py | 17 ++++++++--------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/odex25_benefit/odex_benefit/models/benefit.py b/odex25_benefit/odex_benefit/models/benefit.py index e0e4ab0d5..e044d4481 100644 --- a/odex25_benefit/odex_benefit/models/benefit.py +++ b/odex25_benefit/odex_benefit/models/benefit.py @@ -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: diff --git a/odex25_benefit/odex_benefit/models/family_members.py b/odex25_benefit/odex_benefit/models/family_members.py index 79ecce19a..99c4ec0dd 100644 --- a/odex25_benefit/odex_benefit/models/family_members.py +++ b/odex25_benefit/odex_benefit/models/family_members.py @@ -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 ) diff --git a/odex25_benefit/odex_benefit/models/service_request.py b/odex25_benefit/odex_benefit/models/service_request.py index 4831b7a8a..95c1bd826 100644 --- a/odex25_benefit/odex_benefit/models/service_request.py +++ b/odex25_benefit/odex_benefit/models/service_request.py @@ -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') @@ -79,7 +81,7 @@ class ServiceRequest(models.Model): start = fields.Date(string="Start Date") end = fields.Date(string='End Date') 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( 'service.attachments.settings', 'service_request_id', @@ -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 @@ -1359,7 +1358,7 @@ class ServiceRequest(models.Model): else: 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): for rec in self: added_amount_if_mother_dead = 0.0 @@ -1367,4 +1366,4 @@ class ServiceRequest(models.Model): added_amount_if_mother_dead = rec.service_cat.raise_amount_for_orphan if rec.service_cat.raise_amount_for_orphan and rec.payment_type: added_amount_if_mother_dead = rec.service_cat.raise_amount_for_orphan / int(rec.payment_type) - rec.added_amount_if_mother_dead = added_amount_if_mother_dead \ No newline at end of file + rec.added_amount_if_mother_dead = added_amount_if_mother_dead