Update dev_membership.py

This commit is contained in:
zainab2097 2024-09-29 16:31:05 +03:00 committed by GitHub
parent 753bd3c466
commit 1353e5e790
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 14 deletions

View File

@ -113,7 +113,6 @@ class DevMembership(models.Model):
raise ValidationError(
_("You already have a membership from '%s' to '%s' !!!!") % (membership.from_date, membership.to_date))
@api.onchange('from_date', 'product_id', 'duration','interval')
def onchange_from_date(self):
if self.from_date and self.product_id:
@ -123,22 +122,23 @@ 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.product_id.nationality_ids:
if self.partner_id.nationality_id not in self.product_id.nationality_ids:
raise ValidationError(_("The member's nationality does not meet the membership requirements"))
if self.product_id.age > 0 and self.partner_id.age < self.product_id.age:
raise ValidationError(_('The member must be at least %s years old.')%self.product_id.age)
raise ValidationError(_('The member must be at least %s years old.') % self.product_id.age)
if self.product_id.max_age > 0 and self.partner_id.age > self.product_id.max_age:
raise ValidationError(_('The member must not be more than %s years old.') % self.product_id.max_age)
if self.product_id.gender and self.partner_id.gender != self.product_id.gender :
if self.product_id.gender and self.partner_id.gender != self.product_id.gender:
raise ValidationError(_('Membership is only %s allowed') % self.product_id.gender)
if record.membership_fees < (record.product_id.list_price * record.duration ):
raise ValidationError(_("Membership fees cannot be less than %s .") % (record.product_id.list_price* record.duration,))
if record.duration < record.product_id.duration:
raise ValidationError(_("Duration cannot be less than the default value in Setting of membrship type.%s'") % record.product_id.duration)
if record.membership_fees < (record.product_id.list_price * record.duration):
raise ValidationError(
_("Membership fees cannot be less than %s .") % (record.product_id.list_price * record.duration,))
if record.duration < record.product_id.duration:
raise ValidationError(
_("Duration cannot be less than the default value in Setting of membrship type.%s'") % record.product_id.duration)
self.state = 'confirm'
def action_active_membership(self):