mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fix stock location structural check (#4089)
* Fix stock location structural check Exclude sub stock location items from preventing that a stock location can be switched to structural. * Fix structural check on both storage location and parts category Exclude children of sub- locations/categories in the check to allow this location/category to be structural
This commit is contained in:
parent
fdc4a46b26
commit
14a2c128a9
@ -148,7 +148,7 @@ class PartCategory(MetadataMixin, InvenTreeTree):
|
||||
|
||||
- Ensure that the structural parameter cannot get set if products already assigned to the category
|
||||
"""
|
||||
if self.pk and self.structural and self.item_count > 0:
|
||||
if self.pk and self.structural and self.partcount(False, False) > 0:
|
||||
raise ValidationError(
|
||||
_("You cannot make this part category structural because some parts "
|
||||
"are already assigned to it!"))
|
||||
|
@ -152,7 +152,7 @@ class StockLocation(InvenTreeBarcodeMixin, MetadataMixin, InvenTreeTree):
|
||||
|
||||
- Ensure stock location can't be made structural if stock items already located to them
|
||||
"""
|
||||
if self.pk and self.structural and self.item_count > 0:
|
||||
if self.pk and self.structural and self.stock_item_count(False) > 0:
|
||||
raise ValidationError(
|
||||
_("You cannot make this stock location structural because some stock items "
|
||||
"are already located into it!"))
|
||||
|
Loading…
Reference in New Issue
Block a user