mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-01 04:56:45 +00:00
More stuff:
- Pass tracking number through when completing a shipment - Reload tables automatically when certain actions are performed - Limit stock items to only those with available stock
This commit is contained in:
parent
d5ace1a8da
commit
e74e7138a9
@ -956,7 +956,7 @@ class SalesOrderShipment(models.Model):
|
|||||||
raise ValidationError(_("Shipment has no allocated stock items"))
|
raise ValidationError(_("Shipment has no allocated stock items"))
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def complete_shipment(self, user):
|
def complete_shipment(self, user, **kwargs):
|
||||||
"""
|
"""
|
||||||
Complete this particular shipment:
|
Complete this particular shipment:
|
||||||
|
|
||||||
@ -979,6 +979,13 @@ class SalesOrderShipment(models.Model):
|
|||||||
# Update the "shipment" date
|
# Update the "shipment" date
|
||||||
self.shipment_date = datetime.now()
|
self.shipment_date = datetime.now()
|
||||||
self.shipped_by = user
|
self.shipped_by = user
|
||||||
|
|
||||||
|
# Was a tracking number provided?
|
||||||
|
tracking_number = kwargs.get('tracking_number', None)
|
||||||
|
|
||||||
|
if tracking_number is not None:
|
||||||
|
self.tracking_number = tracking_number
|
||||||
|
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
# Finally, check if the order is fully shipped
|
# Finally, check if the order is fully shipped
|
||||||
|
@ -654,7 +654,10 @@ class SalesOrderShipmentCompleteSerializer(serializers.ModelSerializer):
|
|||||||
request = self.context['request']
|
request = self.context['request']
|
||||||
user = request.user
|
user = request.user
|
||||||
|
|
||||||
shipment.complete_shipment(user)
|
# Extract provided tracking number (optional)
|
||||||
|
tracking_number = data.get('tracking_number', None)
|
||||||
|
|
||||||
|
shipment.complete_shipment(user, tracking_number=tracking_number)
|
||||||
|
|
||||||
|
|
||||||
class SOShipmentAllocationItemSerializer(serializers.Serializer):
|
class SOShipmentAllocationItemSerializer(serializers.Serializer):
|
||||||
|
@ -67,7 +67,10 @@ function completeShipment(shipment_id) {
|
|||||||
confirm: true,
|
confirm: true,
|
||||||
confirmMessage: '{% trans "Confirm Shipment" %}',
|
confirmMessage: '{% trans "Confirm Shipment" %}',
|
||||||
onSuccess: function(data) {
|
onSuccess: function(data) {
|
||||||
// TODO
|
// Reload tables
|
||||||
|
$('#so-lines-table').bootstrapTable('refresh');
|
||||||
|
$('#pending-shipments-table').bootstrapTable('refresh');
|
||||||
|
$('#completed-shipments-table').bootstrapTable('refresh');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1249,7 +1252,9 @@ function loadSalesOrderShipmentTable(table, options={}) {
|
|||||||
|
|
||||||
html += makeIconButton('fa-edit icon-blue', 'button-shipment-edit', pk, '{% trans "Edit shipment" %}');
|
html += makeIconButton('fa-edit icon-blue', 'button-shipment-edit', pk, '{% trans "Edit shipment" %}');
|
||||||
|
|
||||||
html += makeIconButton('fa-truck icon-green', 'button-shipment-ship', pk, '{% trans "Complete shipment" %}');
|
if (!options.shipped) {
|
||||||
|
html += makeIconButton('fa-truck icon-green', 'button-shipment-ship', pk, '{% trans "Complete shipment" %}');
|
||||||
|
}
|
||||||
|
|
||||||
html += `</div>`;
|
html += `</div>`;
|
||||||
|
|
||||||
@ -1300,7 +1305,10 @@ function loadSalesOrderShipmentTable(table, options={}) {
|
|||||||
onPostBody: function() {
|
onPostBody: function() {
|
||||||
setupShipmentCallbacks();
|
setupShipmentCallbacks();
|
||||||
|
|
||||||
$(table).bootstrapTable('expandAllRows');
|
// Auto-expand rows on the "pending" table
|
||||||
|
if (!options.shipped) {
|
||||||
|
$(table).bootstrapTable('expandAllRows');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
formatNoMatches: function() {
|
formatNoMatches: function() {
|
||||||
return '{% trans "No matching shipments found" %}';
|
return '{% trans "No matching shipments found" %}';
|
||||||
@ -1557,6 +1565,7 @@ function allocateStockToSalesOrder(order_id, line_items, options={}) {
|
|||||||
in_stock: true,
|
in_stock: true,
|
||||||
part_detail: true,
|
part_detail: true,
|
||||||
location_detail: true,
|
location_detail: true,
|
||||||
|
available: true,
|
||||||
},
|
},
|
||||||
model: 'stockitem',
|
model: 'stockitem',
|
||||||
required: true,
|
required: true,
|
||||||
@ -2296,7 +2305,11 @@ function loadSalesOrderLineItemTable(table, options={}) {
|
|||||||
],
|
],
|
||||||
{
|
{
|
||||||
success: function() {
|
success: function() {
|
||||||
|
// Reload this table
|
||||||
$(table).bootstrapTable('refresh');
|
$(table).bootstrapTable('refresh');
|
||||||
|
|
||||||
|
// Reload the pending shipment table
|
||||||
|
$('#pending-shipments-table').bootstrapTable('refresh');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -1282,7 +1282,7 @@ function loadStockTable(table, options) {
|
|||||||
if (row.serial != null && row.quantity == 1) {
|
if (row.serial != null && row.quantity == 1) {
|
||||||
html += makeIconBadge('fa-bookmark icon-yellow', '{% trans "Serialized stock item has been allocated" %}');
|
html += makeIconBadge('fa-bookmark icon-yellow', '{% trans "Serialized stock item has been allocated" %}');
|
||||||
} else if (row.allocated >= row.quantity) {
|
} else if (row.allocated >= row.quantity) {
|
||||||
html += makeIconBadge('fa-bookmark icon-red', '{% trans "Stock item has been fully allocated" %}');
|
html += makeIconBadge('fa-bookmark icon-yellow', '{% trans "Stock item has been fully allocated" %}');
|
||||||
} else {
|
} else {
|
||||||
html += makeIconBadge('fa-bookmark', '{% trans "Stock item has been partially allocated" %}');
|
html += makeIconBadge('fa-bookmark', '{% trans "Stock item has been partially allocated" %}');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user