This commit is contained in:
Abdurrahman Saber 2025-10-15 12:15:48 +03:00
parent 311c564a93
commit f7f982aa4b
1 changed files with 16 additions and 16 deletions

View File

@ -159,25 +159,25 @@ class AccountRegisterPayment(models.TransientModel):
current_line: donations.details.lines record (to exclude from search)
Returns: True if already sponsored, False otherwise
"""
if not beneficiary:
return False
# if not beneficiary:
# return False
# Search for other active sponsorships with this beneficiary
other_lines = self.env['donations.details.lines'].sudo().search([
'|', ('sponsorship_id', '!=', False), ('sponsorship_mechanism_id', '!=', False),
'|', ('benefit_id', '=', beneficiary.id), ('benefit_ids', 'in', [beneficiary.id]),
('donation_type', '=', 'sponsorship'),
('state', '=', 'active'), # Only check active sponsorships
('id', '!=', current_line.id) # Exclude current line
])
# # Search for other active sponsorships with this beneficiary
# other_lines = self.env['donations.details.lines'].sudo().search([
# '|', ('sponsorship_id', '!=', False), ('sponsorship_mechanism_id', '!=', False),
# '|', ('benefit_id', '=', beneficiary.id), ('benefit_ids', 'in', [beneficiary.id]),
# ('donation_type', '=', 'sponsorship'),
# ('state', '=', 'active'), # Only check active sponsorships
# ('id', '!=', current_line.id) # Exclude current line
# ])
# Check if any of these lines belong to paid sponsorships
for line in other_lines:
sponsorship = line.sponsorship_id or line.sponsorship_mechanism_id
if sponsorship and sponsorship.state == 'paid':
return True
# # Check if any of these lines belong to paid sponsorships
# for line in other_lines:
# sponsorship = line.sponsorship_id or line.sponsorship_mechanism_id
# if sponsorship and sponsorship.state == 'paid':
# return True
return False
return beneficiary.sponsor_related_id.id
def _create_payments(self):
sponsorship_line_ids = self.env.context.get('sponsorship_line_ids')