diff --git a/odex25_takaful/odex_takaful/models/donation_details_lines.py b/odex25_takaful/odex_takaful/models/donation_details_lines.py
index 1b8d6d7cb..39b810c54 100644
--- a/odex25_takaful/odex_takaful/models/donation_details_lines.py
+++ b/odex25_takaful/odex_takaful/models/donation_details_lines.py
@@ -126,6 +126,13 @@ class DonationsDetailsLines(models.Model):
compute="_compute_direct_debit_filter", store=True,
)
+
+ @api.onchange('family_id')
+ def onchange_family_id(self):
+ for rec in self:
+ rec.benefit_ids = False
+
+
@api.depends('benefit_id.diseases_attachment_ids')
def _compute_get_diseases(self):
for rec in self:
diff --git a/odex25_takaful/odex_takaful/models/res_partner.py b/odex25_takaful/odex_takaful/models/res_partner.py
index 45528c43b..4fab42fa0 100644
--- a/odex25_takaful/odex_takaful/models/res_partner.py
+++ b/odex25_takaful/odex_takaful/models/res_partner.py
@@ -102,13 +102,30 @@ class ResPartner(models.Model):
)
kafel_state = fields.Selection([
('active', "Active"),
- ('not_active', "Not Active")] ,string='Status')
+ ('not_active', "Not Active")] ,string='Status' , compute="get_sponser_state", store=True)
_sql_constraints = [
('id_number_uniq', 'unique (id_number)', 'The ID Number Already Exist!'),
]
+
+ @api.depends('donation_line_ids.state', 'donation_line_ids.sponsorship_duration')
+ def get_sponser_state(self):
+ for rec in self:
+ state = 'not_active'
+ if rec.donation_line_ids:
+ for line in rec.donation_line_ids:
+ # permanent sponsorship → active if not in draft/closed/cancel
+ if line.sponsorship_duration == 'permanent' and line.state not in ['draft', 'closed', 'cancel']:
+ state = 'active'
+ break
+ # temporary sponsorship → active if state is active
+ if line.state == 'active':
+ state = 'active'
+ break
+ rec.kafel_state = state
+
def view_sponsorship_payment_action(self):
"""Enable The Sponsor To Pay Sponsorships Entries"""
sponsorship_id = self.env['takaful.sponsorship'].sudo().search([('sponsor_id', '=', self.id), ('has_delay', '=', True)], limit=1)
@@ -350,10 +367,10 @@ class ResPartner(models.Model):
if self.kafel_id:
self.kafel_id.login = vals['mobile']
- if 'mobile' in vals and self.mobile != False:
+ if 'mobile' in vals and self.mobile == False:
kafeel = self.env['res.users'].with_user(2).create({
'name' : self.name,
- 'branch_custom_id':self.branch_custom_id.id or vals['branch_custom_id'],
+ 'branch_custom_id':vals['branch_custom_id'] if 'branch_custom_id' in vals else self.branch_custom_id.id ,
'sel_groups_1_9_10' : 9,
'partner_id' : self.id,
'login' : vals['mobile'],
diff --git a/odex25_takaful/odex_takaful/models/takaful_sponorship_model.py b/odex25_takaful/odex_takaful/models/takaful_sponorship_model.py
index 2094bbc9d..1279b68fa 100644
--- a/odex25_takaful/odex_takaful/models/takaful_sponorship_model.py
+++ b/odex25_takaful/odex_takaful/models/takaful_sponorship_model.py
@@ -212,7 +212,7 @@ class TakafulSponsorship(models.Model):
context['default_sponsor_name'] = rec.sponsor_id.first_name
context['default_mobile'] = rec.sponsor_id.mobile
context['default_id_num'] = rec.sponsor_id.id_number
- context['default_payment_ids'] = rec.payment_ids.ids
+ # context['default_payment_ids'] = rec.payment_ids.ids
view = self.env.ref('odex_takaful.view_esterdad_wizard_form')
return {
'name': _('Sponsorship Cancellation'),
diff --git a/odex25_takaful/odex_takaful/security/security_data.xml b/odex25_takaful/odex_takaful/security/security_data.xml
index 151409c35..63cc10460 100644
--- a/odex25_takaful/odex_takaful/security/security_data.xml
+++ b/odex25_takaful/odex_takaful/security/security_data.xml
@@ -213,7 +213,7 @@
Responsible Users can access related Sponsorships
- [('create_uid','=',user.id)]
+ [('branch_custom_id.branch', 'child_of', user.employee_id.department_id.id)]
@@ -226,7 +226,7 @@
Users can access related Donations Details Lines
- [(1,'=',1)]
+ [('branch_custom_id.branch', 'child_of', user.employee_id.department_id.id)]
diff --git a/odex25_takaful/odex_takaful/views/takaful_sponorship_view.xml b/odex25_takaful/odex_takaful/views/takaful_sponorship_view.xml
index d297b1efc..eaceef98c 100644
--- a/odex25_takaful/odex_takaful/views/takaful_sponorship_view.xml
+++ b/odex25_takaful/odex_takaful/views/takaful_sponorship_view.xml
@@ -348,13 +348,12 @@
+ attrs="{'required': [('direct_debit', '=', True)], 'invisible': [('direct_debit', '=', False)]}"/>
-
diff --git a/odex25_takaful/odex_takaful/views/takaful_sponsor_view.xml b/odex25_takaful/odex_takaful/views/takaful_sponsor_view.xml
index 195aec927..85e3efda2 100644
--- a/odex25_takaful/odex_takaful/views/takaful_sponsor_view.xml
+++ b/odex25_takaful/odex_takaful/views/takaful_sponsor_view.xml
@@ -126,6 +126,7 @@
+