IMP benefit
This commit is contained in:
parent
fa19ac92cf
commit
98fd1f3543
|
|
@ -59,10 +59,7 @@ class GrantBenefitProfile(models.Model):
|
|||
code = fields.Char(string="Code", copy=False, readonly=True, default=lambda x: _('New'))
|
||||
benefit_type = fields.Selection([('benefit', 'benefit'), ('orphan', 'orphan'), ('widow', 'widow')
|
||||
], string='Benefit Type', tracking=True)
|
||||
mother_status = fields.Selection(selection=[
|
||||
('benefit', 'Benefit'),
|
||||
('non_benefit', 'Non Benefit'),
|
||||
], string='Mother Status', compute="check_mother_status", store=True, default=False)
|
||||
mother_status = fields.Selection(string='Mother Status', related="mother_family_member_id.member_status")
|
||||
mother_salary_certificate = fields.Many2many('ir.attachment', 'mother_member_salary_cert_rel', 'mother_grant_benefit_id', 'attachment_id',
|
||||
string="Salary Certificate")
|
||||
phone2 = fields.Char(string="Phone2")
|
||||
|
|
@ -539,10 +536,7 @@ class GrantBenefitProfile(models.Model):
|
|||
replacement_mother_dead_reason = fields.Char(string='Dead Reason', required=False)
|
||||
replacement_mother_dead_date = fields.Date(string="Replacement Mother Dead Date")
|
||||
replacement_mother_dead_certificate = fields.Many2many('ir.attachment', 'rel_replacement_mother_dead_attachment', 'benefit_id', 'attachment_id', string='Replacement Mother Dead Certificate')
|
||||
replacement_mother_status = fields.Selection(selection=[
|
||||
('benefit', 'Benefit'),
|
||||
('non_benefit', 'Non Benefit'),
|
||||
], string='Replacement Mother Status', compute="check_replacement_mother_status", store=True, default=False)
|
||||
replacement_mother_status = fields.Selection(string='Replacement Mother Status', related="replacement_mother_family_member_id.member_status")
|
||||
replacement_mother_salary_certificate = fields.Many2many('ir.attachment', 'replacement_mother_member_salary_cert_rel',
|
||||
'replacement_mother_grant_benefit_id', 'attachment_id',
|
||||
string="Salary Certificate")
|
||||
|
|
@ -1122,53 +1116,49 @@ class GrantBenefitProfile(models.Model):
|
|||
'url': url
|
||||
}
|
||||
|
||||
@api.depends('mother_marital_conf', 'mother_income', 'mother_location_conf', 'mother_country_id', 'state')
|
||||
def check_mother_status(self):
|
||||
validation_setting = self.env["family.validation.setting"].search([], limit=1)
|
||||
mini_income_for_mother = validation_setting.mini_income_for_mother
|
||||
max_income_for_mother = validation_setting.max_income_for_mother
|
||||
for rec in self:
|
||||
rec.mother_status = False
|
||||
if rec.mother_location_conf and rec.mother_marital_conf:
|
||||
if not rec.mother_location_conf.is_benefit or not rec.mother_marital_conf.is_benefit or rec.state == 'suspended_second_approve':
|
||||
rec.mother_status = 'non_benefit'
|
||||
return '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 mini_income_for_mother < rec.mother_income <= max_income_for_mother:
|
||||
rec.mother_status = 'non_benefit'
|
||||
return 'non_benefit'
|
||||
elif rec.mother_income <= mini_income_for_mother:
|
||||
rec.mother_status = 'benefit'
|
||||
return 'benefit'
|
||||
elif rec.mother_income > max_income_for_mother:
|
||||
rec.mother_status = 'benefit'
|
||||
return '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'):
|
||||
rec.mother_status = 'benefit'
|
||||
return 'benefit'
|
||||
|
||||
|
||||
@api.depends('replacement_mother_marital_conf', 'replacement_mother_income', 'replacement_mother_location_conf', 'replacement_mother_country_id', 'state')
|
||||
def check_replacement_mother_status(self):
|
||||
validation_setting = self.env["family.validation.setting"].search([], limit=1)
|
||||
mini_income_for_mother = validation_setting.mini_income_for_mother
|
||||
max_income_for_mother = validation_setting.max_income_for_mother
|
||||
for rec in self:
|
||||
rec.replacement_mother_status = 'non_benefit'
|
||||
rec.replacement_mother_status = False
|
||||
if not rec.add_replacement_mother:
|
||||
continue
|
||||
if not rec.replacement_mother_location_conf.is_benefit or not rec.replacement_mother_marital_conf.is_benefit or rec.state == 'suspended_second_approve':
|
||||
rec.replacement_mother_status = 'non_benefit'
|
||||
return 'non_benefit'
|
||||
elif rec.replacement_mother_marital_conf.is_benefit:
|
||||
if rec.replacement_is_mother_work and rec.replacement_mother_country_id.code == 'SA' or (
|
||||
rec.replacement_mother_country_id.code != 'SA' and rec.father_country_id.code == 'SA'):
|
||||
if mini_income_for_mother < rec.replacement_mother_income <= max_income_for_mother:
|
||||
rec.replacement_mother_status = 'non_benefit'
|
||||
return 'non_benefit'
|
||||
elif rec.replacement_mother_income <= mini_income_for_mother:
|
||||
rec.replacement_mother_status = 'benefit'
|
||||
return 'benefit'
|
||||
elif rec.replacement_mother_income > max_income_for_mother:
|
||||
rec.replacement_mother_status = 'benefit'
|
||||
return 'benefit'
|
||||
elif not rec.replacement_is_mother_work and rec.replacement_mother_country_id.code == 'SA' or (
|
||||
rec.replacement_mother_country_id.code != 'SA' and rec.father_country_id.code == 'SA'):
|
||||
rec.replacement_mother_status = 'benefit'
|
||||
return 'benefit'
|
||||
|
||||
def delete_from_db(self):
|
||||
find_id = self.env['benefit.housing'].search([])
|
||||
|
|
@ -1650,7 +1640,7 @@ class GrantBenefitProfile(models.Model):
|
|||
rec.is_diseases = 'sick' if rec.is_diseases else 'healthy'
|
||||
|
||||
def _onchange_is_has_needs(self):
|
||||
for rec in self:
|
||||
for rec in self:
|
||||
benefits_needs = rec.env['benefits.needs'].sudo().search(['|',
|
||||
('benefit_id', '=', rec.id),
|
||||
('benefit_ids', 'in', rec.id)])
|
||||
|
|
|
|||
|
|
@ -452,13 +452,14 @@ class FamilyMemberProfile(models.Model):
|
|||
'is_married',
|
||||
'member_location_conf',
|
||||
'state',
|
||||
'is_dead'
|
||||
'is_dead',
|
||||
'benefit_id.member_ids.member_status',
|
||||
)
|
||||
def check_member_status(self):
|
||||
for rec in self:
|
||||
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'
|
||||
rec.write({'member_status': 'benefit'})
|
||||
continue
|
||||
if rec.birth_date:
|
||||
validation_setting = self.env["family.validation.setting"].search([], limit=1)
|
||||
|
|
@ -469,15 +470,21 @@ class FamilyMemberProfile(models.Model):
|
|||
minor_siblings_age = validation_setting.minor_siblings_age
|
||||
max_income_for_benefit = validation_setting.max_income_for_benefit
|
||||
rec.member_status = 'benefit' # Default to benefit
|
||||
benefiting_children = rec.benefit_id.member_ids.filtered(
|
||||
lambda m: m.relationn.relation_type in ['son', 'daughter'] and m.member_status == 'benefit'
|
||||
)
|
||||
if rec.relationn.relation_type == 'mother':
|
||||
rec.member_status = rec.benefit_id.mother_status
|
||||
if rec.relationn.relation_type == 'replacement_mother':
|
||||
rec.member_status = rec.benefit_id.replacement_mother_status
|
||||
if rec.state == 'suspended_second_approve':
|
||||
if not benefiting_children:
|
||||
rec.write({'member_status': 'non_benefit'})
|
||||
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 == 'suspended_second_approve' or not benefiting_children:
|
||||
rec.member_status = 'non_benefit'
|
||||
# continue # Skip further checks for mothers
|
||||
# Gender-specific checks
|
||||
if rec.relationn.relation_type == 'son':
|
||||
elif rec.relationn.relation_type == 'son':
|
||||
if rec.age > male_benefit_age:
|
||||
if 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'
|
||||
|
|
@ -499,7 +506,6 @@ class FamilyMemberProfile(models.Model):
|
|||
rec.member_status = 'non_benefit'
|
||||
if rec.state == 'suspended_second_approve' or rec.is_dead == True:
|
||||
rec.member_status = 'non_benefit'
|
||||
|
||||
elif rec.relationn.relation_type == 'daughter':
|
||||
if rec.age < female_benefit_age and rec.is_married:
|
||||
rec.member_status = 'non_benefit'
|
||||
|
|
@ -683,15 +689,15 @@ 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')
|
||||
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
|
||||
#@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
|
||||
|
||||
#Member Suspend Manual
|
||||
def action_suspend(self):
|
||||
|
|
|
|||
|
|
@ -420,9 +420,9 @@
|
|||
</group>
|
||||
</page>
|
||||
<page string="Mother">
|
||||
<widget name="web_ribbon" title="Non Benefit Mother" bg_color="bg-danger"
|
||||
<widget invisible="1" name="web_ribbon" title="Non Benefit Mother" bg_color="bg-danger"
|
||||
attrs="{'invisible': [('mother_status', '!=', 'non_benefit')]}"/>
|
||||
<widget name="web_ribbon" title="Benefit Mother" bg_color="bg-success"
|
||||
<widget invisible="1" name="web_ribbon" title="Benefit Mother" bg_color="bg-success"
|
||||
attrs="{'invisible': [('mother_status', '!=', 'benefit')]}"/>
|
||||
<group>
|
||||
<group>
|
||||
|
|
@ -453,8 +453,8 @@
|
|||
<field name="mother_id_number_type"
|
||||
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}"
|
||||
required="1"/>
|
||||
<field name="mother_birth_date"
|
||||
attrs="{'required':[('state','not in',['draft','new'])],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
|
||||
<field name="mother_birth_date" required="1"
|
||||
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
|
||||
<field name="mother_country_id"
|
||||
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}"
|
||||
options="{'no_create': True, 'no_create_edit': True,'no_quick_create': True, 'no_open': True}"
|
||||
|
|
@ -569,25 +569,25 @@
|
|||
</page>
|
||||
<page string="Replacement Mother"
|
||||
attrs="{'invisible':[('add_replacement_mother','=',False)]}">
|
||||
<widget name="web_ribbon" title="Non Benefit Replacement Mother" bg_color="bg-danger"
|
||||
<widget invisible="1" name="web_ribbon" title="Non Benefit Replacement Mother" bg_color="bg-danger"
|
||||
attrs="{'invisible': [('replacement_mother_status', '!=', 'non_benefit')]}"/>
|
||||
<widget name="web_ribbon" title="Benefit Replacement Mother" bg_color="bg-success"
|
||||
<widget invisible="1" name="web_ribbon" title="Benefit Replacement Mother" bg_color="bg-success"
|
||||
attrs="{'invisible': [('replacement_mother_status', '!=', 'benefit')]}"/>
|
||||
<group>
|
||||
<group>
|
||||
<label for="replacement_mother_name" string="Replacement Mother Name"/>
|
||||
<div class="o_row">
|
||||
<field name="replacement_mother_name" nolabel="1" placeholder="First Name"
|
||||
attrs="{'required':[('state','not in',['draft','new']),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
|
||||
attrs="{'required':[('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
|
||||
<field name="replacement_mother_second_name" nolabel="1"
|
||||
placeholder="Second Name"
|
||||
attrs="{'required':[('state','not in',['draft','new']),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
|
||||
attrs="{'required':[('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
|
||||
<field name="replacement_mother_third_name" nolabel="1"
|
||||
placeholder="Third Name"
|
||||
attrs="{'required':[('state','not in',['draft','new']),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
|
||||
attrs="{'required':[('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
|
||||
<field name="replacement_mother_family_name" nolabel="1"
|
||||
placeholder="Family Name"
|
||||
attrs="{'required':[('state','not in',['draft','new']),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
|
||||
attrs="{'required':[('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
|
||||
</div>
|
||||
</group>
|
||||
<group/>
|
||||
|
|
@ -596,13 +596,13 @@
|
|||
<group>
|
||||
<field name="replacement_mother_relation" class="oe_inline"
|
||||
options='{"no_open": True,"no_create_edit": True}'
|
||||
attrs="{'required':[('state','not in',['draft','new']),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
|
||||
attrs="{('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
|
||||
<field name="replacement_mother_id_number"
|
||||
attrs="{'required':[('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
|
||||
<field name="replacement_mother_id_number_type"
|
||||
attrs="{'required':[('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
|
||||
<field name="replacement_mother_birth_date"
|
||||
attrs="{'required':[('state','not in',['draft','new']),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
|
||||
attrs="{'required':[('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
|
||||
<field name="replacement_mother_country_id"
|
||||
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'required':[('add_replacement_mother','=',True)]}"
|
||||
options="{'no_create': True, 'no_create_edit': True,'no_quick_create': True, 'no_open': True}"
|
||||
|
|
|
|||
Loading…
Reference in New Issue