From 2e18fbd9989caf537f255b91a713b2fefdaa047e Mon Sep 17 00:00:00 2001 From: younes Date: Mon, 5 Jan 2026 13:49:26 +0100 Subject: [PATCH] [IMP] odex_benefit: IMP benefit --- odex25_benefit/odex_benefit/models/benefit.py | 26 ++++++++------- .../odex_benefit/models/benefit_config.py | 13 ++++++++ .../odex_benefit/models/family_members.py | 2 +- .../models/ir_attachment_inherit.py | 15 +++++---- .../odex_benefit/views/actions_and_menus.xml | 1 + .../views/benefit_config_view.xml | 17 ++++++++++ .../odex_benefit/views/benefit_view.xml | 33 +++++++++++++------ .../odex_benefit/views/family_members.xml | 8 +++-- .../odex_benefit/views/services_settings.xml | 2 +- 9 files changed, 86 insertions(+), 31 deletions(-) diff --git a/odex25_benefit/odex_benefit/models/benefit.py b/odex25_benefit/odex_benefit/models/benefit.py index 30a917c8b..511499cd9 100644 --- a/odex25_benefit/odex_benefit/models/benefit.py +++ b/odex25_benefit/odex_benefit/models/benefit.py @@ -684,6 +684,21 @@ class GrantBenefitProfile(models.Model): family.current_rent_contract_id = active_contracts[:1] or False + @api.depends('member_ids', 'member_ids.member_status', 'add_replacement_mother', + 'replacement_mother_family_member_id', 'replacement_mother_status', 'mother_family_member_id', + 'mother_status') + def get_members_count(self): + for ben in self: + if ben.id: + ben.benefit_member_count = len(ben.member_ids.filtered(lambda x: x.member_status == 'benefit')) + if ben.add_replacement_mother and not ben.replacement_mother_family_member_id and ben.replacement_mother_status == 'benefit': + ben.benefit_member_count += 1 + + if not ben.mother_family_member_id and ben.mother_status == 'benefit': + ben.benefit_member_count += 1 + else: + ben.benefit_member_count = 0.0 + @api.depends('current_rent_contract_id') def _compute_rent_from_contract(self): for family in self: @@ -2259,17 +2274,6 @@ class GrantBenefitProfile(models.Model): rec.replacement_mother_diseases_attachment_ids.write({'member_id': replacement_member.id}) rec.replacement_mother_disabilities_attachment_ids.write({'member_id': replacement_member.id}) - def get_members_count(self): - for ben in self: - if ben.id: - ben.benefit_member_count = len(ben.member_ids.filtered(lambda x: x.member_status == 'benefit')) - if ben.add_replacement_mother and not ben.replacement_mother_family_member_id and ben.replacement_mother_status == 'benefit': - ben.benefit_member_count += 1 - - if not ben.mother_family_member_id and ben.mother_status == 'benefit': - ben.benefit_member_count += 1 - else: - ben.benefit_member_count = 0.0 def get_non_members_count(self): for ben in self: diff --git a/odex25_benefit/odex_benefit/models/benefit_config.py b/odex25_benefit/odex_benefit/models/benefit_config.py index 43f909071..d9984dad5 100644 --- a/odex25_benefit/odex_benefit/models/benefit_config.py +++ b/odex25_benefit/odex_benefit/models/benefit_config.py @@ -823,6 +823,19 @@ class AttachmentsSettings(models.Model): member_appearance_seq = fields.Integer(string='Appearance Sequence') income_appearance_seq = fields.Integer(string='Appearance Sequence') is_mother_salary = fields.Boolean(string="Is Mother Salary", default=False) + parent_id = fields.Many2one('attachments.settings',string='Parent') + child_ids = fields.One2many('attachments.settings','parent_id',string='Children') + + @api.constrains('parent_id') + def _check_no_recursive_parent(self): + for rec in self: + parent = rec.parent_id + while parent: + if parent == rec: + raise ValidationError( + "Recursive hierarchy is not allowed." + ) + parent = parent.parent_id class EducationIlliterateReason(models.Model): _name = 'education.illiterate.reason' diff --git a/odex25_benefit/odex_benefit/models/family_members.py b/odex25_benefit/odex_benefit/models/family_members.py index 3bc65e967..bd8eee3c5 100644 --- a/odex25_benefit/odex_benefit/models/family_members.py +++ b/odex25_benefit/odex_benefit/models/family_members.py @@ -605,7 +605,7 @@ class FamilyMemberProfile(models.Model): _("Over %s years old and not enrolled in any educational institution.") % male_benefit_age ) elif current_education_status_id.case_study == 'continuous': - if current_education_status_id.specialization_ids.is_scientific_specialty and rec.age > exceptional_age_scientific_specialty: + if current_education_status_id.specialization_ids.is_scientific_specialty and rec.age >= exceptional_age_scientific_specialty: rec.member_status = 'non_benefit' reasons.append( _("Over %s years old and not enrolled in a scientific or vocational specialization.") diff --git a/odex25_benefit/odex_benefit/models/ir_attachment_inherit.py b/odex25_benefit/odex_benefit/models/ir_attachment_inherit.py index 154b1b5e6..ed443109c 100644 --- a/odex25_benefit/odex_benefit/models/ir_attachment_inherit.py +++ b/odex25_benefit/odex_benefit/models/ir_attachment_inherit.py @@ -17,8 +17,10 @@ class BenefitAttachment(models.Model): allow_days = fields.Integer(compute='get_allow_days',string='Allow Days') attach_id = fields.Many2one('attachments.settings', string="Attach",domain=[('attach_type', '=', 'member_attach')]) hobbies_id = fields.Many2one('attachments.settings', string="Hobby",domain=[('attach_type', '=', 'hobbies_attach')]) - diseases_id = fields.Many2one('attachments.settings', string="Diseases",domain=[('attach_type', '=', 'diseases_attach')]) - disabilities_id = fields.Many2one('attachments.settings', string="Disabilities",domain=[('attach_type', '=', 'disabilities_attach')]) + diseases_id = fields.Many2one('attachments.settings', string="Diseases",domain=[('attach_type', '=', 'diseases_attach'), ('parent_id','=',False)]) + diseases_child_id = fields.Many2one('attachments.settings',string="Sub Disease",domain="[('parent_id','=',diseases_id)]") + disabilities_id = fields.Many2one('attachments.settings', string="Disabilities",domain=[('attach_type', '=', 'disabilities_attach'), ('parent_id','=',False)]) + disabilities_child_id = fields.Many2one('attachments.settings',string="Sub Disability",domain="[('parent_id','=',disabilities_id)]") hobby_attach = fields.Binary(attachment=True, string="Hobby Attach") # fields to management required and delete records in benefit attachment is_required = fields.Boolean(string='Is Required?') @@ -27,6 +29,7 @@ class BenefitAttachment(models.Model): replacement_mother_grant_benefit_id = fields.Many2one('grant.benefit', string='Replacement Mother Grant Benefit') show_in_portal = fields.Boolean(default=False, string="Show In Portal") supporter_id = fields.Many2one(comodel_name='res.partner',string='Supporter',domain=[('is_supporter', '=', True)],) + support_amount = fields.Float(string='Support Amount') def action_preview_attachment(self): # Custom function to open the preview @@ -68,12 +71,12 @@ class BenefitAttachment(models.Model): @api.onchange('diseases_id') def onchange_diseases_id(self): for rec in self: - if rec.diseases_id: - rec.name = rec.diseases_id.name + if not rec.diseases_id: + rec.diseases_child_id = False @api.onchange('disabilities_id') def onchange_disabilities_id(self): for rec in self: - if rec.disabilities_id: - rec.name = rec.disabilities_id.name + if not rec.disabilities_id: + rec.disabilities_child_id = False diff --git a/odex25_benefit/odex_benefit/views/actions_and_menus.xml b/odex25_benefit/odex_benefit/views/actions_and_menus.xml index fafd553be..6d5f36300 100644 --- a/odex25_benefit/odex_benefit/views/actions_and_menus.xml +++ b/odex25_benefit/odex_benefit/views/actions_and_menus.xml @@ -356,6 +356,7 @@ Attachments Settings attachments.settings tree,form + [('parent_id', '=', False)]

Create the Attachment Setting

diff --git a/odex25_benefit/odex_benefit/views/benefit_config_view.xml b/odex25_benefit/odex_benefit/views/benefit_config_view.xml index 0cb974216..1e9069a9d 100644 --- a/odex25_benefit/odex_benefit/views/benefit_config_view.xml +++ b/odex25_benefit/odex_benefit/views/benefit_config_view.xml @@ -1087,6 +1087,7 @@ + @@ -1098,11 +1099,27 @@ + + + + + + + + + + + + + + + +
diff --git a/odex25_benefit/odex_benefit/views/benefit_view.xml b/odex25_benefit/odex_benefit/views/benefit_view.xml index 9d2c03f63..24d2bed51 100644 --- a/odex25_benefit/odex_benefit/views/benefit_view.xml +++ b/odex25_benefit/odex_benefit/views/benefit_view.xml @@ -512,7 +512,8 @@