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:
@ -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()
|
||||
|
||||
|
@ -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:
|
||||
|
Reference in New Issue
Block a user