From 266b5dac7ae88c15e716f9713c17f975f806cb96 Mon Sep 17 00:00:00 2001 From: younes Date: Sun, 16 Nov 2025 11:15:52 +0100 Subject: [PATCH 1/2] [IMP] odex_benefit: IMP benefit --- .../odex_benefit/models/family_expense.py | 35 ++-- .../views/family_expense_view.xml | 182 +++++++++++++++--- 2 files changed, 168 insertions(+), 49 deletions(-) diff --git a/odex25_ensan/odex_benefit/models/family_expense.py b/odex25_ensan/odex_benefit/models/family_expense.py index 3e36d2052..25ffee136 100644 --- a/odex25_ensan/odex_benefit/models/family_expense.py +++ b/odex25_ensan/odex_benefit/models/family_expense.py @@ -47,9 +47,12 @@ class ConfirmBenefitExpense(models.Model): copy=False) benefit_expense_line_ids = fields.One2many(comodel_name='benefit.expense.line', inverse_name='confirm_expense_id', string='Benefit Expense Lines') - cash_expense = fields.Boolean(string='Include Cash Expense', states={'confirm': [('readonly', True)]}) - meal_expense = fields.Boolean(string='Include Meal Expense', states={'confirm': [('readonly', True)]}) - cloth_expense = fields.Boolean(string='Include Clothing Expense', states={'confirm': [('readonly', True)]}) + othaim_line_ids = fields.One2many(comodel_name='benefit.expense.line', inverse_name='confirm_expense_id', + string='Othaim Lines', domain=[('meal_card', '=', True)]) + cash_expense = fields.Boolean(string='Include Cash Expense', default=True, states={'confirm': [('readonly', True)]}) + meal_expense = fields.Boolean(string='Include Meal Expense', default=True, states={'confirm': [('readonly', True)]}) + cloth_expense = fields.Boolean(string='Include Clothing Expense', default=True, + states={'confirm': [('readonly', True)]}) payment_order_id = fields.Many2one('payment.orders', string='Payment Order', ondelete="set null", copy=False) move_id = fields.Many2one('account.move', ondelete='cascade') available_payment_method_line_ids = fields.Many2many(comodel_name='account.payment.method.line') @@ -152,7 +155,6 @@ class ConfirmBenefitExpense(models.Model): if not families: raise UserError(_("Please select at least one family to calculate.")) - # Todo ask awatif if not rec.cash_expense and not rec.meal_expense and not rec.cloth_expense: raise UserError(_("At least one expense type should be selected.")) @@ -239,25 +241,12 @@ class ConfirmBenefitExpense(models.Model): rec.member_count_othaim = sum(othaim_lines.mapped('benefit_member_count')) def action_assistant_manager(self): - # Todo ask awatif - # if self.expense_type != 'family_expense': - # self.state = 'assistant_general_manager' - # return - - disbursement_date = False - # if not disbursement_date: - last_expense = self.search( - [("state", "=", "confirm"), ("end_date", "!=", False)], - order="id desc", - limit=1 - ) - if last_expense: - disbursement_date = last_expense.end_date - - # Apply the disbursement date to all families - if disbursement_date: - for family in self.family_ids: - family.last_disbursement_date = disbursement_date + for family in self.family_ids: + if self.end_date and family.last_disbursement_date: + if self.end_date > family.last_disbursement_date: + family.last_disbursement_date = self.end_date + else: + family.last_disbursement_date = self.end_date self.state = 'assistant_general_manager' diff --git a/odex25_ensan/odex_benefit/views/family_expense_view.xml b/odex25_ensan/odex_benefit/views/family_expense_view.xml index 32c081c51..2b13c7ff4 100644 --- a/odex25_ensan/odex_benefit/views/family_expense_view.xml +++ b/odex25_ensan/odex_benefit/views/family_expense_view.xml @@ -9,7 +9,6 @@ - @@ -136,37 +135,111 @@ attrs="{'readonly':[('state', '!=', 'draft')]}"/> - - - - - - - - - - - - - - - - +
+ +
+
+ + Family Count (Monthly Expense) + + + + +
+
+ + +
+
+ + Member Count (Monthly Expense) + + + + +
+
+
+
+
+
+
+
+
+ + Total Monthly Income + + + + +
+
+ + +
+
+ + Total Monthly Meals + + + + +
+
+ + +
+
+ + Total Monthly Clothing + + + + +
+
+ + +
+
+ + Total + + + +
+
+
+
+
+
@@ -183,6 +256,63 @@ + + + +
+ +
+ +
+
+ + Family Count (Othaim) + + + +
+
+ + +
+
+ + Member Count (Othaim) + + + +
+
+ + +
+
+ + Total Othaim + + + +
+
+
+ + + + + + + + + From 876a690120bf9474ed43be087bb24967c8f86f4e Mon Sep 17 00:00:00 2001 From: younes Date: Sun, 16 Nov 2025 11:41:51 +0100 Subject: [PATCH 2/2] [IMP] odex_benefit: IMP benefit --- .../odex_benefit/models/family_expense.py | 5 +- .../views/family_expense_view.xml | 113 +++++++++--------- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/odex25_ensan/odex_benefit/models/family_expense.py b/odex25_ensan/odex_benefit/models/family_expense.py index 25ffee136..052bfce6f 100644 --- a/odex25_ensan/odex_benefit/models/family_expense.py +++ b/odex25_ensan/odex_benefit/models/family_expense.py @@ -121,7 +121,7 @@ class ConfirmBenefitExpense(models.Model): self.ensure_one() for line in self.benefit_expense_line_ids: family = line.family_id - income, meals, clotting = 0, 0, 0 + income, meals, clotting, othaim = 0, 0, 0 if not family: continue monthly_meals = 0.0 if family.meal_card else family.family_monthly_meals @@ -130,6 +130,7 @@ class ConfirmBenefitExpense(models.Model): income = family.family_monthly_income if self.meal_expense: meals = monthly_meals + othaim = othaime if self.cloth_expense: clotting = family.family_monthly_clotting vals = { @@ -142,7 +143,7 @@ class ConfirmBenefitExpense(models.Model): 'family_monthly_income': income, 'family_monthly_meals': meals, 'family_monthly_clotting': clotting, - 'family_monthly_othaime': othaime, + 'family_monthly_othaime': othaim, } line.write(vals) diff --git a/odex25_ensan/odex_benefit/views/family_expense_view.xml b/odex25_ensan/odex_benefit/views/family_expense_view.xml index 2b13c7ff4..85f527ba1 100644 --- a/odex25_ensan/odex_benefit/views/family_expense_view.xml +++ b/odex25_ensan/odex_benefit/views/family_expense_view.xml @@ -173,68 +173,66 @@
-
-
-
-
- - Total Monthly Income - - - - -
+
+
+
+ + Total Monthly Income + + + +
+
- -
-
- - Total Monthly Meals - - - - -
+ +
+
+ + Total Monthly Meals + + + +
+
- -
-
- - Total Monthly Clothing - - - - -
+ +
+
+ + Total Monthly Clothing + + + +
+
- -
-
- - Total - - - -
+ +
+
+ + Total + + +
@@ -260,7 +258,8 @@ - +