Repository navigation
Fix order allocation variant validation logic and serializer read_only_fields - #12738
Conversation
✅ Deploy Preview for inventree-web-pui-preview canceled.
|
|
There are a lot of style changed here that make no sense; make sure to read the contributions guide - especially regarding formatting https://docs.inventree.org/en/stable/develop/contributing/ |
…fix-order-allocation-validation-and-serializers
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #12738 +/- ##
==========================================
+ Coverage 87.08% 87.14% +0.06%
==========================================
Files 1483 1481 -2
Lines 100213 99757 -456
Branches 11609 11436 -173
==========================================
- Hits 87270 86937 -333
+ Misses 12878 12755 -123
Partials 65 65
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…ion-validation-and-serializers
…ion-validation-and-serializers
…and-serializers' into fix-order-allocation-validation-and-serializers
|
@bhumin18 thank you for cleaning up the PR, much easier to review it now. This is a good catch, thanks for submitting a fix for this. |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation and see the Github Action logs for details |
Summary
This PR fixes a data validation logic bug in order allocation models and cleans up serializer
read_only_fieldsdefinitions:order/models.py(SalesOrderAllocation.clean()&TransferOrderAllocation.clean()):self.line.part not in variantstoself.item.part not in variants.variants = self.line.part.get_descendants(include_self=True), checkingself.line.part not in variantswas alwaysFalse, which allowed allocating completely unrelated stock items to order line items without triggering the validation error. Now, only the required part or its valid descendant variants can be allocated.order/serializers.py(SalesOrderAllocationSerializer&TransferOrderAllocationSerializer):''fromread_only_fields = ['line'].order/test_api.py(OrderAllocationValidationTest):ValidationError, while allocating valid variant stock items succeeds.