Benefit customization
This commit is contained in:
parent
74430127f9
commit
44c09c89b4
|
|
@ -20,7 +20,7 @@ class GrantBenefitProfile(models.Model):
|
|||
_description = "Benefits - Profiles"
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||
_inherits = {'res.partner': 'partner_id'}
|
||||
_order = 'code'
|
||||
_order = 'code desc'
|
||||
def get_url(self):
|
||||
return "wwww"
|
||||
|
||||
|
|
@ -1288,16 +1288,11 @@ class GrantBenefitProfile(models.Model):
|
|||
expenses = ben.env['expenses.line'].sudo().search([('benefit_id', '=', ben.id)])
|
||||
total_expenses = 0.0
|
||||
if ben.expenses_ids and ben.family_debits_ids:
|
||||
for expenses in ben.expenses_ids:
|
||||
total_expenses += expenses.amount
|
||||
for debit in ben.family_debits_ids:
|
||||
total_expenses += debit.loan_remaining
|
||||
total_expenses = sum(ben.expenses_ids.filtered(lambda e: e.state == 'accepted').mapped('amount')) + sum(ben.family_debits_ids.filtered(lambda e: e.state == 'accepted').mapped('monthly_installment'))
|
||||
elif ben.expenses_ids and not ben.family_debits_ids:
|
||||
for expenses in ben.expenses_ids:
|
||||
total_expenses += expenses.amount
|
||||
total_expenses = sum(ben.expenses_ids.filtered(lambda e: e.state == 'accepted').mapped('amount'))
|
||||
elif ben.family_debits_ids and not ben.expenses_ids:
|
||||
for debit in ben.family_debits_ids:
|
||||
total_expenses += debit.loan_remaining
|
||||
total_expenses = sum(ben.family_debits_ids.filtered(lambda e: e.state == 'accepted').mapped('monthly_installment'))
|
||||
else:
|
||||
total_expenses = 0.0
|
||||
for rec in ben:
|
||||
|
|
@ -1314,26 +1309,29 @@ class GrantBenefitProfile(models.Model):
|
|||
mini_income_for_mother = validation_setting.mini_income_for_mother
|
||||
for rec in self:
|
||||
rec.total_income = 0.0
|
||||
# TODO : add the income resource
|
||||
# rec.total_income = rec.insurance_amount + rec.salary_amount + rec.commercial_record_amount + rec.treatment_amount + rec.treatment_amount_country_Monthly + rec.disability_amount
|
||||
if rec.salary_ids and rec.mother_status == 'non_benefit':
|
||||
for amount in rec.salary_ids:
|
||||
rec.total_income += amount.salary_amount
|
||||
elif rec.mother_status == 'benefit' and not rec.salary_ids:
|
||||
if rec.mother_income > mini_income_for_mother:
|
||||
rec.total_income = rec.mother_income
|
||||
else:
|
||||
rec.total_income = 0.0
|
||||
elif rec.salary_ids and rec.mother_status == 'benefit':
|
||||
if rec.mother_income > mini_income_for_mother:
|
||||
for amount in rec.salary_ids:
|
||||
rec.total_income += amount.salary_amount
|
||||
rec.total_income += rec.mother_income
|
||||
else:
|
||||
for amount in rec.salary_ids:
|
||||
rec.total_income += amount.salary_amount
|
||||
else:
|
||||
rec.total_income = 0.0
|
||||
|
||||
# Helper function to calculate income based on mother/replacement_mother status and salary_ids
|
||||
def calculate_income(income, status, salary_ids):
|
||||
total = 0.0
|
||||
accepted_salaries = sum(salary_ids.filtered(lambda e: e.state == 'accepted').mapped('salary_amount'))
|
||||
|
||||
if status == 'non_benefit':
|
||||
total = accepted_salaries
|
||||
elif status == 'benefit':
|
||||
if not salary_ids:
|
||||
total = income if income > mini_income_for_mother else 0.0
|
||||
else:
|
||||
total = accepted_salaries + (income if income > mini_income_for_mother else 0.0)
|
||||
return total
|
||||
if not rec.add_replacement_mother:
|
||||
# Calculate total income for mother
|
||||
rec.total_income = calculate_income(rec.mother_income, rec.mother_status, rec.salary_ids)
|
||||
if rec.add_replacement_mother:
|
||||
# Calculate total income for replacement mother if applicable
|
||||
rec.total_income += calculate_income(rec.replacement_mother_income, rec.replacement_mother_status,
|
||||
rec.salary_ids)
|
||||
|
||||
|
||||
|
||||
def get_mother_name(self):
|
||||
for rec in self:
|
||||
|
|
@ -1563,7 +1561,7 @@ class GrantBenefitProfile(models.Model):
|
|||
else:
|
||||
ben.non_member_count = 0.0
|
||||
|
||||
@api.depends('salary_ids', 'expenses_ids', 'family_debits_ids','mother_income','benefit_member_count')
|
||||
@api.depends('salary_ids', 'expenses_ids', 'family_debits_ids','mother_income','member_ids')
|
||||
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
|
||||
|
|
|
|||
|
|
@ -423,7 +423,13 @@ class ExpensesLine(models.Model):
|
|||
required=False, )
|
||||
amount = fields.Float()
|
||||
note = fields.Char()
|
||||
state = fields.Selection(string='Status', selection=[('accepted', 'Accepted'), ('refused', 'Refused')])
|
||||
|
||||
def action_accept(self):
|
||||
self.state = 'accepted'
|
||||
|
||||
def action_refuse(self):
|
||||
self.state = 'refused'
|
||||
|
||||
class EntityRefuseReason(models.Model):
|
||||
_name = 'entity.refuse_reason'
|
||||
|
|
@ -607,6 +613,7 @@ class RelationSettings(models.Model):
|
|||
class AttachmentsSettings(models.Model):
|
||||
_name = 'attachments.settings'
|
||||
_description = "Attachments Settings"
|
||||
_order = 'family_appearance_seq,member_appearance_seq asc'
|
||||
|
||||
name = fields.Char(string='name')
|
||||
hobby_id = fields.Many2one('hobbies.settings',string='Hobbies')
|
||||
|
|
@ -617,6 +624,8 @@ class AttachmentsSettings(models.Model):
|
|||
('diseases_attach', _('Diseases Attach')), ('disabilities_attach', _('Disabilities Attach')), ('income_attach', _('Income Attach'))])
|
||||
is_required = fields.Boolean(string='Is Required?')
|
||||
is_default = fields.Boolean(string='Is Default?')
|
||||
family_appearance_seq = fields.Integer(string='Appearance Sequence')
|
||||
member_appearance_seq = fields.Integer(string='Appearance Sequence')
|
||||
|
||||
class EducationIlliterateReason(models.Model):
|
||||
_name = 'education.illiterate.reason'
|
||||
|
|
|
|||
|
|
@ -21,6 +21,13 @@ class FamilyDebits(models.Model):
|
|||
benefit_id = fields.Many2one("grant.benefit")
|
||||
loan_attach = fields.Binary(attachment=True,string='Loan Attach')
|
||||
description = fields.Char(string='Description')
|
||||
state = fields.Selection(string='Status', selection=[('accepted', 'Accepted'), ('refused', 'Refused')])
|
||||
|
||||
def action_accept(self):
|
||||
self.state = 'accepted'
|
||||
|
||||
def action_refuse(self):
|
||||
self.state = 'refused'
|
||||
|
||||
@api.depends('loan_amount','loan_total_paid')
|
||||
def _compute_loan_remaining(self):
|
||||
|
|
|
|||
|
|
@ -994,6 +994,8 @@
|
|||
<group>
|
||||
<field name="name"/>
|
||||
<field name="attach_type"/>
|
||||
<field name="family_appearance_seq" attrs="{'invisible':[('attach_type','=','member_attach')]}"/>
|
||||
<field name="member_appearance_seq" attrs="{'invisible':[('attach_type','=','family_attach')]}"/>
|
||||
<!-- <field name="hobby_id"/>-->
|
||||
<!-- <field name="diseases_id"/>-->
|
||||
<!-- <field name="disabilities_id"/>-->
|
||||
|
|
|
|||
|
|
@ -818,38 +818,14 @@
|
|||
<tree>
|
||||
<field name="loan_giver"/>
|
||||
<field name="loan_amount"/>
|
||||
<button name="action_accept" type="object" string="Accept" class="oe_highlight" attrs="{'invisible':[('state','=','accepted')]}" groups="odex_benefit.group_benefit_manager"/>
|
||||
<button name="action_refuse" type="object" string="Refuse" class="oe_highlight" attrs="{'invisible':[('state','=','refused')]}" groups="odex_benefit.group_benefit_manager"/>
|
||||
<field name="state" readonly="1" force_save="1" widget="badge" decoration-success="state in ['accepted']" decoration-danger="state in ['refused']"/>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
</page>
|
||||
<page string="expenses">
|
||||
<!-- <group>-->
|
||||
<!-- <field name="expenses_request_ids">-->
|
||||
<!-- <tree editable="top">-->
|
||||
<!-- <field name="name"/>-->
|
||||
<!-- <field name="benefit_id" invisible="1"/>-->
|
||||
<!-- <field name="expenses_type"/>-->
|
||||
<!-- <field name="expenses_fees_type"/>-->
|
||||
<!-- <field name="amount" sum="amount"/>-->
|
||||
<!-- <field name="medicine_type"-->
|
||||
<!-- attrs="{'invisible': [('expenses_type', '!=', 'medical')]}"/>-->
|
||||
<!-- <field name="diseases_type"-->
|
||||
<!-- attrs="{'invisible': [('expenses_type', '!=', 'medical')]}"/>-->
|
||||
<!-- <field name="trans_type"-->
|
||||
<!-- attrs="{'invisible': [('expenses_type', '!=', 'transportation')]}"/>-->
|
||||
<!-- <field name="debt_type"-->
|
||||
<!-- attrs="{'invisible': [('expenses_type', '!=', 'debts')]}"/>-->
|
||||
<!-- <field name="debt_reason"-->
|
||||
<!-- attrs="{'invisible': [('expenses_type', '!=', 'debts')]}"/>-->
|
||||
<!-- <field name="attach"/>-->
|
||||
<!-- <button name="action_accepted" type="object"-->
|
||||
<!-- string="Accept" class="oe_highlight"-->
|
||||
<!-- confirm="Are you sure you want to accept ?"-->
|
||||
<!-- states="draft"/>-->
|
||||
<!-- <field name="state" invisible="1"/>-->
|
||||
<!-- </tree>-->
|
||||
<!-- </field>-->
|
||||
<!-- </group>-->
|
||||
<group>
|
||||
<field name="expenses_ids" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}">
|
||||
<tree editable="top">
|
||||
|
|
@ -858,6 +834,9 @@
|
|||
<field name="expenses_type_custom"/>
|
||||
<field name="note"/>
|
||||
<field name="amount" sum="amount"/>
|
||||
<button name="action_accept" type="object" string="Accept" class="oe_highlight" attrs="{'invisible':[('state','=','accepted')]}" groups="odex_benefit.group_benefit_manager"/>
|
||||
<button name="action_refuse" type="object" string="Refuse" class="oe_highlight" attrs="{'invisible':[('state','=','refused')]}" groups="odex_benefit.group_benefit_manager"/>
|
||||
<field name="state" readonly="1" force_save="1" widget="badge" decoration-success="state in ['accepted']" decoration-danger="state in ['refused']"/>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
|
|
@ -871,9 +850,9 @@
|
|||
<field name="salary_attach" widget="many2many_attachment_preview"/>
|
||||
<field name="attach_start_date"/>
|
||||
<field name="attach_end_date"/>
|
||||
<button name="action_accept" type="object" string="Accept" class="oe_highlight" attrs="{'invisible':[('state','=','accepted')]}"/>
|
||||
<button name="action_refuse" type="object" string="Refuse" class="oe_highlight" attrs="{'invisible':[('state','=','refused')]}"/>
|
||||
<field name="state" readonly="1" force_save="1"/>
|
||||
<button name="action_accept" type="object" string="Accept" class="oe_highlight" attrs="{'invisible':[('state','=','accepted')]}" groups="odex_benefit.group_benefit_manager"/>
|
||||
<button name="action_refuse" type="object" string="Refuse" class="oe_highlight" attrs="{'invisible':[('state','=','refused')]}" groups="odex_benefit.group_benefit_manager"/>
|
||||
<field name="state" readonly="1" force_save="1" widget="badge" decoration-success="state in ['accepted']" decoration-danger="state in ['refused']"/>
|
||||
<field name="is_required" invisible="1"/>
|
||||
<field name="is_default" invisible="1"/>
|
||||
</tree>
|
||||
|
|
@ -1027,6 +1006,7 @@
|
|||
<tree editable="bottom" delete="0">
|
||||
<field name="name" attrs="{'readonly':[('is_default','=',True)]}" force_save="1"/>
|
||||
<field name="datas"/>
|
||||
<!-- <field name="datas_attachments_ids" widget="many2many_attachment_preview"/>-->
|
||||
<field name="expiration_date"/>
|
||||
<field name="attach_status"/>
|
||||
<field name="allow_days"/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue