Make VM order-able again

This commit is contained in:
fnux 2020-04-18 13:51:31 +02:00
commit d794b24c86
5 changed files with 70 additions and 34 deletions

View file

@ -636,6 +636,20 @@ class Order(models.Model):
def bills(self):
return Bill.objects.filter(order=self)
@staticmethod
def from_product(product, **kwargs):
# FIXME: this is only a workaround.
billing_address = BillingAddress.get_preferred_address_for(product.owner)
if billing_address == None:
raise Exception("Owner does not have a billing address!")
return Order(description=product.description,
one_time_price=product.one_time_price,
recurring_price=product.recurring_price,
billing_address=billing_address,
owner=product.owner,
**kwargs)
def __str__(self):
return "Order {} created at {}, {}->{}, recurring period {}. One time price {}, recurring price {}".format(
self.uuid, self.creation_date,