Update membership_cancel_request.py

This commit is contained in:
zainab2097 2024-08-14 14:08:20 +03:00 committed by GitHub
parent 0a50771ba1
commit 48b4cbf58b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 0 deletions

View File

@ -20,6 +20,10 @@ class MembershipCancellationRequest(models.Model):
def action_approve(self):
for rec in self:
# Check if the request date is before the membership end date
if rec.request_date < rec.membership_id.membership_end_date:
# Update the membership end date to the request date
rec.membership_id.membership_end_date = rec.request_date
rec.state = 'approved'
rec.membership_id.state = 'cancel'