Make VM order-able again
This commit is contained in:
parent
df059fb00d
commit
d794b24c86
5 changed files with 70 additions and 34 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue