Skip to content

Commit

Permalink
Merge pull request #524 from bruecksen/523-price-not-added-to-a-posit…
Browse files Browse the repository at this point in the history
…ion-if-it-gets-added-through-an-admin

Add price and price total on save of order position
  • Loading branch information
bruecksen authored Nov 8, 2024
2 parents 52a0c01 + ba36b0a commit b8bf2d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions bakeup/shop/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,13 @@ class Meta:
def __str__(self):
return "{}x {}".format(self.quantity, self.product)

def save(self, *args, **kwargs):
if not self.price and self.product.sale_price:
self.price = self.product.sale_price.price.amount
if self.price and self.quantity:
self.price_total = self.price * self.quantity
super().save(*args, **kwargs)

def get_product(self):
if self.product.product_template:
return self.product.product_template
Expand Down
4 changes: 2 additions & 2 deletions bakeup/templates/tables/customer_order_positions_column.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ul class="list-unstyled">
<ul class="list-unstyled mb-0">
{% for position in record.positions.all %}
<li>{{ position.quantity}} x {{ position.product }}{% if record.price_total %} {{ position.price_total }}{% endif %}</li>
<li class="text-nowrap">{{ position.quantity}} x {{ position.product }}{% if position.price_total %} {{ position.price_total }}{% endif %}</li>
{% endfor %}
</ul>

0 comments on commit b8bf2d3

Please sign in to comment.