This commit is contained in:
eman 2024-12-14 19:26:42 +02:00
parent a4f1761e70
commit b1a353d52d
10 changed files with 87 additions and 27 deletions

View File

@ -195,6 +195,7 @@ class GrantBenefitProfile(models.Model):
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')
mother_location_conf = fields.Many2one('location.settings',string='Mother Location',domain="[('location_type','=','mother_location')]")
is_mother_work = fields.Boolean('Is Mother Work?')
mother_has_disabilities = fields.Boolean('Has Disabilities?')
mother_income = fields.Float("Mother Income")
@ -480,6 +481,7 @@ class GrantBenefitProfile(models.Model):
replacement_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='Replacement Mother Location')
replacement_mother_location_conf = fields.Many2one('location.settings',string='Replacement Mother Location',domain="[('location_type','=','mother_location')]")
replacement_is_mother_work = fields.Boolean('Is Replacement Mother Work?')
replacement_mother_has_disabilities = fields.Boolean('Has Disabilities?')
replacement_mother_income = fields.Float("Replacement Mother Income")
@ -774,14 +776,14 @@ class GrantBenefitProfile(models.Model):
'url': url
}
@api.depends('mother_marital_conf', 'mother_income', 'mother_location', 'mother_country_id', 'state')
@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 == 'not_live_with_children' or not rec.mother_marital_conf.is_benefit or rec.state == 'suspended_second_approve':
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'
elif rec.mother_marital_conf.is_benefit :
if rec.is_mother_work and rec.mother_country_id.code == 'SA' or (
@ -796,14 +798,14 @@ class GrantBenefitProfile(models.Model):
rec.mother_country_id.code != 'SA' and rec.father_country_id.code == 'SA'):
rec.mother_status = 'benefit'
@api.depends('replacement_mother_marital_conf', 'replacement_mother_income', 'replacement_mother_location', 'replacement_mother_country_id', 'state')
@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 = False
if rec.replacement_mother_location == 'not_live_with_children' or not rec.replacement_mother_marital_conf.is_benefit or rec.state == 'suspended_second_approve':
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'
elif rec.replacement_mother_marital_conf.is_benefit:
if rec.replacement_is_mother_work and rec.replacement_mother_country_id.code == 'SA' or (
@ -1368,7 +1370,7 @@ class GrantBenefitProfile(models.Model):
'gender': 'female',
'relationn': self.env['relation.settings'].search([('relation_type','=','mother')]).id,
'mother_marital_conf': rec.mother_marital_conf.id,
'mother_location': rec.mother_location,
'mother_location_conf': rec.mother_location_conf.id,
'age': rec.mother_age,
'is_work': rec.is_mother_work,
'has_disabilities':rec.mother_has_disabilities,
@ -1418,7 +1420,7 @@ class GrantBenefitProfile(models.Model):
'gender': 'female',
'relationn': rec.replacement_mother_relation.id,
'mother_marital_conf': rec.replacement_mother_marital_conf.id,
'mother_location': rec.replacement_mother_location,
'mother_location': rec.replacement_mother_location_conf.id,
'age': rec.replacement_mother_age,
'is_work': rec.replacement_is_mother_work,
'has_disabilities': rec.replacement_mother_has_disabilities,
@ -1468,7 +1470,7 @@ class GrantBenefitProfile(models.Model):
'gender': 'female',
'relationn': self.env['relation.settings'].search([('relation_type','=','mother')]).id,
'mother_marital_conf': rec.mother_marital_conf.id,
'mother_location': rec.mother_location,
'mother_location_conf': rec.mother_location_conf.id,
'age': rec.mother_age,
'is_work': rec.is_mother_work,
'has_disabilities': rec.mother_has_disabilities,
@ -1518,7 +1520,7 @@ class GrantBenefitProfile(models.Model):
'gender': 'female',
'relationn': rec.replacement_mother_relation.id,
'mother_marital_conf': rec.replacement_mother_marital_conf.id,
'mother_location': rec.replacement_mother_location,
'mother_location': rec.replacement_mother_location_conf.id,
'age': rec.replacement_mother_age,
'is_work': rec.replacement_is_mother_work,
'has_disabilities': rec.replacement_mother_has_disabilities,
@ -1890,7 +1892,7 @@ class GrantBenefitProfile(models.Model):
if partner_exist or benefit_exist:
raise ValidationError(_("The account number already exists!"))
@api.onchange('mother_marital_conf', 'mother_location', 'mother_income')
@api.onchange('mother_marital_conf', 'mother_location_conf', 'mother_income')
def _onchange_mother_info(self):
res = {}
for rec in self:
@ -1899,7 +1901,7 @@ class GrantBenefitProfile(models.Model):
'message': _('Not Benefit')}
return res
@api.onchange('replacement_mother_marital_conf', 'replacement_mother_location', 'replacement_mother_income')
@api.onchange('replacement_mother_marital_conf', 'replacement_mother_location_conf', 'replacement_mother_income')
def _onchange_replacement_mother_info(self):
res = {}
for rec in self:

View File

@ -610,6 +610,14 @@ class RelationSettings(models.Model):
relation_type = fields.Selection(
[('son', _('Son')), ('daughter', _('Daughter')),('mother', _('Mother')),('replacement_mother', _('Replacement Mother')),('other relation', _('Other Relation'))])
class LocationSettings(models.Model):
_name = 'location.settings'
_description = "Location Settings"
name = fields.Char(string='name')
location_type = fields.Selection([('member', _('Member')), ('mother_location', _('Mother Location'))])
is_benefit = fields.Boolean(string='Is Benefit?')
class AttachmentsSettings(models.Model):
_name = 'attachments.settings'
_description = "Attachments Settings"

View File

@ -41,6 +41,7 @@ class FamilyMemberProfile(models.Model):
('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',domain="[('location_type','=','member')]")
# 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)
@ -59,6 +60,7 @@ class FamilyMemberProfile(models.Model):
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')
mother_location_conf = fields.Many2one('location.settings',string='Mother Location',domain="[('location_type','=','mother_location')]")
need_transportation = fields.Boolean('Need Transportation?')
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)])
@ -326,7 +328,7 @@ class FamilyMemberProfile(models.Model):
# 'code': self.benefit_id.code,
# })
@api.depends('relationn','birth_date', 'is_scientific_specialty', 'is_medical_specialty', 'has_disabilities', 'is_married',
'minor_siblings','member_income','is_married','member_location','education_status','case_study','state','is_dead')
'minor_siblings','member_income','is_married','member_location_conf','education_status','case_study','state','is_dead')
def check_member_status(self):
for rec in self:
if rec.state == 'second_approve' and rec.is_excluded_suspension:
@ -368,7 +370,7 @@ class FamilyMemberProfile(models.Model):
if not rec.is_married and rec.education_status in ['educated'] and rec.case_study in [
'graduate', 'intermittent']:
rec.member_status = 'non_benefit'
if rec.member_location in ['with_relative', 'study_outside_saudi_arabia']:
if not rec.member_location_conf.is_benefit:
rec.member_status = 'non_benefit'
if rec.state == 'suspended_second_approve' or rec.is_dead == True:
rec.member_status = 'non_benefit'
@ -398,7 +400,7 @@ class FamilyMemberProfile(models.Model):
if rec.is_work and rec.education_status in ['educated'] and rec.case_study in [
'graduate', 'intermittent']:
rec.member_status = 'non_benefit'
if rec.member_location in ['with_relative', 'study_outside_saudi_arabia']:
if not rec.member_location_conf.is_benefit:
rec.member_status = 'non_benefit'
if rec.state == 'suspended_second_approve' or rec.is_dead == True:
rec.member_status = 'non_benefit'
@ -467,7 +469,7 @@ class FamilyMemberProfile(models.Model):
# _('The ID Number Already Exist!'))
@api.onchange('relationn','member_status','gender','birth_date', 'is_scientific_specialty', 'is_medical_specialty', 'has_disabilities', 'is_married',
'minor_siblings','member_income','is_married','member_location','education_status','case_study')
'minor_siblings','member_income','is_married','member_location_conf','education_status','case_study')
def onchange_member_status(self):
res ={}
for rec in self:

View File

@ -138,4 +138,5 @@ access_water_bill_lines,access_water_bill_lines,model_water_bill_lines,base.grou
access_age_category,access_age_category,model_age_category,base.group_user,1,1,1,1
access_complaints_category,access_complaints_category,model_complaints_category,base.group_user,1,1,1,1
access_family_complaints,access_family_complaints,model_family_complaints,base.group_user,1,1,1,1
access_buy_home_lines,access_buy_home_lines,model_buy_home_lines,base.group_user,1,1,1,1
access_buy_home_lines,access_buy_home_lines,model_buy_home_lines,base.group_user,1,1,1,1
access_location_settings,access_location_settings,model_location_settings,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
138 access_age_category access_age_category model_age_category base.group_user 1 1 1 1
139 access_complaints_category access_complaints_category model_complaints_category base.group_user 1 1 1 1
140 access_family_complaints access_family_complaints model_family_complaints base.group_user 1 1 1 1
141 access_buy_home_lines access_buy_home_lines model_buy_home_lines base.group_user 1 1 1 1
142 access_location_settings access_location_settings model_location_settings base.group_user 1 1 1 1

View File

@ -258,6 +258,15 @@
<p class="oe_view_nocontent_create">Create the Relation
</p>
</field>
</record>
<record model="ir.actions.act_window" id="location_action">
<field name="name">Location Settings</field>
<field name="res_model">location.settings</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">Create the Location
</p>
</field>
</record>
<record model="ir.actions.act_window" id="marital_status_action">
<field name="name">Marital Status</field>
@ -878,15 +887,18 @@
<menuitem id="relation_settings_menu" name="Relation Settings" parent="menu_benefits_config_organizing"
action="relation_action"
sequence="3"/>
<menuitem id="location_settings_menu" name="Location Settings" parent="menu_benefits_config_organizing"
action="location_action"
sequence="4"/>
<menuitem id="marital_status_menu" name="Marital Status" parent="menu_benefits_config_organizing"
action="marital_status_action"
sequence="4"/>
sequence="5"/>
<menuitem id="age_category_menu" name="Age Category" parent="menu_benefits_config_organizing"
action="age_category_action"
sequence="5"/>
sequence="6"/>
<menuitem id="complaints_category_menu" name="Complaints Category" parent="menu_benefits_config_organizing"
action="complaints_category_action"
sequence="6"/>
sequence="7"/>
<!-- <menuitem id="hobbies_settings_menu" name="Hobbies Settings" parent="menu_benefits_config_organizing"-->
<!-- action="hobbies_settings_action"-->
<!-- sequence="4"/>-->

View File

@ -983,6 +983,34 @@
<field name="relation_type"/>
</tree>
</field>
</record>
<record id="location_settings_form" model="ir.ui.view">
<field name="name">Location Settings</field>
<field name="model">location.settings</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<group>
<field name="name"/>
<field name="location_type"/>
<field name="is_benefit"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<record id="location_settings_tree" model="ir.ui.view">
<field name="name">Location Settings</field>
<field name="model">location.settings</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="location_type"/>
<field name="is_benefit"/>
</tree>
</field>
</record>
<record id="attachments_settings_form" model="ir.ui.view">
<field name="name">Attachments Settings</field>

View File

@ -342,7 +342,8 @@
<field name="mother_dead_city_id" attrs="{'invisible':[('mother_is_dead','=',False)],'required':[('mother_is_dead','=',True)],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
<field name="mother_dead_date" attrs="{'invisible':[('mother_is_dead','=',False)],'required':[('mother_is_dead','=',True)],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
<field name="mother_dead_certificate" attrs="{'invisible':[('mother_is_dead','=',False)],'required':[('mother_is_dead','=',True)],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}" widget="many2many_attachment_preview"/>
<field name="mother_location" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])],'required':[('state','!=','draft')]}"/>
<field name="mother_location" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}" invisible="1"/>
<field name="mother_location_conf" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])],'required':[('state','!=','draft')]}"/>
<field name="mother_age" attrs="{'required':[('state','!=','draft')]}"
readonly="1"/>
<field name="is_mother_work" attrs="{'required':[('state','!=','draft')],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
@ -448,8 +449,8 @@
<field name="replacement_mother_dead_city_id" attrs="{'invisible':[('replacement_mother_is_dead','=',False)],'required':[('replacement_mother_is_dead','=',True),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
<field name="replacement_mother_dead_date" attrs="{'invisible':[('replacement_mother_is_dead','=',False)],'required':[('replacement_mother_is_dead','=',True),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
<field name="replacement_mother_dead_certificate" attrs="{'invisible':[('replacement_mother_is_dead','=',False)],'required':[('replacement_mother_is_dead','=',True),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}" widget="many2many_attachment_preview"/>
<field name="replacement_mother_location"
attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])],'required':[('state','!=','draft'),('add_replacement_mother','=',True)]}"/>
<field name="replacement_mother_location" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}" invisible="1"/>
<field name="replacement_mother_location_conf" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])],'required':[('state','!=','draft'),('add_replacement_mother','=',True)]}"/>
<field name="replacement_mother_age" attrs="{'required':[('state','!=','draft'),('add_replacement_mother','=',True)]}"
readonly="1"/>
<field name="replacement_is_mother_work" attrs="{'required':[('state','!=','draft'),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
@ -548,7 +549,8 @@
<field name="member_id_number" required="1"/>
<field name="is_dead"/>
<!-- <field name="gender" required="1"/>-->
<field name="member_location" force_save="1" attrs="{'invisible':[('is_mother','=',True)]}"/>
<field name="member_location" force_save="1" invisible="1"/>
<field name="member_location_conf" force_save="1" attrs="{'invisible':[('is_mother','=',True)]}"/>
<field name="is_work"/>
<field name="member_income" attrs="{'required':[('is_work','=',True)]}"/>
<field name="need_transportation"/>
@ -573,7 +575,8 @@
<field name="is_alhaju" widget="boolean_toggle"/>
<field name="is_amra" widget="boolean_toggle"/>
<field name="mother_marital_conf" attrs="{'invisible':[('is_mother','=',False)]}"/>
<field name="mother_location" attrs="{'invisible':[('is_mother','=',False)]}"/>
<field name="mother_location" invisible="1"/>
<field name="mother_location_conf" attrs="{'invisible':[('is_mother','=',False)]}"/>
</group>
</group>
<notebook>
@ -711,7 +714,7 @@
<field name="name" force_save="1"/>
<!-- <field name="gender" required="1"/>-->
<field name="relationn"/>
<field name="member_location"/>
<field name="member_location_conf"/>
<field name="member_status" string="Is Benefit?"/>
<field name="age"/>
<field name="benefit_id"/>

View File

@ -56,7 +56,8 @@
<field name="member_id_number" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}" required="1"/>
<!-- <field name="gender" required="1" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>-->
<field name="is_dead" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
<field name="member_location" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
<field name="member_location" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}" invisible="1"/>
<field name="member_location_conf" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
<field name="is_work" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
<field name="member_income" attrs="{'required':[('is_work','=',True)],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
<field name="need_transportation" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
@ -75,7 +76,8 @@
<field name="is_alhaju" widget="boolean_toggle" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
<field name="is_amra" widget="boolean_toggle" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
<field name="mother_marital_conf" attrs="{'invisible':['|',('relationn','=','mother'),('relationn','=','replacement_mother')]}"/>
<field name="mother_location" attrs="{'invisible':['|',('relationn','=','mother'),('relationn','=','replacement_mother')]}"/>
<field name="mother_location" invisible="1"/>
<field name="mother_location_conf" attrs="{'invisible':['|',('relationn','=','mother'),('relationn','=','replacement_mother')]}"/>
<field name="benefit_id" attrs="{'readonly': [('state','!=','draft')]}" force_save="1" required="1"/>
<field name="member_status" readonly="1" widget="badge" decoration-success="member_status == 'benefit'" decoration-danger="member_status == 'non_benefit'"/>
@ -212,7 +214,7 @@
<field name="name" force_save="1"/>
<!-- <field name="gender" required="1"/>-->
<field name="relationn"/>
<field name="member_location"/>
<field name="member_location_conf"/>
<field name="member_status" string="Is Benefit?"/>
<field name="age"/>
<field name="benefit_id"/>

View File

@ -1055,5 +1055,6 @@ class AnotherSponsors(models.Model):
sponsor_name = fields.Char(string="Sponsor Name")
sponsor_phone = fields.Char(string="Sponsor Phone")
sponsor_id_number = fields.Char(string="Sponsor ID Number")
sponsorship_id = fields.Many2one('takaful.sponsorship')

View File

@ -186,6 +186,7 @@
<tree editable="bottom">
<field name="sponsor_name"/>
<field name="sponsor_phone"/>
<field name="sponsor_id_number"/>
</tree>
</field>
</page>