Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add fulfillments to dashboard order details view

Anna Siwik0a1653c4e845
diff --git a/saleor/order/models.py b/saleor/order/models.py
index 1bd18a698c..22f10911ae 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -162,7 +162,7 @@ class Order(models.Model):
return dict(OrderStatus.CHOICES)[self.status]
def get_subtotal(self):
- subtotal_iterator = (line.get_total() for line in self.get_lines())
+ subtotal_iterator = (line.get_total() for line in self)
return sum(subtotal_iterator, ZERO_TAXED_MONEY)
def can_cancel(self):
diff --git a/templates/dashboard/order/detail.html b/templates/dashboard/order/detail.html
index ecb01a150a..614cafea06 100644
--- a/templates/dashboard/order/detail.html
+++ b/templates/dashboard/order/detail.html
@@ -126,14 +126,6 @@
{% endif %}
</p>
</div>
- <div class="col s12 m4 l12">
- <h6>
- {% trans "Order status" context "Order summary card header" %}
- </h6>
- <p>
- {% render_status order.status order.get_status_display %}
- </p>
- </div>
<div class="col s12 m4 l12">
<h6>
{% trans "Payment status" context "Order summary card header" %}
@@ -255,129 +247,109 @@
</div>
</div>
<div class="col s12 l8 switch-two-columns">
- {% for group in groups %}
- <div class="card shipment-table">
- <div class="data-table-header">
- <h5 class="data-table-title">
- {% blocktrans trimmed with shipment=group.id group_shipping_method_name=group.shipping_method_name context "Shipment group table title" %}
- Shipment #{{ shipment }} - {{ group_shipping_method_name }}
- {% endblocktrans %}
- </h5>
- {% render_status group.status group.get_status_display %}
- </div>
- <div class="data-table-container">
- <table class="bordered highlight responsive data-table">
- <thead>
- <tr>
- <th class="wide">
- {% trans "Item" context "Shipment group table header" %}
- </th>
- <th class="right-align">
- {% trans "Price" context "Shipment group table header" %}
- </th>
- <th class="right-align">
- {% trans "Quantity" context "Shipment group table header" %}
- </th>
- <th class="right-align">
- {% trans "Total" context "Shipment group table header" %}
- </th>
- </tr>
- </thead>
- <tbody>
- {% for line in group.lines.all %}
- <tr class="last-no-border">
- <td>
- {% if line.product %}
- <a href="{% url 'dashboard:product-detail' pk=line.product.pk %}">{{ line.product_name }}</a>
- {% else %}
- {{ line.product_name }}
- {% endif %}
- <br>
- <span class="grey-text">
- {% blocktrans trimmed with sku=line.product_sku context "Shipment group table text" %}
- SKU: {{ sku }}
- {% endblocktrans %}
- </span>
- </td>
- <td class="right-align">
- {{ line.unit_price.gross|amount:'html' }}
- </td>
- <td class="right-align">
- {% if group.can_edit_lines %}
- <a class="dropdown-button" href="#" data-activates="line-actions-{{ line.pk }}" data-constrainwidth="false">
- {{ line.quantity }} {% if line.stock_location and is_many_stock_locations %} ({{ line.stock_location|truncatechars:10 }}) {% endif %}
- <svg data-src="{% static "dashboard/images/arrow-drop-down.svg" %}" width="24" height="24" />
- </a>
- <ul id="line-actions-{{ line.pk }}" class="dropdown-content">
- <li>
- <a href="#base-modal" data-href="{% url 'dashboard:orderline-change-quantity' order_pk=order.pk line_pk=line.pk %}" class="modal-trigger-custom" title="{% trans "Change quantity" context "Shipment group table row action" %}">
- {% trans "Change quantity" context "Shipment group table row action" %}
- </a>
- </li>
- {% if is_many_stock_locations %}
- <li>
- <a href="#base-modal" data-href="{% url 'dashboard:orderline-change-stock' order_pk=order.pk line_pk=line.pk %}" class="modal-trigger-custom" title="{% trans "Change stock location" context "Shipment group table row action" %}">
- {% trans "Change stock" context "Shipment group table row action" %}
- </a>
- </li>
- {% endif %}
- <li>
- <a href="#base-modal" data-href="{% url 'dashboard:orderline-split' order_pk=order.pk line_pk=line.pk %}" class="modal-trigger-custom" title="{% trans "Split line" context "Shipment group table row action" %}">
- {% trans "Split order line" context "Shipment group table row action" %}
- </a>
- </li>
+ <div class="card shipment-table">
+ <div class="data-table-header">
+ <h5 class="data-table-title">
+ {% blocktrans trimmed with order=order.id context "Order table title" %}
+ Order #{{ order }}
+ {% endblocktrans %}
+ </h5>
+ {% render_status order.status order.get_status_display %}
+ </div>
+ <div class="data-table-container">
+ <table class="bordered highlight responsive data-table">
+ <thead>
+ <tr>
+ <th class="wide">
+ {% trans "Item" context "Order table header" %}
+ </th>
+ <th class="right-align">
+ {% trans "Price" context "Order table header" %}
+ </th>
+ <th class="right-align">
+ {% trans "Quantity" context "Order table header" %}
+ </th>
+ <th class="right-align">
+ {% trans "Total" context "Order table header" %}
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for line in order %}
+ <tr class="last-no-border">
+ <td>
+ {% if line.product %}
+ <a href="{% url 'dashboard:product-detail' pk=line.product.pk %}">{{ line.product_name }}</a>
+ {% else %}
+ {{ line.product_name }}
+ {% endif %}
+ <br>
+ <span class="grey-text">
+ {% blocktrans trimmed with sku=line.product_sku context "Order table text" %}
+ SKU: {{ sku }}
+ {% endblocktrans %}
+ </span>
+ </td>
+ <td class="right-align">
+ {{ line.unit_price.gross|amount:'html' }}
+ </td>
+ <td class="right-align">
+ {% if group.can_edit_lines %}
+ <a class="dropdown-button" href="#" data-activates="line-actions-{{ line.pk }}" data-constrainwidth="false">
+ {{ line.quantity }} {% if line.stock_location and is_many_stock_locations %} ({{ line.stock_location|truncatechars:10 }}) {% endif %}
+ <svg data-src="{% static "dashboard/images/arrow-drop-down.svg" %}" width="24" height="24" />
+ </a>
+ <ul id="line-actions-{{ line.pk }}" class="dropdown-content">
+ <li>
+ <a href="#base-modal" data-href="{% url 'dashboard:orderline-change-quantity' order_pk=order.pk line_pk=line.pk %}" class="modal-trigger-custom" title="{% trans "Change quantity" context "Order table row action" %}">
+ {% trans "Change quantity" context "Order table row action" %}
+ </a>
+ </li>
+ {% if is_many_stock_locations %}
<li>
- <a href="#base-modal" data-href="{% url 'dashboard:orderline-cancel' order_pk=order.pk line_pk=line.pk %}" class="modal-trigger-custom" title="{% trans "Remove line" context "Shipment group table row action" %}">
- {% trans "Remove line" context "Shipment group table row action" %}
+ <a href="#base-modal" data-href="{% url 'dashboard:orderline-change-stock' order_pk=order.pk line_pk=line.pk %}" class="modal-trigger-custom" title="{% trans "Change stock location" context "Order table row action" %}">
+ {% trans "Change stock" context "Order table row action" %}
</a>
</li>
- </ul>
- {% else %}
- {{ line.quantity }}
- {% endif %}
- </td>
- <td class="right-align">
- {{ line.get_total.gross|amount:'html' }}
- </td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- </div>
- {% if perms.order.edit_order %}
- {% if group.can_ship or group.can_cancel %}
- <div class="data-table-action">
- {% if group.can_ship %}
- <a href="#base-modal" data-href="{% url 'dashboard:ship-delivery-group' order_pk=order.pk group_pk=group.pk %}" class="btn-flat waves-effect modal-trigger-custom">
- {% trans "Dispatch" context "Shipment group table action" %}
- </a>
- {% endif %}
- {% if group.can_cancel %}
- <a href="#base-modal" data-href="{% url 'dashboard:cancel-delivery-group' order_pk=order.pk group_pk=group.pk %}" class="btn-flat waves-effect modal-trigger-custom" title="{% trans 'Cancel group' context 'Shipment group table action' %}">
- {% trans "Cancel shipment" context "Shipment group table action" %}
- </a>
- {% endif %}
- {% if group.can_edit_lines %}
- <a href="#base-modal" data-href="{% url 'dashboard:add-variant-to-group' order_pk=order.pk group_pk=group.pk %}" class="btn-flat waves-effect modal-trigger-custom" title="{% trans "Add product to order" context "Order summary card action title" %}">
- {% trans "Add product" context "Order summary card action" %}
- </a>
- {% endif %}
- <a href="{% url 'dashboard:order-packing-slips' group_pk=group.pk %}" data-href="" class="btn-flat waves-effect" target="_blank">
- {% trans "Packing Slips" context "Order detail action" %}
+ </ul>
+ {% else %}
+ {{ line.quantity }}
+ {% endif %}
+ </td>
+ <td class="right-align">
+ {{ line.get_total.gross|amount:'html' }}
+ </td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+ {% if perms.order.edit_order %}
+ {% if group.can_ship or group.can_cancel %}
+ <div class="data-table-action">
+ {% if group.can_ship %}
+ <a href="#base-modal" data-href="{% url 'dashboard:ship-delivery-group' order_pk=order.pk group_pk=group.pk %}" class="btn-flat waves-effect modal-trigger-custom">
+ {% trans "Dispatch" context "Shipment group table action" %}
</a>
- </div>
- {% endif %}
- {% endif %}
- {% if group.tracking_number %}
- <div class="card-action">
- {% blocktrans trimmed with tracking=group.tracking_number context "Shipment group table text" %}
- Tracking number: {{ tracking }}
- {% endblocktrans %}
+ {% endif %}
+ {% if group.can_cancel %}
+ <a href="#base-modal" data-href="{% url 'dashboard:cancel-delivery-group' order_pk=order.pk group_pk=group.pk %}" class="btn-flat waves-effect modal-trigger-custom" title="{% trans 'Cancel group' context 'Shipment group table action' %}">
+ {% trans "Cancel shipment" context "Shipment group table action" %}
+ </a>
+ {% endif %}
+ {% if group.can_edit_lines %}
+ <a href="#base-modal" data-href="{% url 'dashboard:add-variant-to-group' order_pk=order.pk group_pk=group.pk %}" class="btn-flat waves-effect modal-trigger-custom" title="{% trans "Add product to order" context "Order summary card action title" %}">
+ {% trans "Add product" context "Order summary card action" %}
+ </a>
+ {% endif %}
+ <a href="{% url 'dashboard:order-packing-slips' group_pk=group.pk %}" data-href="" class="btn-flat waves-effect" target="_blank">
+ {% trans "Packing Slips" context "Order detail action" %}
+ </a>
</div>
{% endif %}
- </div>
- {% endfor %}
- <div class="card" id="order-totals">
+ {% endif %}
+ </div>
+ <div class="card" id="order-totals">
<div class="data-table-container">
<table class="bordered highlight responsive data-table">
<tfoot>
@@ -434,6 +406,52 @@
</table>
</div>
</div>
+ {% for fulfillment in order.fulfillments.all %}
+ <div class="card shipment-table">
+ <div class="data-table-header">
+ <h5 class="data-table-title">
+ {% blocktrans trimmed with fulfillment=fulfillment.id context "Fulfillment table title" %}
+ Fulfillment #{{ fulfillment }}
+ {% endblocktrans %}
+ </h5>
+ </div>
+ <div class="data-table-container">
+ <table class="bordered highlight responsive data-table">
+ <thead>
+ <tr>
+ <th class="wide">
+ {% trans "Item" context "Shipment group table header" %}
+ </th>
+ <th class="right-align">
+ {% trans "Quantity" context "Shipment group table header" %}
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for line in fulfillment.lines.all %}
+ <tr class="last-no-border">
+ <td>
+ {{ line.order_line.product_name }}
+ </td>
+ <td class="right-align">
+ {{ line.quantity }}
+ </td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+ <div class="card-action">
+ {% if fulfillment.tracking_number %}
+ {% blocktrans trimmed with tracking=fulfillment.tracking_number context "Fulfillment table text" %}
+ Tracking number: {{ tracking }}
+ {% endblocktrans %}
+ {% else %}
+ {% trans "Tracking number: no tracking number" context "Fulfillment table text" %}
+ {% endif %}
+ </div>
+ </div>
+ {% endfor %}
<div class="card order-notes{% if not notes %} print-hide{% endif %}" id="order-notes">
<div class="card-content">
<span class="card-title black-text">