mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Include 'key' field in StockItemTestResult serializer
This commit is contained in:
parent
01481ef5c9
commit
e4d10279fa
@ -687,6 +687,8 @@ class StockItemTestResultList(generics.ListCreateAPIView):
|
||||
'value',
|
||||
]
|
||||
|
||||
ordering = 'date'
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
try:
|
||||
kwargs['user_detail'] = str2bool(self.request.query_params.get('user_detail', False))
|
||||
|
@ -1129,7 +1129,7 @@ class StockItemTestResult(models.Model):
|
||||
super().clean()
|
||||
|
||||
# If this test result corresponds to a template, check the requirements of the template
|
||||
key = helpers.generateTestKey(self.test)
|
||||
key = self.key
|
||||
|
||||
templates = self.stock_item.part.getTestTemplates()
|
||||
|
||||
@ -1150,6 +1150,10 @@ class StockItemTestResult(models.Model):
|
||||
|
||||
break
|
||||
|
||||
@property
|
||||
def key(self):
|
||||
return helpers.generateTestKey(self.test)
|
||||
|
||||
stock_item = models.ForeignKey(
|
||||
StockItem,
|
||||
on_delete=models.CASCADE,
|
||||
|
@ -230,6 +230,8 @@ class StockItemTestResultSerializer(InvenTreeModelSerializer):
|
||||
|
||||
user_detail = UserSerializerBrief(source='user', read_only=True)
|
||||
|
||||
key = serializers.CharField(read_only=True)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
user_detail = kwargs.pop('user_detail', False)
|
||||
|
||||
@ -244,6 +246,7 @@ class StockItemTestResultSerializer(InvenTreeModelSerializer):
|
||||
fields = [
|
||||
'pk',
|
||||
'stock_item',
|
||||
'key',
|
||||
'test',
|
||||
'result',
|
||||
'value',
|
||||
|
Loading…
Reference in New Issue
Block a user