diff --git a/odex25_ensan/odex_benefit/models/benefit.py b/odex25_ensan/odex_benefit/models/benefit.py
index 5b4688d9f..9403e518a 100644
--- a/odex25_ensan/odex_benefit/models/benefit.py
+++ b/odex25_ensan/odex_benefit/models/benefit.py
@@ -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
diff --git a/odex25_ensan/odex_benefit/models/benefit_config.py b/odex25_ensan/odex_benefit/models/benefit_config.py
index 68f55c2de..1c22175de 100644
--- a/odex25_ensan/odex_benefit/models/benefit_config.py
+++ b/odex25_ensan/odex_benefit/models/benefit_config.py
@@ -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'
diff --git a/odex25_ensan/odex_benefit/models/family_debits.py b/odex25_ensan/odex_benefit/models/family_debits.py
index 20b3271df..fc413c6b6 100644
--- a/odex25_ensan/odex_benefit/models/family_debits.py
+++ b/odex25_ensan/odex_benefit/models/family_debits.py
@@ -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):
diff --git a/odex25_ensan/odex_benefit/views/benefit_config_view.xml b/odex25_ensan/odex_benefit/views/benefit_config_view.xml
index f48c8fc35..a3422caae 100644
--- a/odex25_ensan/odex_benefit/views/benefit_config_view.xml
+++ b/odex25_ensan/odex_benefit/views/benefit_config_view.xml
@@ -994,6 +994,8 @@
+
+
diff --git a/odex25_ensan/odex_benefit/views/benefit_view.xml b/odex25_ensan/odex_benefit/views/benefit_view.xml
index a8b5ad2ee..8c6b189be 100644
--- a/odex25_ensan/odex_benefit/views/benefit_view.xml
+++ b/odex25_ensan/odex_benefit/views/benefit_view.xml
@@ -818,38 +818,14 @@
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -858,6 +834,9 @@
+
+
+
@@ -871,9 +850,9 @@
-
-
-
+
+
+
@@ -1027,6 +1006,7 @@
+