IMP benefit

This commit is contained in:
younes 2025-09-30 08:29:43 +01:00
parent cab7875c7b
commit e70045fecc
4 changed files with 306 additions and 114 deletions

View File

@ -7830,13 +7830,6 @@ msgstr ""
msgid "Marital Status"
msgstr "الحالة الاجتماعية"
#. module: odex_benefit
#: code:addons/odex_benefit/models/benefit.py:0
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid "Married"
msgstr "متزوجة"
#. module: odex_benefit
#: model:ir.model.fields.selection,name:odex_benefit.selection__associations_line__support_type__material
#: model:ir.model.fields.selection,name:odex_benefit.selection__food_basket_line__donation_type__material
@ -15806,3 +15799,147 @@ msgstr "طريقة الحد الأقصى"
#: model:ir.model.fields,field_description:odex_benefit.field_services_settings__needs_beneficiary_manager_approval
msgid "Needs Beneficiary Manager Approval"
msgstr "هل تحتاج موافقة مدير المستفيدين؟"
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid "Mother has no benefiting children"
msgstr "ليس لديها ايتام قصر"
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid ""
"The application has been rejected due to missing required documents, lack of"
" official proofs, or the family's ineligibility for the association's "
"services."
msgstr "تم رفض الطلب بسبب عدم استكمال المستندات المطلوبة أو الإثباتات الرسمية أو لعدم استحقاق الأسرة لخدمات الجمعية."
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid ""
"He/She has a physical or intellectual disability but is over 30 years of "
"age."
msgstr "لدية اعاقة حسدية او فكرية ولكن تجاوز عمر 30"
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid ""
"He/She is enrolled in a scientific or vocational specialization but is over "
"24 years of age."
msgstr "منتظم في احدي التخصصات العلمية او المهنية ولكن تجاوز عمر 24"
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid ""
"He/She is enrolled in a medical specialization but is over 26 years of age."
msgstr "منتظم في احدي التخصصات الطبية ولكن تجاوز عمر 26"
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid ""
"He/She is over 18 years of age and not enrolled in a scientific or medical "
"specialization."
msgstr "تجاوز عمر 18 وليس منتظم في تخصص علمي او طبي"
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid ""
"She is over 18 years of age and not enrolled in any educational institution."
msgstr "تجاوز عمر 18 وغير منتظمة بجهة تعلمية"
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid "He/She is employed with a salary exceeding 4,000."
msgstr "يعمل براتب اكبر من 4000 "
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid ""
"He/She is over 18 years of age and not enrolled in an educational "
"institution."
msgstr "تجاوز عمر 18 وغير منتظم بجهة تعلمية"
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid "He/She is over 18 years of age and has completed his/her education."
msgstr "تجاوز عمر 18 واكمل تعليمه"
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid "He/She does not reside with his/her family."
msgstr "لايقيم مع اسرته"
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid ""
"Failure to complete the required documents or official proofs, or the "
"familys ineligibility for the associations services, and the application "
"has been rejected."
msgstr "عدم استكمال المستندات المطاوبة او الاثباتات الرسمية او عدم استحقاق الاسرة لخدمات الجمعية وتم رفض الطلب"
#. module: odex_benefit
#: code:addons/odex_benefit/models/benefit.py:0
#: code:addons/odex_benefit/models/benefit.py:0
#: code:addons/odex_benefit/models/family_members.py:0
#: code:addons/odex_benefit/models/family_members.py:0
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid "Married"
msgstr "متزوجة"
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_members.py:0
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid "She is employed and not enrolled in an educational institution."
msgstr "تعمل وغير منتظمة بجهة تعلمية"
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_members.py:0
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid "She is over 26 years of age and has no underage brothers."
msgstr "تجاوزت عمر 26 وليس لديها اخوة قصر"
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid "She is over 35 years of age."
msgstr "تجاوزت عمر 35"
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid "She works with a salary greater than 4,000."
msgstr "تعمل براتب اكبر من 4000 "
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid "She is employed and has completed her education."
msgstr "تعمل واكملت تعليمها"
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid "She does not reside with the family."
msgstr "لاتقييم مع الاسرة"
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid ""
"Application rejected due to missing documents, missing official proofs, or "
"the family's ineligibility for the association's services."
msgstr "عدم استكمال المستندات المطاوبة او الاثباتات الرسمية او عدم استحقاق الاسرة لخدمات الجمعية وتم رفض الطلب"

View File

@ -8,6 +8,7 @@ from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
import qrcode
import base64
from io import BytesIO
SAUDI_MOBILE_PATTERN = "(^(05|5)(5|0|3|6|4|9|1|8|7)([0-9]{7})$)"
ALPHABETIC_PATTERN = "^[\u0600-\u065F\u066A-\u06EF\u06FA-\u06FFA-Za-z ]+$"
import re
@ -26,73 +27,92 @@ class FamilyMemberProfile(models.Model):
return self._context.get('active_id')
member_first_name = fields.Char(string="Member First Name")
member_second_name = fields.Char(string="Member Second Name",related="benefit_id.father_name")
member_third_name = fields.Char(string="Member Third Name",related="benefit_id.father_second_name")
member_family_name = fields.Char(string="Member Family Name",related="benefit_id.father_family_name")
member_second_name = fields.Char(string="Member Second Name", related="benefit_id.father_name")
member_third_name = fields.Char(string="Member Third Name", related="benefit_id.father_second_name")
member_family_name = fields.Char(string="Member Family Name", related="benefit_id.father_family_name")
mother_first_name = fields.Char(string="Mother First Name")
mother_second_name = fields.Char(string="Mother Second Name")
mother_third_name = fields.Char(string="Mother Third Name")
mother_family_name = fields.Char(string="MotherFamily Name")
name = fields.Char(string="Name", compute='get_partner_name', store=True,readonly = False)
name = fields.Char(string="Name", compute='get_partner_name', store=True, readonly=False)
member_id_number = fields.Char(string="Member Id Number")
benefit_id = fields.Many2one("grant.benefit",string="Responsable",default=_default_benefit)
benefit_id = fields.Many2one("grant.benefit", string="Responsable", default=_default_benefit)
gender = fields.Selection(selection=[('male', 'Male'), ('female', 'Female')], string="Gender")
member_phone = fields.Char(string="Member Phone")
member_location = fields.Selection(selection=[('with_family', 'With Family'), ('with_relative', 'with a relative'),
('study_inside_saudi_arabia', 'Study Inside Saudi Arabia'),('study_outside_saudi_arabia', 'Study Outside Saudi Arabia'),
('rehabilitation_center_for_the_disabled', 'Rehabilitation center for the disabled'),('house_of_social_observations', 'House of Social Observations'),
('girls_home','Girls Home'),('university_housing','University Housing'),('with_husband','With_husband'),('work_inside_saudi_arabia','Work Inside Saudi Arabia')], string="Member Location")
member_location_conf = fields.Many2one('location.settings',string='Member Location')
('study_inside_saudi_arabia', 'Study Inside Saudi Arabia'),
('study_outside_saudi_arabia', 'Study Outside Saudi Arabia'),
('rehabilitation_center_for_the_disabled',
'Rehabilitation center for the disabled'),
('house_of_social_observations', 'House of Social Observations'),
('girls_home', 'Girls Home'),
('university_housing', 'University Housing'),
('with_husband', 'With_husband'),
('work_inside_saudi_arabia', 'Work Inside Saudi Arabia')],
string="Member Location")
member_location_conf = fields.Many2one('location.settings', string='Member Location')
# member_location = fields.Many2one('member.location', string="Member Location")
birth_date = fields.Date(string="Birth Date")
age = fields.Integer(string="Age", compute='_compute_get_age_date',store=True)
age = fields.Integer(string="Age", compute='_compute_get_age_date', store=True)
age_status = fields.Selection(
[('minor', 'Minor'), ('non_minor', 'Non-Minor')],
string='Age Status',
default='non_minor', compute='_compute_get_age_status',store=True
default='non_minor', compute='_compute_get_age_status', store=True
)
is_work = fields.Boolean('Is Work?')
salary_certificate = fields.Many2many('ir.attachment','member_salary_cert_rel','member_id','attachment_id',string="Salary Certificate")
salary_certificate = fields.Many2many('ir.attachment', 'member_salary_cert_rel', 'member_id', 'attachment_id',
string="Salary Certificate")
is_dead = fields.Boolean('Is Dead?')
death_certificate = fields.Many2many('ir.attachment','member_death_cert_rel','member_id','attachment_id',string="Death Certificate")
death_certificate = fields.Many2many('ir.attachment', 'member_death_cert_rel', 'member_id', 'attachment_id',
string="Death Certificate")
member_income = fields.Float('Member Income')
is_married = fields.Boolean('Is Married?')
marriage_certificate = fields.Many2many('ir.attachment','member_marriage_cert_rel','member_id','attachment_id',string="Marriage Certificate")
relationn = fields.Many2one('relation.settings',domain="['|',('relation_type','=','son'),('relation_type','=','daughter')]",string="Relation")
marriage_certificate = fields.Many2many('ir.attachment', 'member_marriage_cert_rel', 'member_id', 'attachment_id',
string="Marriage Certificate")
relationn = fields.Many2one('relation.settings',
domain="['|',('relation_type','=','son'),('relation_type','=','daughter')]",
string="Relation")
relationn_type = fields.Selection(related="relationn.relation_type")
relation = fields.Selection(
[('son', _('Son')), ('daughter', _('Daughter'))])
mother_marital = fields.Selection(
[('married', _('Married')), ('widower', _('Widower')), ('divorced', _('Divorced')),
('divorced_from_another_man', _('Divorced From Another Man')), ('prisoner', _('Prisoner')), ('dead', _('Dead')), ('hanging', _('Hanging'))],
('divorced_from_another_man', _('Divorced From Another Man')), ('prisoner', _('Prisoner')),
('dead', _('Dead')), ('hanging', _('Hanging'))],
_('Marital Status'))
mother_marital_conf = fields.Many2one('marital.status',string='Mother Marital')
mother_marital_conf = fields.Many2one('marital.status', string='Mother Marital')
mother_location = fields.Selection(
[('with_husband_and_children', _('With Husband And Children')), ('with_children', _('With Children')),
('not_live_with_children', _('Not live with children'))], string='Mother Location')
attachment_ids = fields.One2many("ir.attachment",'member_id',domain=[('hobbies_id', '=', False),('diseases_id', '=', False),('disabilities_id', '=', False)])
hobbies_attachment_ids = fields.One2many('ir.attachment', 'member_id', string='Hobbies Attachments',domain=[('hobbies_id', '!=', False)])
diseases_attachment_ids = fields.One2many('ir.attachment', 'member_id', string='Diseases Attachments',domain=[('diseases_id', '!=', False)])
disabilities_attachment_ids = fields.One2many('ir.attachment','member_id', string='Disabilities Attachments',domain=[('disabilities_id', '!=', False)])
hobbies_ids = fields.One2many("member.hobbies",'member_id')
diseases_ids = fields.One2many("member.diseases",'member_id')
disabilities_ids = fields.One2many("member.disabilities",'member_id')
is_scientific_specialty = fields.Boolean('Is Scientific Specialty?',related="specialization_ids.is_scientific_specialty")
is_medical_specialty = fields.Boolean('Is Medical Specialty?',related="specialization_ids.is_medical_specialty")
minor_siblings = fields.Boolean('minor siblings?',compute="_compute_minor_siblings",store=True)
attachment_ids = fields.One2many("ir.attachment", 'member_id',
domain=[('hobbies_id', '=', False), ('diseases_id', '=', False),
('disabilities_id', '=', False)])
hobbies_attachment_ids = fields.One2many('ir.attachment', 'member_id', string='Hobbies Attachments',
domain=[('hobbies_id', '!=', False)])
diseases_attachment_ids = fields.One2many('ir.attachment', 'member_id', string='Diseases Attachments',
domain=[('diseases_id', '!=', False)])
disabilities_attachment_ids = fields.One2many('ir.attachment', 'member_id', string='Disabilities Attachments',
domain=[('disabilities_id', '!=', False)])
hobbies_ids = fields.One2many("member.hobbies", 'member_id')
diseases_ids = fields.One2many("member.diseases", 'member_id')
disabilities_ids = fields.One2many("member.disabilities", 'member_id')
is_scientific_specialty = fields.Boolean('Is Scientific Specialty?',
related="specialization_ids.is_scientific_specialty")
is_medical_specialty = fields.Boolean('Is Medical Specialty?', related="specialization_ids.is_medical_specialty")
minor_siblings = fields.Boolean('minor siblings?', compute="_compute_minor_siblings", store=True)
# Education_data
member_education_status_ids = fields.One2many('education.status', 'family_member_id')
education_status = fields.Selection(
string='Education Status',
selection=[('educated', 'educated'), ('illiterate', 'illiterate'),('under_study_age', 'Under Study Age')],
selection=[('educated', 'educated'), ('illiterate', 'illiterate'), ('under_study_age', 'Under Study Age')],
default='under_study_age',
)
case_study = fields.Selection(string='Case Study',
selection=[('continuous', 'continuous'), ('intermittent', 'intermittent'),
('graduate', 'Graduate')])
illiterate_reason = fields.Char(string='Illiterate Reason')
intermittent_reason = fields.Many2one('education.illiterate.reason',string='Intermittent Reason')
educational_certificate = fields.Binary(attachment=True,string='Educational Certificate')
intermittent_reason = fields.Many2one('education.illiterate.reason', string='Intermittent Reason')
educational_certificate = fields.Binary(attachment=True, string='Educational Certificate')
education_entity = fields.Selection(string='Education Entity', selection=[('governmental', 'Governmental'),
('special', 'Special')])
last_education_entity = fields.Selection(string='Last Education Entity',
@ -106,7 +126,7 @@ class FamilyMemberProfile(models.Model):
literacy_school_note = fields.Text(string="Literacy School Note", required=False)
classroom = fields.Many2one('education.classroom', string='Classroom')
last_classroom = fields.Many2one('education.classroom', string='Last Classroom')
last_educational_certificate = fields.Binary(attachment=True,string='Last Educational Certificate')
last_educational_certificate = fields.Binary(attachment=True, string='Last Educational Certificate')
degree = fields.Many2one('education.result', string='Degree')
last_degree = fields.Many2one('education.result', string='Last Degree')
percentage = fields.Float(string="Percentage%")
@ -194,7 +214,7 @@ class FamilyMemberProfile(models.Model):
('suspended_second_approve', 'Suspended Second Approved'),
('exception_second_approve', 'Waiting for General Manager'),
('black_list', 'Black List'),
], string='state', tracking=True,compute='_get_state',store = True, group_expand='_expand_states')
], string='state', tracking=True, compute='_get_state', store=True, group_expand='_expand_states')
state_a = fields.Selection([
('draft', 'Draft'),
('new', 'Researcher Assignment'),
@ -218,20 +238,22 @@ class FamilyMemberProfile(models.Model):
member_status = fields.Selection(selection=[
('benefit', 'Benefit'),
('non_benefit', 'Non Benefit'),
], string='Benefit Status', compute="check_member_status",default = False,store=True)
], string='Benefit Status', compute="check_member_status", default=False, store=True)
suspend_reason = fields.Many2one('suspend.reason', string='Suspend Reason')
reason = fields.Text(string='Reason')
suspend_description = fields.Text(string='Suspend Description')
suspend_attachment = fields.Binary(string='Suspend Attachment', attachment=True)
suspend_type = fields.Selection(
selection=[('temporarily_suspend', 'Temporarily Suspended'), ('suspend', 'Suspend')], string="Suspend Type")
suspend_method = fields.Selection(selection=[('manual', 'Manual'), ('auto', 'Auto')], string="Suspend Method",default='auto')
suspend_method = fields.Selection(selection=[('manual', 'Manual'), ('auto', 'Auto')], string="Suspend Method",
default='auto')
is_member_workflow = fields.Boolean('Is Member Workflow?')
# sponsor_id = fields.Many2one('res.partner', string='Sponsor Partner',domain="[('account_type','=','sponsor')]")
sponsor_id = fields.Many2one('res.partner', string='Sponsor Partner',domain="[('is_sponsor_portal', '=', True)]")
sponsor_id = fields.Many2one('res.partner', string='Sponsor Partner', domain="[('is_sponsor_portal', '=', True)]")
sponsor_related_id = fields.Many2one('takaful.sponsor', string='Sponsor')
sponsorship_id = fields.Many2one('takaful.sponsorship', string='Sponsorship')
required_attach = fields.Selection(selection=[('true', 'True'), ('false', 'False')], compute='get_required_attach',store=True,string='Member Required Attach')
required_attach = fields.Selection(selection=[('true', 'True'), ('false', 'False')], compute='get_required_attach',
store=True, string='Member Required Attach')
# Exception fields
exception_reason = fields.Many2one('exception.reason', string='Exception Reason')
exception_description = fields.Text(string='Exception Description')
@ -246,7 +268,6 @@ class FamilyMemberProfile(models.Model):
total_member_service_requests = fields.Integer(compute='_get_total_member_service_requests')
non_benefit_reason = fields.Text(string="Non Benefit Reason", tracking=True)
# def create(self, vals):
# for line_vals in vals:
# if line_vals.get("education_status", False) == "educated" and "member_education_status_ids" not in line_vals:
@ -254,7 +275,7 @@ class FamilyMemberProfile(models.Model):
# _("You should at least insert one current/previous education status!")
# )
# return super(FamilyMemberProfile, self).create(vals)
# def write(self, vals):
# education_status = vals.get("education_status", False) or self.education_status
# if education_status == "educated" and "member_education_status_ids" not in vals and not len(self.member_education_status_ids):
@ -279,8 +300,7 @@ class FamilyMemberProfile(models.Model):
_("The son/daughter's age is supposed to be less than the mother's age by %s") % rec.relationn.age_difference
)
@api.depends('age_status', 'is_dead','benefit_id.member_ids.age_status','benefit_id.member_ids.is_dead')
@api.depends('age_status', 'is_dead', 'benefit_id.member_ids.age_status', 'benefit_id.member_ids.is_dead')
def _compute_minor_siblings(self):
for member in self:
member.minor_siblings = any(
@ -330,6 +350,7 @@ class FamilyMemberProfile(models.Model):
_("%s must contain only alphabetic characters and spaces. "
"Numbers and special characters are not allowed.") % field_label
)
@api.depends('age')
def _compute_get_age_status(self):
for rec in self:
@ -339,7 +360,8 @@ class FamilyMemberProfile(models.Model):
rec.age_status = 'minor'
elif rec.relationn.relation_type == 'daughter' and rec.age <= 26:
rec.age_status = 'minor'
elif rec.relationn.relation_type == 'son' and rec.age <= 22 and (current_education_status_id.specialization_ids.is_scientific_specialty or current_education_status_id.specialization_ids.is_medical_specialty):
elif rec.relationn.relation_type == 'son' and rec.age <= 22 and (
current_education_status_id.specialization_ids.is_scientific_specialty or current_education_status_id.specialization_ids.is_medical_specialty):
rec.age_status = 'minor'
else:
rec.age_status = 'non_minor'
@ -352,7 +374,7 @@ class FamilyMemberProfile(models.Model):
# Check that dates are not in the future
if rec.birth_date and rec.birth_date > today:
raise ValidationError("Member's Birth Date cannot be in the future.")
def unlink(self):
for order in self:
if order.state not in ['draft']:
@ -369,7 +391,7 @@ class FamilyMemberProfile(models.Model):
return super(FamilyMemberProfile, self).unlink()
@api.depends('is_member_workflow', 'benefit_id.state','state_a')
@api.depends('is_member_workflow', 'benefit_id.state', 'state_a')
def _get_state(self):
for rec in self:
if not rec.is_member_workflow:
@ -403,7 +425,7 @@ class FamilyMemberProfile(models.Model):
raise ValidationError('The attachment name is missing.')
default_attachments_data.append((0, 0, {
'name': attach.name,
'attach_id':attach.id,
'attach_id': attach.id,
'is_required': attach.is_required,
'is_default': attach.is_default,
'show_in_portal': attach.show_in_portal
@ -414,11 +436,12 @@ class FamilyMemberProfile(models.Model):
res['attachment_ids'] = default_attachments_data
return res
def _get_total_member_service_requests(self):
for rec in self:
rec.total_member_service_requests = self.env['service.request'].search_count([('benefit_type', '=', 'member'), ('member_id', '=', rec.id)])
rec.total_member_service_requests = self.env['service.request'].search_count(
[('benefit_type', '=', 'member'), ('member_id', '=', rec.id)])
def action_open_related_member_service_requests(self):
""" Opens a tree view with related records filtered by a dynamic domain """
member_service_requests = self.env['service.request'].search([
@ -460,7 +483,7 @@ class FamilyMemberProfile(models.Model):
@api.depends(
'member_education_status_ids',
'member_education_status_ids.specialization_ids',
'member_education_status_ids.specialization_ids',
'member_education_status_ids.education_status',
'member_education_status_ids.case_study',
'relationn',
@ -478,7 +501,8 @@ class FamilyMemberProfile(models.Model):
for rec in self:
reasons = []
rec.non_benefit_reason = False
current_education_status_id = rec.member_education_status_ids.filtered(lambda r: r.education_status_type == 'current')
current_education_status_id = rec.member_education_status_ids.filtered(
lambda r: r.education_status_type == 'current')
if rec.state == 'second_approve' and rec.is_excluded_suspension:
rec.member_status = 'benefit'
continue
@ -498,14 +522,15 @@ class FamilyMemberProfile(models.Model):
if rec.relationn.relation_type == 'mother':
if not benefiting_children:
rec.write({'member_status': 'non_benefit'})
reasons.append("Mother has no benefiting children")
reasons.append(_("Mother has no benefiting children"))
else:
rec.member_status = rec.benefit_id.check_mother_status()
elif rec.relationn.relation_type == 'replacement_mother':
rec.member_status = rec.benefit_id.check_replacement_mother_status()
if rec.state in ['suspended_second_approve','refused'] or not benefiting_children:
if rec.state in ['suspended_second_approve', 'refused'] or not benefiting_children:
rec.member_status = 'non_benefit'
reasons.append("Test 01")
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."))
# continue # Skip further checks for mothers
# Gender-specific checks
elif rec.relationn.relation_type == 'son':
@ -515,77 +540,89 @@ class FamilyMemberProfile(models.Model):
else:
if rec.age > exceptional_age_has_disabilities and rec.disabilities_attachment_ids:
rec.member_status = 'non_benefit'
reasons.append("Test 02")
elif current_education_status_id.specialization_ids.is_scientific_specialty and rec.age > exceptional_age_scientific_specialty and not rec.minor_siblings :
reasons.append(
_("He/She has a physical or intellectual disability but is over 30 years of age."))
elif current_education_status_id.specialization_ids.is_scientific_specialty and rec.age > exceptional_age_scientific_specialty and not rec.minor_siblings:
rec.member_status = 'non_benefit'
reasons.append("Test 03")
reasons.append(
_("He/She is enrolled in a scientific or vocational specialization but is over 24 years of age."))
elif current_education_status_id.specialization_ids.is_medical_specialty and rec.age > exceptional_age_medical_specialty and not rec.minor_siblings:
rec.member_status = 'non_benefit'
reasons.append("Test 04")
elif not any([current_education_status_id.specialization_ids.is_scientific_specialty, current_education_status_id.specialization_ids.is_medical_specialty]):
reasons.append(
_("He/She is enrolled in a medical specialization but is over 26 years of age."))
elif not any([current_education_status_id.specialization_ids.is_scientific_specialty,
current_education_status_id.specialization_ids.is_medical_specialty]):
rec.member_status = 'non_benefit'
reasons.append("Test 05")
reasons.append(
_("He/She is over 18 years of age and not enrolled in a scientific or medical specialization."))
if not rec.minor_siblings:
rec.member_status = 'non_benefit'
reasons.append("Test 06")
reasons.append(
_("She is over 18 years of age and not enrolled in any educational institution."))
if rec.is_work:
if rec.member_income > max_income_for_benefit:
rec.member_status = 'non_benefit'
reasons.append("Test 07")
reasons.append(_("He/She is employed with a salary exceeding 4,000."))
if not rec.is_married and rec.education_status in ['illiterate']:
rec.member_status = 'non_benefit'
reasons.append("Test 08")
if not rec.is_married and rec.education_status in ['educated'] and current_education_status_id.case_study in [
reasons.append(
_("He/She is over 18 years of age and not enrolled in an educational institution."))
if not rec.is_married and rec.education_status in [
'educated'] and current_education_status_id.case_study in [
'graduate', 'intermittent']:
rec.member_status = 'non_benefit'
reasons.append("Test 09")
reasons.append(_("He/She is over 18 years of age and has completed his/her education."))
if not rec.member_location_conf.is_benefit:
rec.member_status = 'non_benefit'
reasons.append("Test 10")
if rec.state in ['suspended_second_approve','refused'] or rec.is_dead == True:
reasons.append(_("He/She does not reside with his/her family."))
if rec.state in ['suspended_second_approve', 'refused'] or rec.is_dead == True:
rec.member_status = 'non_benefit'
reasons.append("Test 11")
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."))
elif rec.relationn.relation_type == 'daughter':
if rec.age < female_benefit_age and rec.is_married:
rec.member_status = 'non_benefit'
reasons.append("Test 12")
if rec.age < female_benefit_age and rec.is_work and rec.education_status not in ['educated'] and current_education_status_id.case_study != 'continuous':
rec.member_status = 'non_benefit'
reasons.append("Test 13")
reasons.append(_("Married"))
if rec.age < female_benefit_age and rec.is_work and rec.education_status not in [
'educated'] and current_education_status_id.case_study != 'continuous':
rec.member_status = 'non_benefit'
reasons.append(_("She is employed and not enrolled in an educational institution."))
if rec.age > female_benefit_age:
if rec.age > minor_siblings_age and not rec.minor_siblings:
rec.member_status = 'non_benefit'
reasons.append("Test 14")
reasons.append(_("She is over 26 years of age and has no underage brothers."))
elif not rec.minor_siblings:
rec.member_status = 'non_benefit'
reasons.append("Test 15")
reasons.append(_("She is over 26 years of age and has no underage brothers."))
elif rec.minor_siblings and rec.age > minor_siblings_age:
rec.member_status = 'non_benefit'
reasons.append("Test 16")
reasons.append(_("She is over 35 years of age."))
# elif rec.is_work and current_education_status_id.education_status in ['illiterate'] and current_education_status_id.case_study in [
# 'graduate', 'intermittent']:
# rec.member_status = 'non_benefit'
elif rec.is_married:
rec.member_status = 'non_benefit'
reasons.append("Test 17")
reasons.append(_("Married"))
# elif not rec.minor_siblings:
# rec.member_status = 'non_benefit'
if rec.is_work and rec.member_income > max_income_for_benefit and rec.education_status in ['educated'] and current_education_status_id.case_study == 'continuous':
if rec.is_work and rec.member_income > max_income_for_benefit and rec.education_status in [
'educated'] and current_education_status_id.case_study == 'continuous':
rec.member_status = 'non_benefit'
reasons.append("Test 18")
if rec.is_work and rec.education_status in ['illiterate'] :
rec.member_status = 'non_benefit'
reasons.append("Test 19")
if rec.is_work and rec.education_status in ['educated'] and current_education_status_id.case_study in [
'graduate', 'intermittent']:
rec.member_status = 'non_benefit'
reasons.append("Test 20")
reasons.append(_("She works with a salary greater than 4,000."))
if rec.is_work and rec.education_status in ['illiterate']:
rec.member_status = 'non_benefit'
reasons.append(_("She is employed and not enrolled in an educational institution."))
if rec.is_work and rec.education_status in [
'educated'] and current_education_status_id.case_study in [
'graduate', 'intermittent']:
rec.member_status = 'non_benefit'
reasons.append(_("She is employed and has completed her education."))
if not rec.member_location_conf.is_benefit:
rec.member_status = 'non_benefit'
reasons.append("Test 21")
if rec.state in ['suspended_second_approve','refused'] or rec.is_dead == True:
reasons.append(_("She does not reside with the family."))
if rec.state in ['suspended_second_approve', 'refused'] or rec.is_dead == True:
rec.member_status = 'non_benefit'
reasons.append("Test 22")
reasons.append(_("Application rejected due to missing documents, missing official proofs, or the family's ineligibility for the association's services."))
# General checks for all members
# if rec.is_work:
# if rec.member_income > max_income_for_benefit:
@ -715,24 +752,27 @@ class FamilyMemberProfile(models.Model):
# Check if the father ID and mother ID are the same on the same record
if rec.member_id_number == rec.benefit_id.mother_id_number or rec.member_id_number == rec.benefit_id.father_id_number or rec.member_id_number == rec.benefit_id.replacement_mother_id_number:
raise ValidationError(_("ID number cannot be the same with mother or replacement mother or father id number"))
raise ValidationError(
_("ID number cannot be the same with mother or replacement mother or father id number"))
# Check if the ID number exists in other records or in family members
exist = self.search([
('member_id_number', '=', rec.member_id_number)
],limit=1)
], limit=1)
exist_in_family = self.env["grant.benefit"].search([
'|','|',
'|', '|',
('father_id_number', '=', rec.member_id_number),
('mother_id_number', '=', rec.member_id_number),
('replacement_mother_id_number', '=', rec.member_id_number),
],limit=1)
], limit=1)
if exist or exist_in_family:
if exist_in_family:
raise ValidationError(_("The ID Number already exists in Family with code %s")%exist_in_family.code)
if exist :
raise ValidationError(
_("The ID Number already exists in Family with code %s") % exist_in_family.code)
if exist:
raise ValidationError(
_("The ID Number already exists in Family with code %s") % exist.benefit_id.code)
# @api.onchange("member_id_number")
# def onchange_member_id_number(self):
# for rec in self:
@ -742,19 +782,21 @@ class FamilyMemberProfile(models.Model):
# raise ValidationError(
# _('The ID Number Already Exist!'))
@api.onchange('relationn','member_status','gender','birth_date', 'is_scientific_specialty', 'is_medical_specialty', 'is_married',
'minor_siblings','member_income','is_married','member_location_conf','education_status','case_study')
@api.onchange('relationn', 'member_status', 'gender', 'birth_date', 'is_scientific_specialty',
'is_medical_specialty', 'is_married',
'minor_siblings', 'member_income', 'is_married', 'member_location_conf', 'education_status',
'case_study')
def onchange_member_status(self):
res ={}
for rec in self:
if rec.member_status == 'non_benefit':
res['warning'] = {'title': _('ValidationError'),
'message': _('Not Benefit')}
return res
res = {}
for rec in self:
if rec.member_status == 'non_benefit':
res['warning'] = {'title': _('ValidationError'),
'message': _('Not Benefit')}
return res
#Member Suspend Manual
# Member Suspend Manual
def action_suspend(self):
for rec in self :
for rec in self:
rec.is_member_workflow = True
rec.is_excluded_suspension = False
return {
@ -766,16 +808,20 @@ class FamilyMemberProfile(models.Model):
'view_id': self.env.ref('odex_benefit.view_suspend_member_reason_wizard_form').id,
'target': 'new',
}
def action_suspend_first_accept(self):
for rec in self:
rec.state_a = 'first_approve'
def action_suspend_second_accept(self):
for rec in self:
rec.state_a = 'suspended_second_approve'
def action_suspend_refuse(self):
for rec in self:
rec.state_a = 'second_approve'
rec.is_member_workflow = False
# Excption Work flow
def action_exception(self):
for rec in self:
@ -837,9 +883,11 @@ class FamilyMemberProfile(models.Model):
message = self.create_message('waiting_approve')
# self.partner_id.send_sms_notification(message, self.phone)
self.state_a = 'waiting_approve'
def action_accepted(self):
"""Accept registration"""
self.state_a = "second_approve"
def action_first_refusal(self):
"""First refusal to entity registration"""
domain = []
@ -859,6 +907,7 @@ class FamilyMemberProfile(models.Model):
'domain': domain,
'context': context,
}
def action_refuse(self):
"""Refuse entity registration"""
domain = []
@ -876,6 +925,7 @@ class FamilyMemberProfile(models.Model):
'domain': domain,
'context': context,
}
def action_black_list(self):
"""Move benefit to black list"""
domain = []
@ -893,6 +943,7 @@ class FamilyMemberProfile(models.Model):
'domain': domain,
'context': context,
}
def action_edit_info(self):
self.state = 'complete_info'
@ -901,6 +952,7 @@ class FamilyMemberProfile(models.Model):
# group_e = self.env.ref('odex_benefit.group_benefit_edit', False)
# group_e.write({'users': [(3, self.user_id.id)]})
rec.state_a = rec.old_stage
def create_manual_visit(self):
self.env['visit.location'].create({
'benefit_id': self.id,
@ -947,7 +999,3 @@ class FamilyMemberProfile(models.Model):
if exist:
raise ValidationError(
_("The phone Number already exists in Family with code %s") % exist.benefit_id.code)

View File

@ -742,6 +742,11 @@
<field name="member_ids" widget="one2many_list"
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}">
<form string="Family Member">
<div class="alert alert-danger" role="alert"
style="margin-bottom:0px;text-align:center;"
attrs="{'invisible':[('member_status', '=', 'benefit')]}">
<field name="non_benefit_reason" attrs="{'readonly': True}"/>
</div>
<sheet>
<widget name="web_ribbon" title="Non Benefit Member" bg_color="bg-danger"
attrs="{'invisible': [('member_status', '!=', 'non_benefit')]}"/>

View File

@ -270,7 +270,9 @@
<field name="name" force_save="1"/>
<field name="relationn"/>
<field name="member_location_conf"/>
<field name="member_status" string="Is Benefit?"/>
<field name="member_status" widget="badge"
decoration-success="member_status == 'benefit'"
decoration-danger="member_status == 'non_benefit'" string="Is Benefit?"/>
<field name="age"/>
<field name="benefit_id"/>
<field name="state"/>