Update membership_cancel_request.py

This commit is contained in:
zainab2097 2024-08-14 16:05:17 +03:00 committed by GitHub
parent 2448875654
commit a63a1012f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 0 deletions

View File

@ -20,6 +20,8 @@ class MembershipCancellationRequest(models.Model):
def action_approve(self):
for rec in self:
# Convert request_date to a date if it's a datetime
request_date = rec.request_date.date() if isinstance(rec.request_date, datetime) else rec.request_date
# Check if the request date is before the membership end date
if rec.request_date < rec.membership_id.to_date:
# Update the membership end date to the request date