Skip to content

Add Metadata to further models - #4410

Merged
SchrodingersGat merged 49 commits into
inventree:masterfrom
miggland:metadata
Mar 23, 2023
Merged

SchrodingersGat merged 49 commits into
inventree:masterfrom
miggland:metadata

Conversation

@miggland

@miggland miggland commented Feb 24, 2023 •

Copy link
Copy Markdown
Contributor

Adds the metadata mixin, and thus the ability to add metadata to the following models, as mentioned in #4202 (List here is slightly different):

  • Manufacturer part
  • Supplier part
  • Part labels
  • Stock item labels
  • Stock location labels
  • PO lines
  • PO extra lines
  • SO lines
  • SO extra lines
  • SO shipments
  • Build Orders
  • Build order items
  • BOM items
  • Part parameter templates
  • Reports BOM
  • Reports Build
  • Reports PO
  • Reports SO
  • Reports stock item test

To do:

  • Migrations
  • Tests
  • Update API version

@matmair matmair added enhancement This is an suggested enhancement or new feature plugin Plugin ecosystem labels Feb 24, 2023
@miggland

Copy link
Copy Markdown
Contributor Author

The test is still failing on my test VM, with the error given above - even though it's working here. Odd.

It is somehow related to slowtests- if I disable those (see change below), then the tests run fine.

I'm also seeing extra migration files created constantly, with the following content. Strange, anything I need to worry about?

# Generated by Django 3.2.18 on 2023-03-17 11:06

from django.db import migrations


class Migration(migrations.Migration):

    dependencies = [
        ('InvenTree', '0001_initial'),
    ]

    operations = [
    ]
# Generated by Django 3.2.18 on 2023-03-17 12:00

from django.db import migrations


class Migration(migrations.Migration):

    dependencies = [
        ('InvenTree', '0002_auto_20230317_1106'),
    ]

    operations = [
    ]

Change to slowtests:

diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py
index 1aab68d5d..6f8234917 100644
--- a/InvenTree/InvenTree/settings.py
+++ b/InvenTree/InvenTree/settings.py
@@ -38,8 +38,8 @@ if TESTING:
     PASSWORD_HASHERS = ['django.contrib.auth.hashers.MD5PasswordHasher',]
 
     # Enable slow-test-runner
-    TEST_RUNNER = 'django_slowtests.testrunner.DiscoverSlowestTestsRunner'
-    NUM_SLOW_TESTS = 25
+    #TEST_RUNNER = 'django_slowtests.testrunner.DiscoverSlowestTestsRunner'
+    #NUM_SLOW_TESTS = 25
 
     # Note: The following fix is "required" for docker build workflow
     # Note: 2022-12-12 still unsure why...
diff --git a/tasks.py b/tasks.py
index 85501e024..3788b5f29 100644
--- a/tasks.py
+++ b/tasks.py
@@ -559,7 +559,7 @@ def test(c, disable_pty=False):
     pty = not disable_pty
 
     # Run coverage tests
-    manage(c, 'test --slowreport', pty=pty)
+    manage(c, 'test', pty=pty)
 
 
 @task(help={'dev': 'Set up development environment at the end'})

@miggland
miggland marked this pull request as ready for review March 21, 2023 11:20
Comment thread InvenTree/report/api.py
def get_serializer(self, *args, **kwargs):
"""Return correct MetadataSerializer instance depending on which model is requested"""
# Get type of report, make sure its one of the allowed values
UseModel = self._get_model(*args, **kwargs)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we use a simpler approach here:

UseModel = self.Meta.model

(or similar)?

The endpoint already has either a model or queryset defined, righ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This question is for @matmair, he helped out and contributed this part of the code. I'm not sure of the implications / the details of your question..

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SchrodingersGat not in this case, the model is provided in the url definition as an argument. Reduced the boilerplate as everything is the same for these 4 models. We can type it out if you prefer that. This mainly cuts down on the LoC.

@SchrodingersGat

Copy link
Copy Markdown
Member

@miggland looking good, but see my comment above

@matmair any thoughts on this?

@matmair matmair left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm.
There is a caching change I am unsure of - the rest looks great!

Comment thread InvenTree/report/api.py Resolved
@miggland

Copy link
Copy Markdown
Contributor Author

Fixed as above, and merged latest master into the branch.

@SchrodingersGat

Copy link
Copy Markdown
Member

@miggland many thanks for the great work here :)

@SchrodingersGat
SchrodingersGat merged commit 807784d into inventree:master Mar 23, 2023
@SchrodingersGat SchrodingersGat added this to the 0.11.0 milestone Mar 23, 2023
@miggland miggland mentioned this pull request Apr 11, 2023
28 of 38 tasks
@miggland
miggland deleted the metadata branch June 1, 2023 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement This is an suggested enhancement or new feature plugin Plugin ecosystem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants