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

Prevent deletion of part which is used in an assembly #7260

Merged
merged 7 commits into from
May 20, 2024

Conversation

SchrodingersGat
Copy link
Member

@SchrodingersGat SchrodingersGat commented May 19, 2024

Adds protection against deleting a part which is a component in an assembly.

@matmair @wolflu05 thoughts here? Should this behaviour be behind a configurable setting?

@SchrodingersGat SchrodingersGat added enhancement This is an suggested enhancement or new feature part Related to Part models labels May 19, 2024
@SchrodingersGat SchrodingersGat added this to the 0.16.0 milestone May 19, 2024
Copy link

netlify bot commented May 19, 2024

Deploy Preview for inventree-web-pui-preview canceled.

Name Link
🔨 Latest commit a32f04b
🔍 Latest deploy log https://app.netlify.com/sites/inventree-web-pui-preview/deploys/664aae7b94a26200089799dd

Copy link

codecov bot commented May 19, 2024

Codecov Report

Attention: Patch coverage is 88.46154% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 84.00%. Comparing base (2431fc6) to head (a32f04b).
Report is 2 commits behind head on master.

Files Patch % Lines
src/backend/InvenTree/InvenTree/models.py 80.00% 1 Missing ⚠️
src/backend/InvenTree/part/models.py 85.71% 1 Missing ⚠️
...venTree/plugin/base/integration/ValidationMixin.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7260      +/-   ##
==========================================
- Coverage   84.06%   84.00%   -0.07%     
==========================================
  Files        1054     1054              
  Lines       46288    46372      +84     
  Branches     1326     1326              
==========================================
+ Hits        38913    38954      +41     
- Misses       7043     7086      +43     
  Partials      332      332              
Flag Coverage Δ
backend 85.45% <88.46%> (+<0.01%) ⬆️
pui 64.50% <ø> (-0.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wolflu05
Copy link
Contributor

Sorry that I cannot add some production feedback here, I have not really used assemblies yet. But just from thinking about it, if we delete an part, the part for the assembly is missing, that would mean, we either delete the assembly too, or remove the part from the assembly or deactivate the part somehow that its not shown in search anymore.

@SchrodingersGat
Copy link
Member Author

Sorry that I cannot add some production feedback here, I have not really used assemblies yet. But just from thinking about it, if we delete an part, the part for the assembly is missing, that would mean, we either delete the assembly too, or remove the part from the assembly or deactivate the part somehow that its not shown in search anymore.

I think that this is not quite right. The change I am implementing here prevents the sub_part from a BOM being deleted - which would in practice mean that a BOM item disappears (without warning) from the BOM of an existing assembly. This change prevents the part from being deleted while it is still in the BOM for a different assembly.

@SchrodingersGat SchrodingersGat merged commit c540b12 into inventree:master May 20, 2024
27 of 28 checks passed
@SchrodingersGat SchrodingersGat deleted the part-delete-fix branch May 20, 2024 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is an suggested enhancement or new feature part Related to Part models
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants