diff --git a/odex25_ensan/odex_takaful/models/donation_details_lines.py b/odex25_ensan/odex_takaful/models/donation_details_lines.py
index 72aaa3834..e600b2a65 100644
--- a/odex25_ensan/odex_takaful/models/donation_details_lines.py
+++ b/odex25_ensan/odex_takaful/models/donation_details_lines.py
@@ -111,20 +111,26 @@ class DonationsDetailsLines(models.Model):
def _compute_get_age_range(self):
for rec in self:
x = []
- records = self.env['donations.details.lines'].search(['|' , ('state', '=', 'replace') , ('state', '=', 'waiting')])
- for record in records:
+ branch_id = rec.branch_custom_id.id
+ records = self.env['donations.details.lines'].search(['|' , ('state', '=', 'replace') , ('state', '=', 'waiting') ])
+ filtered_records = records.filtered(lambda r: r.sponsorship_mechanism_id.branch_custom_id.id == branch_id)
- if record.sponsorship_duration == 'permanent':
+ for record in filtered_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:
+ 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:
+ elif record.sponsorship_duration != 'permanent' and record.payment_month_count >= 6 :
x.append(1)
- lowest_value = min(x) if x else None
+ elif record.sponsorship_duration != 'permanent' and record.payment_month_count < 6 :
+ x.append(18)
+
+
+ if len(x) > 0 :
+ lowest_value = min(x) if x else None
+ else:
+ lowest_value = 100
+
rec.ages = lowest_value
@api.depends('extension_history_ids')
@@ -495,6 +501,7 @@ class DonationsDetailsLines(models.Model):
parent_record = self.env['takaful.sponsorship'].browse(parent_id)
res['sponsorship_creation_date'] = parent_record.sponsorship_creation_date
+ res['branch_custom_id'] = parent_record.branch_custom_id
# res['donation_mechanism'] = parent_record.donation_mechanism
self._onchange_sponsorship_type()
diff --git a/odex25_ensan/odex_takaful/views/takaful_sponorship_view.xml b/odex25_ensan/odex_takaful/views/takaful_sponorship_view.xml
index 847aeb512..56a65fc41 100644
--- a/odex25_ensan/odex_takaful/views/takaful_sponorship_view.xml
+++ b/odex25_ensan/odex_takaful/views/takaful_sponorship_view.xml
@@ -79,18 +79,18 @@