[IMP] odex_benefit: IMP benefit

This commit is contained in:
younes 2026-01-19 15:33:53 +01:00
parent 9e0935d67b
commit c74cb8f89d
4 changed files with 39 additions and 40 deletions

View File

@ -750,10 +750,6 @@ class GrantBenefitProfile(models.Model):
@api.depends('is_mother_work','mother_salary_ids','mother_expenses_ids','mother_debits_ids')
def _compute_mother_net_income(self):
for rec in self:
if not rec.is_mother_work:
rec.mother_net_income = 0.0
continue
deductions = (
sum(rec.mother_expenses_ids.filtered('deduct_from_family_income').mapped('amount')) +
sum(rec.mother_debits_ids.filtered('deduct_from_family_income').mapped('monthly_installment'))
@ -1424,30 +1420,28 @@ class GrantBenefitProfile(models.Model):
return status, reasons
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:
reasons = []
status = 'benefit'
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 in ['suspended_second_approve','refused']:
if rec.state in ['suspended_second_approve', 'refused']:
status = 'non_benefit'
reasons.append(_("The replacement mother's marital or location conditions are not eligible."))
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:
status = 'non_benefit'
reasons.append(_("The replacement mother's income is between minimum and maximum thresholds."))
elif rec.replacement_mother_income <= mini_income_for_mother:
status = 'benefit'
elif rec.replacement_mother_income > max_income_for_mother:
status = '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'):
status = 'benefit'
reasons.append(_("Family is suspended or refused."))
return status, reasons
if not rec.replacement_mother_marital_conf or not rec.replacement_mother_location_conf:
status = 'non_benefit'
reasons.append(_("Replacement mother marital or location information is missing."))
return status, reasons
if not rec.replacement_mother_marital_conf.replacement_mother_is_benefit:
status = 'non_benefit'
reasons.append(_("The replacement mother's marital status is not eligible for benefits."))
if not rec.replacement_mother_location_conf.replacement_mother_is_benefit:
status = 'non_benefit'
reasons.append(_("The replacement mother's location is not eligible for benefits."))
return status, reasons
def delete_from_db(self):
@ -2212,18 +2206,11 @@ class GrantBenefitProfile(models.Model):
for rec in self:
total = 0.0
rec.total_income = 0.0
if not rec.add_replacement_mother:
if rec.mother_status == 'non_benefit':
total = sum(rec.salary_ids.filtered(lambda e: e.approved).mapped('salary_amount'))
elif rec.mother_status == 'benefit':
total = sum(rec.salary_ids.filtered(lambda e: e.approved).mapped('salary_amount')) + rec.mother_income
rec.total_income = total
if rec.add_replacement_mother:
if rec.replacement_mother_status == 'non_benefit':
total = sum(rec.salary_ids.filtered(lambda e: e.approved).mapped('salary_amount'))
elif rec.replacement_mother_status == 'benefit':
total = sum(rec.salary_ids.filtered(lambda e: e.approved).mapped('salary_amount')) + rec.replacement_mother_income
rec.total_income += total
if rec.mother_status == 'non_benefit':
total = sum(rec.salary_ids.filtered(lambda e: e.approved).mapped('salary_amount'))
elif rec.mother_status == 'benefit':
total = sum(rec.salary_ids.filtered(lambda e: e.approved).mapped('salary_amount')) + rec.mother_income
rec.total_income = total
def get_mother_name(self):
for rec in self:
@ -2655,7 +2642,7 @@ class GrantBenefitProfile(models.Model):
'message': _('Not Benefit')}
return res
@api.onchange('replacement_mother_marital_conf', 'replacement_mother_location_conf', 'replacement_mother_income')
@api.onchange('replacement_mother_marital_conf', 'replacement_mother_location_conf')
def _onchange_replacement_mother_info(self):
res = {}
for rec in self:

View File

@ -806,6 +806,7 @@ class LocationSettings(models.Model):
location_type = fields.Selection([('member', _('Member')), ('mother_location', _('Mother Location'))])
is_benefit = fields.Boolean(string='Is Benefit?')
is_far_from_family = fields.Boolean(string='Is Far From Family?')
replacement_mother_is_benefit = fields.Boolean(string="Replacement Mother Is Benefit?", default=True, )
class AttachmentsSettings(models.Model):
_name = 'attachments.settings'
@ -897,6 +898,7 @@ class MaritalStatus(models.Model):
name = fields.Char(string="Name")
is_benefit = fields.Boolean(string='Is Benefit?')
is_dead = fields.Boolean(string='Is Dead?')
replacement_mother_is_benefit = fields.Boolean(string="Replacement Mother Is Benefit?",default=True,)
class AgeCategory(models.Model):
_name = 'age.category'

View File

@ -1016,9 +1016,13 @@
<group>
<field name="name"/>
<field name="location_type"/>
<field name="is_benefit"/>
<field name="is_far_from_family"/>
</group>
<group>
<field name="is_benefit"/>
<field name="replacement_mother_is_benefit"/>
</group>
</group>
</sheet>
</form>
@ -1033,6 +1037,7 @@
<field name="location_type"/>
<field name="is_benefit"/>
<field name="is_far_from_family"/>
<field name="replacement_mother_is_benefit"/>
</tree>
</field>
</record>
@ -1333,9 +1338,13 @@
<group>
<group>
<field name="name"/>
<field name="is_benefit"/>
<field name="is_dead"/>
</group>
<group>
<field name="is_benefit"/>
<field name="replacement_mother_is_benefit"/>
</group>
</group>
</sheet>
</form>
@ -1348,6 +1357,7 @@
<tree>
<field name="name"/>
<field name="is_benefit"/>
<field name="replacement_mother_is_benefit"/>
</tree>
</field>
</record>

View File

@ -909,7 +909,7 @@
</tree>
</field>
</page>
<page string="Mother Expenses" attrs="{'invisible':[('is_mother_work','=',False)]}">
<page string="Mother Expenses">
<field name="mother_expenses_ids" context="{'default_state': 'accepted'}"
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}">
<tree editable="top">
@ -929,7 +929,7 @@
</tree>
</field>
</page>
<page string="Mother Income" attrs="{'invisible':[('is_mother_work','=',False)]}">
<page string="Mother Income">
<field name="mother_salary_ids"
context="{'default_state': 'accepted','default_is_mother_salary': True}"
mode="tree"
@ -955,7 +955,7 @@
</tree>
</field>
</page>
<page string="Mother Debts" attrs="{'invisible':[('is_mother_work','=',False)]}">
<page string="Mother Debts">
<field name="mother_debits_ids" context="{'default_state': 'accepted'}"
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}">
<form>