commit
c7567b9e81
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Reference in New Issue