Compare commits

...

11 Commits

Author SHA1 Message Date
github-actions[bot]
1c4362c42a Prevent div-by-zero error (#4967) (#4968)
- Div-by-zero could occur when calculating how many items can be built for a part
- Might result if (somehow) the BomItem has a quantity of zero

(cherry picked from commit d8965c6c2b)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
2023-06-05 13:49:39 +10:00
github-actions[bot]
5b6d999091 Fix for 'available' filter (#4952) (#4954)
- Available filter also requires "in stock"

(cherry picked from commit c0dafe155f)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
2023-06-02 17:06:09 +10:00
Miklós Márton
970714a76f Fix completeSalesOrderShipment typo in sales_order.js (#4908) 2023-05-27 17:38:14 +10:00
Oliver Walters
59214cacbf Bump version to 0.11.3 2023-05-27 17:37:43 +10:00
Oliver
4868194a0b Fix for PurchaseOrder template (#4891)
- Fixes bug which removes javascript incorrectly
2023-05-25 09:39:55 +10:00
Oliver
53e442f555 Sales order fix backport (#4879)
* Bump version to 0.11.2

* Fix for sales order tables (#4753)

- Allow line items to be allocated after partial shipment
- Fixes https://github.com/inventree/InvenTree/issues/4734
2023-05-24 00:38:00 +10:00
Oliver
9f6d860554 Bump version to 0.11.2 (#4878) 2023-05-24 00:37:40 +10:00
Oliver
a1908f1bf1 Fix "New Sales Order" button (#4832) 2023-05-17 14:48:31 +10:00
Oliver
c29e58aeaa Bug fix for zero quantity pricing (#4766)
- Fix default value for formatPriceRange method
- Display empty value in table

(cherry picked from commit 07d9c2264e)
2023-05-05 22:40:20 +10:00
Oliver
fdaf6d3e19 Implement pagination for stock history tracking API (#4631)
* Bump version number to 0.11.1

* Implement pagination for stock history tracking API

(cherry picked from commit 75696770c6)
2023-04-19 07:09:08 +10:00
Oliver
78badcd65b Bump version number to 0.11.1 (#4630) 2023-04-18 22:56:35 +10:00
8 changed files with 33 additions and 12 deletions

View File

@@ -13,7 +13,7 @@ import common.models
from InvenTree.api_version import INVENTREE_API_VERSION
# InvenTree software version
INVENTREE_SW_VERSION = "0.11.0"
INVENTREE_SW_VERSION = "0.11.3"
def inventreeInstanceName():

View File

@@ -390,7 +390,7 @@
});
{% endif %}
{% if roles.salse_order.add %}
{% if roles.sales_order.add %}
$("#new-sales-order").click(function() {
createSalesOrder({

View File

@@ -130,6 +130,7 @@
{% endblock page_content %}
{% block js_ready %}
{% settings_value "PURCHASEORDER_EDIT_COMPLETED_ORDERS" as allow_extra_editing %}
{{ block.super }}
@@ -174,7 +175,7 @@
filterkey: "postock"
});
{% if order.status == PurchaseOrderStatus.PENDING %}
{% if order.is_open or allow_extra_editing %}
$('#new-po-line').click(function() {
createPurchaseOrderLineItem({{ order.pk }}, {

View File

@@ -1293,6 +1293,11 @@ class Part(InvenTreeBarcodeMixin, MetadataMixin, MPTTModel):
)
for item in queryset.all():
if item.quantity <= 0:
# Ignore zero-quantity items
continue
# Iterate through each item in the queryset, work out the limiting quantity
quantity = item.available_stock + item.substitute_stock

View File

@@ -434,7 +434,8 @@ class StockFilter(rest_filters.FilterSet):
"""
if str2bool(value):
# The 'quantity' field is greater than the calculated 'allocated' field
return queryset.filter(Q(quantity__gt=F('allocated')))
# Note that the item must also be "in stock"
return queryset.filter(StockItem.IN_STOCK_FILTER).filter(Q(quantity__gt=F('allocated')))
else:
# The 'quantity' field is less than (or equal to) the calculated 'allocated' field
return queryset.filter(Q(quantity__lte=F('allocated')))
@@ -1188,7 +1189,12 @@ class StockTrackingList(ListAPI):
"""List all stock tracking entries."""
queryset = self.filter_queryset(self.get_queryset())
serializer = self.get_serializer(queryset, many=True)
page = self.paginate_queryset(queryset)
if page is not None:
serializer = self.get_serializer(page, many=True)
else:
serializer = self.get_serializer(queryset, many=True)
data = serializer.data
@@ -1262,6 +1268,8 @@ class StockTrackingList(ListAPI):
except Exception:
pass
if page is not None:
return self.get_paginated_response(data)
if request.is_ajax():
return JsonResponse(data, safe=False)
else:

View File

@@ -76,7 +76,11 @@ function formatPriceRange(price_min, price_max, options={}) {
var p_min = price_min || price_max;
var p_max = price_max || price_min;
var quantity = options.quantity || 1;
var quantity = 1;
if ('quantity' in options) {
quantity = options.quantity;
}
if (p_min == null && p_max == null) {
return null;

View File

@@ -379,7 +379,7 @@ function completePendingShipments(order_id, options={}) {
*/
function completePendingShipmentsHelper(shipments, shipment_idx, options={}) {
if (shipment_idx < shipments.length) {
completeSalseOrderShipment(shipments[shipment_idx].pk,
completeSalesOrderShipment(shipments[shipment_idx].pk,
{
buttons: [
{
@@ -1056,9 +1056,8 @@ function allocateStockToSalesOrder(order_id, line_items, options={}) {
var table_entries = '';
for (var idx = 0; idx < line_items.length; idx++ ) {
var line_item = line_items[idx];
var remaining = 0;
let line_item = line_items[idx];
let remaining = Math.max(0, line_item.quantity - line_item.allocated);
table_entries += renderLineItemRow(line_item, remaining);
}
@@ -1225,7 +1224,7 @@ function allocateStockToSalesOrder(order_id, line_items, options={}) {
var available = Math.max((data.quantity || 0) - (data.allocated || 0), 0);
// Remaining quantity to be allocated?
var remaining = Math.max(line_item.quantity - line_item.shipped - line_item.allocated, 0);
var remaining = Math.max(line_item.quantity - line_item.allocated, 0);
// Maximum amount that we need
var desired = Math.min(available, remaining);
@@ -1892,7 +1891,7 @@ function loadSalesOrderLineItemTable(table, options={}) {
if (row.part && row.part_detail) {
let part = row.part_detail;
if (options.allow_edit && !row.shipped) {
if (options.allow_edit && (row.shipped < row.quantity)) {
if (part.trackable) {
buttons += makeIconButton('fa-hashtag icon-green', 'button-add-by-sn', pk, '{% trans "Allocate serial numbers" %}');
}

View File

@@ -2063,6 +2063,10 @@ function loadStockTable(table, options) {
currency = baseCurrency();
}
if (row.quantity <= 0) {
return '-';
}
return formatPriceRange(
min_price,
max_price,