diff --git a/odex25_ensan/odex_takaful/models/donation_details_lines.py b/odex25_ensan/odex_takaful/models/donation_details_lines.py
index bf1f36d4a..ee84a3f7b 100644
--- a/odex25_ensan/odex_takaful/models/donation_details_lines.py
+++ b/odex25_ensan/odex_takaful/models/donation_details_lines.py
@@ -102,11 +102,42 @@ class DonationsDetailsLines(models.Model):
waiting_date = fields.Date(
string="تاريخ الانتظار",
)
-
+ actual_end_date = fields.Date(string="مدة الانتظار", compute='_compute_actual_end_date', store=True)
period_display = fields.Char(
string="Period",
compute="_compute_period_display" )
+ age_category = fields.Selection([
+ ('18', '+18'),
+ ('16', '+16'),
+ ('all', 'جميع الأعمار'),
+ ], string="الفئة العمرية", compute="_compute_age_category")
+
+ @api.depends('sponsorship_duration', 'payment_month_count', 'direct_debit')
+ def _compute_age_category(self):
+ for rec in self:
+ print( rec.sponsorship_duration , ' ' ,rec.direct_debit , ' ' , rec.payment_month_count)
+ if rec.sponsorship_duration == 'permanent':
+ rec.age_category = 'all'
+ elif rec.sponsorship_duration != 'permanent' :
+ if rec.direct_debit:
+ rec.age_category = '16'
+ elif rec.sponsorship_duration != 'permanent' and rec.payment_month_count >= 6:
+ rec.age_category = 'all'
+ elif rec.sponsorship_duration != 'permanent' and rec.payment_month_count < 6:
+ rec.age_category = '18'
+ else:
+ rec.age_category = 'all'
+
+ @api.depends('benefit_ids.end_date')
+ def _compute_actual_end_date(self):
+ for rec in self:
+ if rec.benefit_ids:
+ # take the first benefit record
+ first_benefit = rec.benefit_ids[0]
+ rec.actual_end_date = first_benefit.end_date
+ else:
+ rec.actual_end_date = False
@api.depends('end_date', 'waiting_date')
def _compute_period_display(self):
today = date.today()
@@ -879,7 +910,7 @@ class DonationsDetailsLines(models.Model):
record = super(DonationsDetailsLines, self).create(vals)
if record.benefit_ids == 1:
record.benefit_id = record.benefit_ids[0].id
-
+ print('Vals >>> ' , vals)
return record
def write(self, vals):
diff --git a/odex25_ensan/odex_takaful/models/takaful_sponorship_model.py b/odex25_ensan/odex_takaful/models/takaful_sponorship_model.py
index 381b6f98e..18f6e8898 100644
--- a/odex25_ensan/odex_takaful/models/takaful_sponorship_model.py
+++ b/odex25_ensan/odex_takaful/models/takaful_sponorship_model.py
@@ -810,7 +810,7 @@ class TakafulSponsorship(models.Model):
sponsor_donor_type = vals.get('sponsor_donor_type')
sponsor_id = vals.get('sponsor_id')
state = vals.get('state', 'draft')
-
+ print('Vals >>> ' , vals)
# Only validate when state is draft and saving (not during onchange)
if state == 'draft':
# Check for donation with new_sponsor
diff --git a/odex25_ensan/odex_takaful/views/donations_details_lines.xml b/odex25_ensan/odex_takaful/views/donations_details_lines.xml
index 1d9131163..ff32a550c 100644
--- a/odex25_ensan/odex_takaful/views/donations_details_lines.xml
+++ b/odex25_ensan/odex_takaful/views/donations_details_lines.xml
@@ -83,7 +83,7 @@
-
+
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+