2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-10-24 09:57:40 +00:00

ensure popped values are persisted

This commit is contained in:
Matthias Mair
2025-10-13 22:21:09 +02:00
parent 81f26c7073
commit 994259a71d

View File

@@ -53,7 +53,6 @@ class OptFilter:
class PathScopedMixin(serializers.Serializer):
"""Mixin to disable a serializer field based on kwargs passed to the view."""
no_filter = False
_was_filtered = False
def __init__(self, *args, **kwargs):
@@ -77,10 +76,13 @@ class PathScopedMixin(serializers.Serializer):
}
# Remove filter args from kwargs to avoid issues with super().__init__
poped_kwargs = {} # store popped kwargs as a arg might be reused for multiple fields
tgs_vals = {}
for k, v in self.filter_targets.items():
pop_ref = v['name'] or k
val = kwargs.pop(pop_ref, None)
val = kwargs.pop(pop_ref, poped_kwargs.get(pop_ref))
if val:
poped_kwargs[pop_ref] = val
tgs_vals[k] = str2bool(val) if isinstance(val, str) else val
self.filter_target_values = tgs_vals