From b5a42f2c64e8d0c76fea4d09cb99bc1f49ee6ea7 Mon Sep 17 00:00:00 2001 From: odoo-syria-team Date: Thu, 13 Nov 2025 17:01:38 +0300 Subject: [PATCH] [FIX]Add Domain on sponsership --- .../models/donation_details_lines.py | 36 +++++++------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/odex25_ensan/odex_takaful/models/donation_details_lines.py b/odex25_ensan/odex_takaful/models/donation_details_lines.py index ccee360d6..72aaa3834 100644 --- a/odex25_ensan/odex_takaful/models/donation_details_lines.py +++ b/odex25_ensan/odex_takaful/models/donation_details_lines.py @@ -112,33 +112,21 @@ class DonationsDetailsLines(models.Model): for rec in self: x = [] records = self.env['donations.details.lines'].search(['|' , ('state', '=', 'replace') , ('state', '=', 'waiting')]) - print('records >>> ' , records) - for i in records: - x.append(self.compute_donation_value(records)) + for record in records: + + if record.sponsorship_duration == 'permanent': + x.append(1) + elif record.sponsorship_duration != 'permanent' and record.payment_month_count > 6: + x.append(1) + elif record.sponsorship_duration != 'permanent' and record.payment_month_count < 6 and record.direct_debit: + x.append(16) + elif record.sponsorship_duration != 'permanent' and record.payment_month_count < 6: + x.append(18) + else: + x.append(1) lowest_value = min(x) if x else None rec.ages = lowest_value - def compute_donation_value(self , records): - """ - Loop through donation detail lines and return a number based on conditions: - - If sponsorship_duration == 'permanent' → return 1 - - Else if not permanent and payment_month_count > 6 → return 1 - - Else if not permanent and payment_month_count < 6 and direct_debit == True → return 16 - - Else if not permanent and payment_month_count < 6 → return 18 - - Else → return 1 - """ - for record in records: - if record.sponsorship_duration == 'permanent': - return 1 - elif record.sponsorship_duration != 'permanent' and record.payment_month_count > 6: - return 1 - elif record.sponsorship_duration != 'permanent' and record.payment_month_count < 6 and record.direct_debit: - return 16 - elif record.sponsorship_duration != 'permanent' and record.payment_month_count < 6: - return 18 - else: - return 1 - return 1 @api.depends('extension_history_ids') def _compute_extension_count(self): for rec in self: