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

Adds metadata mixin class for adding JSON field to internal tables

- Add metadata field to stocklocation
- Add metadata field to stockitem
This commit is contained in:
Oliver Walters
2022-05-16 00:45:16 +10:00
parent 818be32e31
commit 097afed78e
3 changed files with 54 additions and 2 deletions

View File

@ -16,6 +16,30 @@ import common.models
from plugin import InvenTreePlugin, registry
class MetadataMixin(models.Model):
"""
Model mixin class which adds a JSON metadata field to a model,
for use by any (and all) plugins.
The intent of this mixin is to provide a metadata field on a model instance,
for plugins to read / modify as required, to store any extra information.
The assumptions for models implementing this mixin are:
- The internal InvenTree business logic will make no use of this field
- Multiple plugins may read / write to this metadata field, and not assume they have sole rights
"""
class Meta:
abstract = True
metadata = models.JSONField(
blank=True, null=True,
verbose_name=_('Plugin Metadata'),
help_text=_('JSON metadata field, for use by external plugins'),
)
class PluginConfig(models.Model):
"""
A PluginConfig object holds settings for plugins.