diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 3407e2ebf64..72e6e0e8dea 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -148,7 +148,7 @@ def clean(self): - 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!")) diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 93ee99c9517..a4a9124a2aa 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -152,7 +152,7 @@ def clean(self): - 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!"))