Merge pull request #4617 from expsa/youkch_dev_odex25_ensan
IMP benefit
This commit is contained in:
commit
601ca5004f
|
|
@ -4852,6 +4852,11 @@ msgstr ""
|
|||
msgid "Estimated Rent Amount"
|
||||
msgstr "قيمة الإيجار المقدرة من الجمعية"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__estimated_rent_amount
|
||||
msgid "Estimated Rent Amount"
|
||||
msgstr "القيمة التقديرية للإيجار"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_rent_lines__estimated_rent_branches
|
||||
msgid "Estimated Rent Branches"
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ class GrantBenefitProfile(models.Model):
|
|||
floor = fields.Char(string='floor')
|
||||
housing_number = fields.Char(string='housing number')
|
||||
rent_amount = fields.Float(string='Rent Amount')
|
||||
estimated_rent_amount = fields.Float(string="Estimated Rent Amount", compute="_compute_estimated_rent_amount",store=True)
|
||||
housing_type = fields.Selection([
|
||||
('apartment', 'apartment'),
|
||||
('villa', 'villa'),
|
||||
|
|
@ -669,6 +670,19 @@ class GrantBenefitProfile(models.Model):
|
|||
"Numbers and special characters are not allowed.") % field_label
|
||||
)
|
||||
|
||||
@api.depends('rent_amount','property_type','benefit_member_count', 'branch_custom_id.branch_type')
|
||||
def _compute_estimated_rent_amount(self):
|
||||
for rec in self:
|
||||
estimated_rent_amount = 0.0
|
||||
if rec.rent_amount > 0 and rec.property_type in ['rent','rent_shared']:
|
||||
if rec.branch_custom_id.branch_type == 'branches':
|
||||
estimated_rent_amount = self.env['rent.lines'].search(
|
||||
[('benefit_count', '=', rec.benefit_member_count)], order="estimated_rent_branches desc",limit=1).estimated_rent_branches
|
||||
else:
|
||||
estimated_rent_amount = self.env['rent.lines'].search(
|
||||
[('benefit_count', '=', rec.benefit_member_count)], order="estimated_rent_governorate desc",limit=1).estimated_rent_governorate
|
||||
rec.estimated_rent_amount = min(estimated_rent_amount, rec.rent_amount) / 12.0
|
||||
|
||||
def assign_sequence_to_all(self):
|
||||
sequence = self.env['ir.sequence'].search([('code', '=', 'benefit.sequence')], limit=1)
|
||||
if not sequence:
|
||||
|
|
@ -1130,19 +1144,20 @@ class GrantBenefitProfile(models.Model):
|
|||
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'
|
||||
rec.write({'mother_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 mini_income_for_mother < rec.mother_income <= max_income_for_mother:
|
||||
rec.mother_status = 'non_benefit'
|
||||
rec.write({'mother_status': 'non_benefit'})
|
||||
elif rec.mother_income <= mini_income_for_mother:
|
||||
rec.mother_status = 'benefit'
|
||||
rec.write({'mother_status': 'benefit'})
|
||||
elif rec.mother_income > max_income_for_mother:
|
||||
rec.mother_status = 'benefit'
|
||||
rec.write({'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'):
|
||||
rec.mother_status = 'benefit'
|
||||
rec.write({'mother_status': '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):
|
||||
|
|
@ -1769,6 +1784,7 @@ class GrantBenefitProfile(models.Model):
|
|||
|
||||
@api.depends(
|
||||
'expenses_ids',
|
||||
'estimated_rent_amount',
|
||||
'expenses_ids.deduct_from_family_income',
|
||||
'expenses_ids.amount',
|
||||
'family_debits_ids',
|
||||
|
|
@ -1786,20 +1802,17 @@ class GrantBenefitProfile(models.Model):
|
|||
total_expenses = sum(ben.expenses_ids.filtered(lambda e: e.deduct_from_family_income).mapped('amount'))
|
||||
elif ben.family_debits_ids and not ben.expenses_ids:
|
||||
total_expenses = sum(ben.family_debits_ids.filtered(lambda e: e.deduct_from_family_income).mapped('monthly_installment'))
|
||||
else:
|
||||
total_expenses = 0.0
|
||||
if followers:
|
||||
ben.followers_total = len(followers)
|
||||
if expenses:
|
||||
ben.expenses_total = len(expenses)
|
||||
ben.total_expenses = total_expenses
|
||||
ben.total_expenses = total_expenses + ben.estimated_rent_amount
|
||||
|
||||
@api.depends(
|
||||
'mother_income',
|
||||
'mother_status',
|
||||
'replacement_mother_income',
|
||||
'replacement_mother_status',
|
||||
'salary_ids',
|
||||
'salary_ids.salary_amount',
|
||||
'salary_ids.approved',
|
||||
)
|
||||
def get_total_income(self):
|
||||
|
|
@ -2076,6 +2089,11 @@ class GrantBenefitProfile(models.Model):
|
|||
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
|
||||
|
||||
|
|
@ -2405,11 +2423,10 @@ class GrantBenefitProfile(models.Model):
|
|||
@api.onchange('mother_marital_conf', 'mother_location_conf', 'mother_income')
|
||||
def _onchange_mother_info(self):
|
||||
res = {}
|
||||
for rec in self:
|
||||
if rec.mother_status == 'non_benefit':
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _('Not Benefit')}
|
||||
return res
|
||||
if self.mother_status == 'non_benefit':
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _('Not Benefit')}
|
||||
return res
|
||||
|
||||
@api.onchange('replacement_mother_marital_conf', 'replacement_mother_location_conf', 'replacement_mother_income')
|
||||
def _onchange_replacement_mother_info(self):
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ class Visit(models.Model):
|
|||
template.write({'email_to': self.benefit_id.email,
|
||||
'email_cc': self.env.user.company_id.hr_email or self.env.user.company_id.email,})
|
||||
email_values = {"email_from": self.env.user.company_id.hr_email or self.env.user.company_id.email}
|
||||
template.with_context(lang=self.env.user.lang,tracking_disable=True).send_mail(self.id, force_send=True,notif_layout=False,
|
||||
template.with_context(lang=self.env.user.lang,tracking_disable=True).send_mail(self.id, force_send=True,
|
||||
raise_exception=False,email_values=email_values)
|
||||
elif self.benefit_id.contact_type == 'sms':
|
||||
if not self.benefit_id.sms_phone:
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@
|
|||
<button name="complete_data" type="object"
|
||||
string="Researcher Assignment" class="oe_highlight"
|
||||
confirm="Are you sure you want to Researcher assignment ?"
|
||||
states="draft,new"
|
||||
states="new"
|
||||
groups="odex_benefit.group_benefit_manager,odex_benefit.group_benefit_branch_manager,odex_benefit.group_benefit_woman_commitee"/>
|
||||
<button name="finish_complete_data" type="object"
|
||||
string="Finish Complete" class="oe_highlight"
|
||||
|
|
@ -954,7 +954,7 @@
|
|||
<!-- <field name="gender" required="1"/>-->
|
||||
<field name="relationn"/>
|
||||
<field name="member_location_conf"/>
|
||||
<field name="member_status" string="Is Benefit?"/>
|
||||
<field name="member_status"/>
|
||||
<field name="age"/>
|
||||
<field name="benefit_id"/>
|
||||
<field name="state"/>
|
||||
|
|
@ -1159,11 +1159,11 @@
|
|||
</field>
|
||||
|
||||
<group class="oe_subtotal_footer oe_right">
|
||||
<label for="rent_amount"
|
||||
<label for="estimated_rent_amount"
|
||||
attrs="{'invisible':[('property_type','!=','rent'),('property_type','!=','rent_shared')]}"/>
|
||||
<field name="estimated_rent_amount" nolabel="1" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}" readonly="1" force_save="1"
|
||||
attrs="{'invisible':[('property_type','!=','rent'),('property_type','!=','rent_shared')]}"/>
|
||||
<field name="rent_amount" nolabel="1" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type','!=','rent'),('property_type','!=','rent_shared')]}"/>
|
||||
<label for="total_expenses"/>
|
||||
<field name="total_expenses" nolabel="1" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue