diff --git a/uncloud_pay/models.py b/uncloud_pay/models.py index 8023bf7..4005908 100644 --- a/uncloud_pay/models.py +++ b/uncloud_pay/models.py @@ -645,18 +645,20 @@ class Product(UncloudModel): if not recurring_period: recurring_period = self.default_recurring_period - one_time_order = None if self.one_time_price > 0: one_time_order = Order.objects.create(owner=self.owner, - billing_address=billing_address, - starting_date=when_to_start, - price=self.one_time_price, - recurring_period=RecurringPeriod.ONE_TIME, - description=str(self)) - + billing_address=billing_address, + starting_date=when_to_start, + price=self.one_time_price, + recurring_period=RecurringPeriod.ONE_TIME, + description=str(self)) + else: + one_time_order = None if recurring_period != RecurringPeriod.ONE_TIME: + print("not one time") + if one_time_order: recurring_order = Order.objects.create(owner=self.owner, billing_address=billing_address, @@ -699,12 +701,13 @@ class Product(UncloudModel): self.order = new_order - def save(self, *args, **kwargs): - # Create order if there is none already - if not self.order: - self.create_or_update_order() +# def save(self, *args, **kwargs): + # if not self.order: + # raise ValidationError("Cannot create product without order") - super().save(*args, **kwargs) +# self.create_or_update_order() + +# super().save(*args, **kwargs) @property def recurring_price(self):