Merge pull request #5971 from expsa/14.0-fix-odex_takaful-auto-20260104_205554

[FIX] odex_takaful: improve data models and business logic
This commit is contained in:
Mohamed Eltayar 2026-01-04 20:56:25 +03:00 committed by GitHub
commit 453706622b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 5 deletions

View File

@ -721,7 +721,6 @@ class DonationsDetailsLines(models.Model):
@api.depends('family_id','record_type')
def _compute_family_domain_ids(self):
for rec in self:
domain = []
if rec.record_type == 'donation':
domain = [
'|',
@ -729,9 +728,11 @@ class DonationsDetailsLines(models.Model):
'&',
('state', 'in', ('waiting_approve', 'first_approve')),
('action_type', '=', 'suspended')]
family = self.env['grant.benefit'].sudo().search(domain)
rec.family_domain_ids = [(6, 0, family.ids)] if family else False
family = self.env['grant.benefit'].sudo().search(domain)
rec.family_domain_ids = [(6, 0, family.ids)] if family else False
else:
# No family selection needed for sponsorships or other types
rec.family_domain_ids = False
@api.depends('gender',
'record_type',
@ -839,8 +840,13 @@ class DonationsDetailsLines(models.Model):
elif rec.record_type == 'donation' and rec.donation_mechanism == "with_conditions" and rec.family_id:
domain = [("benefit_id", "=", rec.family_id.id)]
members = self.env['family.member'].sudo().search(domain)
else:
# No beneficiary selection needed (e.g., unconditional donations, waqf)
# Return empty recordset to avoid loading all records - fixes browser hang
rec.members_domain_ids = self.env['family.member'].sudo().browse()
continue
members = self.env['family.member'].sudo().search(domain)
rec.members_domain_ids = members if members else self.env['family.member'].sudo().browse()