Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stock location structural check (#4089) #4095

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion InvenTree/part/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!"))
Expand Down
2 changes: 1 addition & 1 deletion InvenTree/stock/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!"))
Expand Down