mirror of
https://github.com/inventree/InvenTree.git
synced 2025-10-21 08:27:38 +00:00
Allow adjument of build outputs (#10600)
* Auto-select location * Allow stock adjustments for "in production" items * Tweak stock move check * Allow splitting of production stock * Update CHANGELOG.md
This commit is contained in:
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Added ability to partially complete and partially scrap build outputs in [#10499](https://github.com/inventree/InvenTree/pull/10499)
|
||||
- Added support for Redis ACL user-based authentication in [#10551](https://github.com/inventree/InvenTree/pull/10551)
|
||||
- Expose stock adjustment forms to the UI plugin context in [#10584](https://github.com/inventree/InvenTree/pull/10584)
|
||||
- Allow stock adjustments for "in production" items in [#10600](https://github.com/inventree/InvenTree/pull/10600)
|
||||
|
||||
### Changed
|
||||
|
||||
|
@@ -1743,7 +1743,6 @@ class StockItem(
|
||||
self.belongs_to is None, # Not installed inside another StockItem
|
||||
self.customer is None, # Not assigned to a customer
|
||||
self.consumed_by is None, # Not consumed by a build
|
||||
not self.is_building, # Not part of an active build
|
||||
])
|
||||
|
||||
@property
|
||||
@@ -2221,7 +2220,6 @@ class StockItem(
|
||||
- The new item will have a different StockItem ID, while this will remain the same.
|
||||
"""
|
||||
# Run initial checks to test if the stock item can actually be "split"
|
||||
|
||||
allow_production = kwargs.get('allow_production', False)
|
||||
|
||||
# Cannot split a stock item which is in production
|
||||
@@ -2346,7 +2344,9 @@ class StockItem(
|
||||
'STOCK_ALLOW_OUT_OF_STOCK_TRANSFER', backup_value=False, cache=False
|
||||
)
|
||||
|
||||
if not allow_out_of_stock_transfer and not self.is_in_stock(check_status=False):
|
||||
if not allow_out_of_stock_transfer and not self.is_in_stock(
|
||||
check_status=False, check_in_production=False
|
||||
):
|
||||
raise ValidationError(_('StockItem cannot be moved as it is not in stock'))
|
||||
|
||||
if quantity <= 0:
|
||||
@@ -2362,7 +2362,7 @@ class StockItem(
|
||||
kwargs['notes'] = notes
|
||||
|
||||
# Split the existing StockItem in two
|
||||
self.splitStock(quantity, location, user, **kwargs)
|
||||
self.splitStock(quantity, location, user, allow_production=True, **kwargs)
|
||||
|
||||
return True
|
||||
|
||||
|
@@ -1602,7 +1602,7 @@ class StockAdjustmentItemSerializer(serializers.Serializer):
|
||||
)
|
||||
|
||||
if not allow_out_of_stock_transfer and not stock_item.is_in_stock(
|
||||
check_status=False, check_quantity=False
|
||||
check_status=False, check_quantity=False, check_in_production=False
|
||||
):
|
||||
raise ValidationError(_('Stock item is not in stock'))
|
||||
elif self.require_in_stock == False:
|
||||
|
@@ -712,6 +712,9 @@ function stockTransferFields(items: any[]): ApiFormFieldSet {
|
||||
|
||||
const records = Object.fromEntries(items.map((item) => [item.pk, item]));
|
||||
|
||||
// Extract all location values from the items
|
||||
const locations = [...new Set(items.map((item) => item.location))];
|
||||
|
||||
const fields: ApiFormFieldSet = {
|
||||
items: {
|
||||
field_type: 'table',
|
||||
@@ -740,6 +743,7 @@ function stockTransferFields(items: any[]): ApiFormFieldSet {
|
||||
]
|
||||
},
|
||||
location: {
|
||||
value: locations.length === 1 ? locations[0] : undefined,
|
||||
filters: {
|
||||
structural: false
|
||||
}
|
||||
|
Reference in New Issue
Block a user