[FIX]Add Domain on sponsership

This commit is contained in:
odoo-syria-team 2025-11-13 17:01:38 +03:00
parent 312caaec31
commit b5a42f2c64
1 changed files with 12 additions and 24 deletions

View File

@ -112,33 +112,21 @@ class DonationsDetailsLines(models.Model):
for rec in self:
x = []
records = self.env['donations.details.lines'].search(['|' , ('state', '=', 'replace') , ('state', '=', 'waiting')])
print('records >>> ' , records)
for i in records:
x.append(self.compute_donation_value(records))
for record in records:
if record.sponsorship_duration == 'permanent':
x.append(1)
elif record.sponsorship_duration != 'permanent' and record.payment_month_count > 6:
x.append(1)
elif record.sponsorship_duration != 'permanent' and record.payment_month_count < 6 and record.direct_debit:
x.append(16)
elif record.sponsorship_duration != 'permanent' and record.payment_month_count < 6:
x.append(18)
else:
x.append(1)
lowest_value = min(x) if x else None
rec.ages = lowest_value
def compute_donation_value(self , records):
"""
Loop through donation detail lines and return a number based on conditions:
- If sponsorship_duration == 'permanent' return 1
- Else if not permanent and payment_month_count > 6 return 1
- Else if not permanent and payment_month_count < 6 and direct_debit == True return 16
- Else if not permanent and payment_month_count < 6 return 18
- Else return 1
"""
for record in records:
if record.sponsorship_duration == 'permanent':
return 1
elif record.sponsorship_duration != 'permanent' and record.payment_month_count > 6:
return 1
elif record.sponsorship_duration != 'permanent' and record.payment_month_count < 6 and record.direct_debit:
return 16
elif record.sponsorship_duration != 'permanent' and record.payment_month_count < 6:
return 18
else:
return 1
return 1
@api.depends('extension_history_ids')
def _compute_extension_count(self):
for rec in self: