Skip to content

Cleanup old BOM Import Code #8756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
55 changes: 0 additions & 55 deletions src/backend/InvenTree/InvenTree/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,61 +226,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.

Expand Down
Loading
Loading