From cd68d5a80ef377bd7ef3340996addf1829a9c21e Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 16 May 2022 19:14:46 +1000 Subject: [PATCH] Add metadata mixin to Part and PartCategory models --- .../migrations/0076_auto_20220516_0819.py | 23 +++++++++++++++++++ InvenTree/part/models.py | 16 ++++++------- 2 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 InvenTree/part/migrations/0076_auto_20220516_0819.py diff --git a/InvenTree/part/migrations/0076_auto_20220516_0819.py b/InvenTree/part/migrations/0076_auto_20220516_0819.py new file mode 100644 index 0000000000..5b02860aca --- /dev/null +++ b/InvenTree/part/migrations/0076_auto_20220516_0819.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.13 on 2022-05-16 08:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('part', '0075_auto_20211128_0151'), + ] + + operations = [ + migrations.AddField( + model_name='part', + name='metadata', + field=models.JSONField(blank=True, help_text='JSON metadata field, for use by external plugins', null=True, verbose_name='Plugin Metadata'), + ), + migrations.AddField( + model_name='partcategory', + name='metadata', + field=models.JSONField(blank=True, help_text='JSON metadata field, for use by external plugins', null=True, verbose_name='Plugin Metadata'), + ), + ] diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 96ffa581f4..09128cd6bc 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -46,29 +46,29 @@ from common.models import InvenTreeSetting from InvenTree import helpers from InvenTree import validators -from InvenTree.models import InvenTreeTree, InvenTreeAttachment, DataImportMixin -from InvenTree.fields import InvenTreeURLField -from InvenTree.helpers import decimal2string, normalize, decimal2money import InvenTree.ready import InvenTree.tasks +from InvenTree.fields import InvenTreeURLField +from InvenTree.helpers import decimal2string, normalize, decimal2money +from InvenTree.models import InvenTreeTree, InvenTreeAttachment, DataImportMixin from InvenTree.status_codes import BuildStatus, PurchaseOrderStatus, SalesOrderStatus +import common.models from build import models as BuildModels from order import models as OrderModels from company.models import SupplierPart +import part.settings as part_settings from stock import models as StockModels -import common.models - -import part.settings as part_settings +from plugin.models import MetadataMixin logger = logging.getLogger("inventree") -class PartCategory(InvenTreeTree): +class PartCategory(MetadataMixin, InvenTreeTree): """ PartCategory provides hierarchical organization of Part objects. Attributes: @@ -327,7 +327,7 @@ class PartManager(TreeManager): @cleanup.ignore -class Part(MPTTModel): +class Part(MetadataMixin, MPTTModel): """ The Part object represents an abstract part, the 'concept' of an actual entity. An actual physical instance of a Part is a StockItem which is treated separately.