Add shipment status to order list
This commit is contained in:
parent
0bf982e7f8
commit
ed3c93418c
@ -49,6 +49,18 @@ class OrderStatus:
|
||||
]
|
||||
|
||||
|
||||
class ShippingStatus:
|
||||
NOT_SHIPPED = 'Not shipped'
|
||||
PARTIALLY_SHIPPED = 'Partially shipped'
|
||||
SHIPPED = 'Shipped'
|
||||
|
||||
CHOICES = [
|
||||
(NOT_SHIPPED, 'Not shipped'),
|
||||
(PARTIALLY_SHIPPED, 'Partially shipped'),
|
||||
(SHIPPED, 'Shipped'),
|
||||
]
|
||||
|
||||
|
||||
class TransactionStatus:
|
||||
# The order was created with the specified context.
|
||||
CREATED = 'CREATED'
|
||||
|
||||
@ -24,6 +24,7 @@ from . import (
|
||||
VoucherType,
|
||||
TransactionStatus,
|
||||
OrderStatus,
|
||||
ShippingStatus,
|
||||
ShippingProvider,
|
||||
ShippingContainer
|
||||
)
|
||||
@ -397,6 +398,15 @@ class Order(models.Model):
|
||||
|
||||
objects = OrderManager()
|
||||
|
||||
def get_shipping_status(self):
|
||||
has_tracking = self.tracking_numbers.count() > 0
|
||||
if has_tracking and self.status == OrderStatus.FULFILLED:
|
||||
return ShippingStatus.SHIPPED
|
||||
elif has_tracking and self.status == OrderStatus.PARTIALLY_FULFILLED:
|
||||
return ShippingStatus.PARTIALLY_SHIPPED
|
||||
|
||||
return ShippingStatus.NOT_SHIPPED
|
||||
|
||||
def minus_stock(self):
|
||||
for line in self.lines.all():
|
||||
line.minus_stock()
|
||||
|
||||
@ -3,7 +3,8 @@
|
||||
<th>Order No.</th>
|
||||
<th>Date</th>
|
||||
<th>Customer</th>
|
||||
<th>Status</th>
|
||||
<th>Fulfillment</th>
|
||||
<th>Shipping</th>
|
||||
<th>Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -18,6 +19,17 @@
|
||||
<span class="status-dot status-{{order.status}}"></span> {{order.get_status_display}}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="status-display">
|
||||
{% if order.get_shipping_status == "Shipped" %}
|
||||
<span class="status-dot status-success"></span> {{ order.get_shipping_status }}
|
||||
{% elif order.get_shipping_status == "Partially shipped" %}
|
||||
<span class="status-dot status-warning"></span> {{ order.get_shipping_status }}
|
||||
{% else %}
|
||||
<span class="status-dot status-info"></span> {{ order.get_shipping_status }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
<td>${{order.total_amount}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user