2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 03:00:54 +00:00

Add metadata endpoints for SalesOrder and PurchaseOrder models

This commit is contained in:
Oliver Walters
2022-05-16 21:40:10 +10:00
parent 5582c8ba43
commit bd17458f37
6 changed files with 43 additions and 14 deletions

View File

@ -45,16 +45,16 @@ class MetadataMixin(models.Model):
Args:
key: String key for requesting metadata. e.g. if a plugin is accessing the metadata, the plugin slug should be used
Returns:
Python dict object containing requested metadata. If no matching metadata is found, returns None
"""
if self.metadata is None:
return backup_value
return self.metadata.get(key, backup_value)
def set_metadata(self, key: str, data, commit=True):
"""
Save the provided metadata under the provided key.
@ -68,9 +68,9 @@ class MetadataMixin(models.Model):
if self.metadata is None:
# Handle a null field value
self.metadata = {}
self.metadata[key] = data
if commit:
self.save()

View File

@ -15,8 +15,6 @@ from django.utils import timezone
from rest_framework import serializers
from InvenTree.helpers import str2bool
from plugin.models import PluginConfig, PluginSetting, NotificationUserSetting
from common.serializers import GenericReferencedSettingSerializer
@ -37,7 +35,7 @@ class MetadataSerializer(serializers.ModelSerializer):
fields = [
'metadata',
]
def update(self, instance, data):
if self.partial: