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

Merged
merged 4 commits into from
Dec 21, 2022
Merged

Fix stock location structural check #4089

merged 4 commits into from
Dec 21, 2022

Conversation

bloemp
Copy link
Contributor

@bloemp bloemp commented Dec 21, 2022

Exclude sub stock location items from preventing that a stock location can be switched to structural.

Closes #4087

Exclude sub stock location items from preventing that a stock location can be switched to structural.
@SchrodingersGat SchrodingersGat added the bug Identifies a bug which needs to be addressed label Dec 21, 2022
@SchrodingersGat
Copy link
Member

@bloemp thanks! Can you also make the same fix to the part category model:

if self.pk and self.structural and self.item_count > 0:

@SchrodingersGat SchrodingersGat added part Related to Part models stock Related to Stock models labels Dec 21, 2022
@SchrodingersGat SchrodingersGat added this to the 0.9.1 milestone Dec 21, 2022
@bloemp
Copy link
Contributor Author

bloemp commented Dec 21, 2022

@SchrodingersGat modified the pull request to include a fix for the part categorie.
if self.pk and self.structural and self.partcount(False, False) > 0:
I've added both parameters to the partcount call, while not strictly needed... it seemed future proof (if anyone ever changes the default, the check still functions). But as a newbie to python, is this the best way to go?

@SchrodingersGat
Copy link
Member

@bloemp looks good :)

@SchrodingersGat SchrodingersGat merged commit 14a2c12 into inventree:master Dec 21, 2022
@SchrodingersGat
Copy link
Member

Thanks for your contribution @bloemp

SchrodingersGat pushed a commit to SchrodingersGat/InvenTree that referenced this pull request Dec 21, 2022
* 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

(cherry picked from commit 14a2c12)
SchrodingersGat added a commit that referenced this pull request Dec 21, 2022
* 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

(cherry picked from commit 14a2c12)

Co-authored-by: bloemp <pbloem@upcmail.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Identifies a bug which needs to be addressed part Related to Part models stock Related to Stock models
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Can't make storage location structural if sub storage location contains parts
2 participants