From 4359870b86c4b2fa5c4d53d96006680391e0debb Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 24 Dec 2024 01:02:57 +0000 Subject: [PATCH] Remove DataImportMixin class --- src/backend/InvenTree/InvenTree/models.py | 55 ----------------------- src/backend/InvenTree/part/models.py | 23 +--------- 2 files changed, 1 insertion(+), 77 deletions(-) diff --git a/src/backend/InvenTree/InvenTree/models.py b/src/backend/InvenTree/InvenTree/models.py index fdab2c719810..36479395374a 100644 --- a/src/backend/InvenTree/InvenTree/models.py +++ b/src/backend/InvenTree/InvenTree/models.py @@ -225,61 +225,6 @@ def set_metadata( self.save() -class DataImportMixin: - """Model mixin class which provides support for 'data import' functionality. - - Models which implement this mixin should provide information on the fields available for import - """ - - # TODO: This mixin should be removed after https://github.com/inventree/InvenTree/pull/6911 is implemented - # TODO: This approach to data import functionality is *outdated* - - # Define a map of fields available for import - IMPORT_FIELDS = {} - - @classmethod - def get_import_fields(cls): - """Return all available import fields. - - Where information on a particular field is not explicitly provided, - introspect the base model to (attempt to) find that information. - """ - fields = cls.IMPORT_FIELDS - - for name, field in fields.items(): - # Attempt to extract base field information from the model - base_field = None - - for f in cls._meta.fields: - if f.name == name: - base_field = f - break - - if base_field: - if 'label' not in field: - field['label'] = base_field.verbose_name - - if 'help_text' not in field: - field['help_text'] = base_field.help_text - - fields[name] = field - - return fields - - @classmethod - def get_required_import_fields(cls): - """Return all *required* import fields.""" - fields = {} - - for name, field in cls.get_import_fields().items(): - required = field.get('required', False) - - if required: - fields[name] = field - - return fields - - class ReferenceIndexingMixin(models.Model): """A mixin for keeping track of numerical copies of the "reference" field. diff --git a/src/backend/InvenTree/part/models.py b/src/backend/InvenTree/part/models.py index 7f23844d170f..d3a4f78de091 100644 --- a/src/backend/InvenTree/part/models.py +++ b/src/backend/InvenTree/part/models.py @@ -4089,11 +4089,7 @@ def clean(self): ) -class BomItem( - InvenTree.models.DataImportMixin, - InvenTree.models.MetadataMixin, - InvenTree.models.InvenTreeModel, -): +class BomItem(InvenTree.models.MetadataMixin, InvenTree.models.InvenTreeModel): """A BomItem links a part to its component items. A part can have a BOM (bill of materials) which defines @@ -4113,23 +4109,6 @@ class BomItem( allow_variants: Stock for part variants can be substituted for this BomItem """ - # Fields available for bulk import - IMPORT_FIELDS = { - 'quantity': {'required': True}, - 'reference': {}, - 'overage': {}, - 'allow_variants': {}, - 'inherited': {}, - 'optional': {}, - 'consumable': {}, - 'note': {}, - 'part': {'label': _('Part'), 'help_text': _('Part ID or part name')}, - 'part_id': {'label': _('Part ID'), 'help_text': _('Unique part ID value')}, - 'part_name': {'label': _('Part Name'), 'help_text': _('Part name')}, - 'part_ipn': {'label': _('Part IPN'), 'help_text': _('Part IPN value')}, - 'level': {'label': _('Level'), 'help_text': _('BOM level')}, - } - class Meta: """Metaclass providing extra model definition."""