Update dev_membership.py

This commit is contained in:
zainab2097 2024-08-04 11:50:36 +03:00 committed by GitHub
parent 4637cc186f
commit 038ed43f3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 4 deletions

View File

@ -143,15 +143,18 @@ class DevMembership(models.Model):
self.to_date = self.from_date + relativedelta(months=+self.duration) - relativedelta(days=1)
elif self.interval == 'days':
self.to_date = self.from_date + relativedelta(days=+self.duration)
def action_confirm_membership(self):
if self.partner_id.nationality_id not in self.product_id.nationality_ids and self.prodcut_id.nationality_ids!=False:
if self.partner_id.nationality_id not in self.product_id.nationality_ids and self.product_id.nationality_ids != False:
raise ValidationError(_("The member's nationality does not meet the membership requirements"))
if self.partner_id.age <18:
if self.partner_id.age < 18:
raise ValidationError(_('The member must be at least 18 years old.'))
if self.partner_id.gender != self.product_id.gender and self.product_id.gender!=False:
if self.partner_id.gender != self.product_id.gender and self.product_id.gender != False:
raise ValidationError(_('Membership is only allowed for %s') % self.product_id.gender)
self.state = 'confirm'
def action_active_membership(self):
if not self.invoice_id and not self.is_free: