2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 03:00:54 +00:00

Mark a SalesOrder as "shipped"

- Option to hide non-stock items from stock list
- Update models with new feature
This commit is contained in:
Oliver Walters
2020-04-25 08:46:28 +10:00
parent c5b93e2392
commit b351976ae9
8 changed files with 73 additions and 12 deletions

View File

@ -363,8 +363,17 @@ class StockList(generics.ListCreateAPIView):
# Start with all objects
stock_list = super().filter_queryset(queryset)
# Filter out parts which are not actually "in stock"
stock_list = stock_list.filter(customer=None, belongs_to=None)
in_stock = self.request.query_params.get('in_stock', None)
if in_stock is not None:
in_stock = str2bool(in_stock)
if in_stock:
# Filter out parts which are not actually "in stock"
stock_list = stock_list.filter(customer=None, belongs_to=None)
else:
# Only show parts which are not in stock
stock_list = stock_list.exclude(customer=None, belongs_to=None)
# Filter by 'allocated' patrs?
allocated = self.request.query_params.get('allocated', None)
@ -418,7 +427,7 @@ class StockList(generics.ListCreateAPIView):
# Does the client wish to filter by stock location?
loc_id = self.request.query_params.get('location', None)
cascade = str2bool(self.request.query_params.get('cascade', False))
cascade = str2bool(self.request.query_params.get('cascade', True))
if loc_id is not None:

View File

@ -634,6 +634,8 @@ class StockItem(MPTTModel):
# Remove the specified quantity from THIS stock item
self.take_stock(quantity, user, 'Split {n} items into new stock item'.format(n=quantity))
# Return a copy of the "new" stock item
@transaction.atomic
def move(self, location, notes, user, **kwargs):
""" Move part to a new location.
@ -656,6 +658,9 @@ class StockItem(MPTTModel):
except InvalidOperation:
return False
if not self.in_stock:
raise ValidationError(_("StockItem cannot be moved as it is not in stock"))
if quantity <= 0:
return False

View File

@ -15,6 +15,12 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
{% block pre_content %}
{% include 'stock/loc_link.html' with location=item.location %}
{% if item.customer %}
<div class='alert alert-block alert-info'>
{% trans "This stock item has been sent to" %} <b><a href="{% url 'company-detail-sales-orders' item.customer.id %}">{{ item.customer.name }}</a></b>
</div>
{% endif %}
{% for allocation in item.sales_order_allocations.all %}
<div class='alert alert-block alert-info'>
{% trans "This stock item is allocated to Sales Order" %} <a href="{% url 'so-detail' allocation.line.order.id %}"><b>#{{ allocation.line.order.reference }}</b></a> ({% trans "Quantity" %}: {% decimal allocation.quantity %})