yk_dev_odex25_ensan
This commit is contained in:
parent
eef9d1a0e1
commit
3031aab616
|
|
@ -1753,7 +1753,6 @@ class GrantBenefitProfile(models.Model):
|
|||
|
||||
def get_total_income(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:
|
||||
|
|
@ -1764,13 +1763,15 @@ class GrantBenefitProfile(models.Model):
|
|||
total = 0.0
|
||||
existing_mother_salary = salary_ids.filtered(lambda x: x.is_mother_salary == True)
|
||||
should_have_salary_line = (status == 'benefit' and income > max_income_for_mother)
|
||||
income_type = self.env['attachments.settings'].search([('is_mother_salary','=',True)],limit=1)
|
||||
if should_have_salary_line:
|
||||
if not existing_mother_salary:
|
||||
salary_ids.create({
|
||||
'benefit_id': rec.id,
|
||||
'is_mother_salary': True,
|
||||
'salary_amount': income,
|
||||
'state': 'accepted',
|
||||
'income_type': income_type and income_type.id or False,
|
||||
'approved': True,
|
||||
})
|
||||
elif existing_mother_salary:
|
||||
existing_mother_salary.write({'salary_amount': income})
|
||||
|
|
@ -1778,11 +1779,11 @@ class GrantBenefitProfile(models.Model):
|
|||
if existing_mother_salary:
|
||||
existing_mother_salary.unlink()
|
||||
if status == 'non_benefit':
|
||||
total = sum(salary_ids.filtered(lambda e: e.state == 'accepted' and not e.is_mother_salary).mapped(
|
||||
total = sum(salary_ids.filtered(lambda e: e.approved and not e.is_mother_salary).mapped(
|
||||
'salary_amount'))
|
||||
elif status == 'benefit':
|
||||
total = sum(
|
||||
salary_ids.filtered(lambda e: e.state == 'accepted').mapped('salary_amount'))
|
||||
salary_ids.filtered(lambda e: e.approved).mapped('salary_amount'))
|
||||
return total
|
||||
if not rec.add_replacement_mother:
|
||||
# Calculate total income for mother
|
||||
|
|
@ -1792,6 +1793,10 @@ class GrantBenefitProfile(models.Model):
|
|||
rec.total_income += calculate_income(rec.replacement_mother_income, rec.replacement_mother_status,
|
||||
rec.salary_ids)
|
||||
|
||||
# total_income = mother_income + sum(approved salarys)
|
||||
# approved_salarys = fillter
|
||||
# mother_inocme = if replacement_mother : income else mother.income income > max
|
||||
|
||||
|
||||
def get_mother_name(self):
|
||||
for rec in self:
|
||||
|
|
@ -2030,22 +2035,11 @@ class GrantBenefitProfile(models.Model):
|
|||
else:
|
||||
ben.non_member_count = 0.0
|
||||
|
||||
@api.depends('salary_ids', 'expenses_ids', 'family_debits_ids.monthly_installment','mother_income','member_ids','family_debits_ids.state','expenses_ids.state','salary_ids.state')
|
||||
@api.depends('salary_ids', 'expenses_ids', 'family_debits_ids.monthly_installment','mother_income','replacement_mother_income','member_ids','family_debits_ids.state','expenses_ids.state','salary_ids.approved')
|
||||
def get_member_income(self):
|
||||
validation_setting = self.env["family.validation.setting"].search([], limit=1)
|
||||
# max_income_for_mother = validation_setting.max_income_for_mother
|
||||
# total = 0
|
||||
for ben in self:
|
||||
ben.get_total_income()
|
||||
ben.get_total_expenses()
|
||||
# if ben.mother_income >= max_income_for_mother and ben.family_debits_ids:
|
||||
# family_income = ben.total_income - ben.total_expenses
|
||||
# elif ben.mother_income >= max_income_for_mother:
|
||||
# family_income = ben.total_income - ben.total_expenses
|
||||
# elif ben.family_debits_ids:
|
||||
# family_income = ben.total_income - ben.total_expenses
|
||||
# else:
|
||||
# family_income = ben.total_income - ben.total_expenses
|
||||
family_income = ben.total_income - ben.total_expenses
|
||||
if ben.benefit_member_count:
|
||||
if ben.benefit_member_count > 3:
|
||||
|
|
|
|||
|
|
@ -291,6 +291,7 @@ class Salary(models.Model):
|
|||
|
||||
benefit_id = fields.Many2one(
|
||||
'grant.benefit')
|
||||
currency_id = fields.Many2one('res.currency', related='benefit_id.currency_id')
|
||||
salary_type = fields.Char()
|
||||
income_type = fields.Many2one('attachments.settings',string='Income Type',domain="[('attach_type','=','income_attach')]")
|
||||
salary_amount = fields.Float(
|
||||
|
|
@ -301,8 +302,9 @@ class Salary(models.Model):
|
|||
attach_end_date = fields.Date(string='Attach End Date')
|
||||
is_required = fields.Boolean(string='Is Required?')
|
||||
is_mother_salary = fields.Boolean(string="Is Mother Salary", default=False)
|
||||
approved = fields.Boolean(string="Is Approved", default=False)
|
||||
is_default = fields.Boolean(string='Is Default?')
|
||||
state = fields.Selection(string='Status',selection=[('waiting', 'Waiting'),('accepted', 'Accepted'),('refused', 'Refused')],default="waiting")
|
||||
state = fields.Selection(string='Status',selection=[('waiting', 'Waiting'),('accepted', 'Accepted'),('refused', 'Refused')],default="accepted")
|
||||
# total_salary = fields.Float(string="Total Salary", compute='_compute_total_salary',store=True)
|
||||
|
||||
# @api.depends('salary_amount','state')
|
||||
|
|
@ -758,6 +760,7 @@ class AttachmentsSettings(models.Model):
|
|||
family_appearance_seq = fields.Integer(string='Appearance Sequence')
|
||||
member_appearance_seq = fields.Integer(string='Appearance Sequence')
|
||||
income_appearance_seq = fields.Integer(string='Appearance Sequence')
|
||||
is_mother_salary = fields.Boolean(string="Is Mother Salary", default=False)
|
||||
|
||||
class EducationIlliterateReason(models.Model):
|
||||
_name = 'education.illiterate.reason'
|
||||
|
|
|
|||
|
|
@ -1046,6 +1046,7 @@
|
|||
<!-- <field name="hobby_id"/>-->
|
||||
<!-- <field name="diseases_id"/>-->
|
||||
<!-- <field name="disabilities_id"/>-->
|
||||
<field name="is_mother_salary"/>
|
||||
<field name="is_required"/>
|
||||
<field name="is_default"/>
|
||||
<field name="show_in_portal"/>
|
||||
|
|
|
|||
|
|
@ -273,7 +273,8 @@
|
|||
attrs="{'invisible': [('action_type', '!=', 'exception')]}"/>
|
||||
<div class="oe_title">
|
||||
<h1>
|
||||
<field name="code" class="oe_inline"/> -
|
||||
<field name="code" class="oe_inline"/>
|
||||
-
|
||||
<field placeholder="Name" name="name" class="oe_inline" readonly="1"
|
||||
force_save="1"/>
|
||||
</h1>
|
||||
|
|
@ -1083,14 +1084,17 @@
|
|||
<field name="benefit_id" invisible="1"/>
|
||||
<field name="income_type"
|
||||
options="{'no_create': True, 'no_create_edit': True,'no_quick_create': True, 'no_open': True}"/>
|
||||
<field name="is_mother_salary" readonly="1" force_save="1"/>
|
||||
<field name="salary_amount"/>
|
||||
<field name="is_mother_salary" invisible="1"/>
|
||||
<field name="salary_amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}" sum="Total Income"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="salary_attach" widget="many2many_attachment_preview"/>
|
||||
<field name="attach_start_date"/>
|
||||
<field name="attach_end_date"/>
|
||||
<field name="is_required" invisible="1"/>
|
||||
<field name="is_default" invisible="1"/>
|
||||
<field name="state" invisible="1"/>
|
||||
<field name="approved" widget="boolean_toggle"/>
|
||||
</tree>
|
||||
</field>
|
||||
<group>
|
||||
|
|
|
|||
Loading…
Reference in New Issue