Skip to content
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

Don't ignore parts without stock in stocktake #5627

Merged
merged 4 commits into from
Oct 2, 2023

Conversation

lippoliv
Copy link
Sponsor Contributor

@lippoliv lippoliv commented Sep 28, 2023

Fixes #5621

Currently in Stocktake (no matter if it's the export or update parts) we ignore Parts with 0 stock. This PR fixes that.

Backport

I would love to see this being backported to 0.12.x, but it will not work automatically I guess. It's simliar lines, but in another file (https://github.com/inventree/InvenTree/blob/0.12.x/InvenTree/part/tasks.py#L317-L319).

@netlify
Copy link

netlify bot commented Sep 28, 2023

Deploy Preview for inventree canceled.

Name Link
🔨 Latest commit 1f934ab
🔍 Latest deploy log https://app.netlify.com/sites/inventree/deploys/651a556182688300073089c2

@lippoliv
Copy link
Sponsor Contributor Author

I guess the CI fails for other reasons then my changes, right?

@SchrodingersGat
Copy link
Member

@lippoliv looks like it - please merge in master once #5628 has been merged

@SchrodingersGat SchrodingersGat added part Related to Part models stock Related to Stock models backport Apply this label to a PR to enable auto-backport action backport-to-0.12.x labels Sep 28, 2023
@SchrodingersGat
Copy link
Member

@lippoliv can you please merge in the changes from latest master so we can get this one merged?

@lippoliv
Copy link
Sponsor Contributor Author

lippoliv commented Oct 1, 2023

@SchrodingersGat done

@SchrodingersGat
Copy link
Member

Looks like some of the unit tests will have to be adjusted too :)

@lippoliv
Copy link
Sponsor Contributor Author

lippoliv commented Oct 1, 2023

Missed that, try to fix it. The VSCode integration is missing is that normal?

image

I can just execute the tests task, wait some time and then see the output of everything?

@SchrodingersGat
Copy link
Member

@lippoliv what exactly are you running to get that error message?

You should be able to (from the command line in devcontainer) run something like:

invoke test -r part.test_api (substitute part.test_api for whatever group of tests you need to run)

@lippoliv
Copy link
Sponsor Contributor Author

lippoliv commented Oct 2, 2023

I set up VS Code as described in devcontainers. Then I told it what python testing we use. I end up in the screenshot I showed before. In Output > Python I see

Failed to import test module: users.test_migrations
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/local/lib/python3.10/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/workspaces/InvenTree/InvenTree/users/test_migrations.py", line 5, in <module>
    from InvenTree import unit_test
  File "/workspaces/InvenTree/InvenTree/InvenTree/unit_test.py", line 11, in <module>
    from django.contrib.auth.models import Group, Permission
  File "/workspaces/InvenTree/dev/venv/lib/python3.10/site-packages/django/contrib/auth/models.py", line 3, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "/workspaces/InvenTree/dev/venv/lib/python3.10/site-packages/django/contrib/auth/base_user.py", line 48, in <module>
    class AbstractBaseUser(models.Model):
  File "/workspaces/InvenTree/dev/venv/lib/python3.10/site-packages/django/db/models/base.py", line 108, in __new__
    app_config = apps.get_containing_app_config(module)
  File "/workspaces/InvenTree/dev/venv/lib/python3.10/site-packages/django/apps/registry.py", line 253, in get_containing_app_config
    self.check_apps_ready()
  File "/workspaces/InvenTree/dev/venv/lib/python3.10/site-packages/django/apps/registry.py", line 135, in check_apps_ready
    settings.INSTALLED_APPS
  File "/workspaces/InvenTree/dev/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 82, in __getattr__
    self._setup(name)
  File "/workspaces/InvenTree/dev/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 63, in _setup
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

Is that a bug?

However I adapted your command line (thanks for the help) and ended up with invoke test -r part.test_api.PartStocktakeTest.test_report_list which I made pass and then step by step went "up" to see that everything works.

@SchrodingersGat
Copy link
Member

LGTM, thanks for the contribution @lippoliv

@SchrodingersGat SchrodingersGat merged commit 6a48eae into inventree:master Oct 2, 2023
20 checks passed
@SchrodingersGat SchrodingersGat added this to the 0.13.0 milestone Oct 2, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 2, 2023

💔 All backports failed

Status Branch Result
0.12.x Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

backport --pr 5627

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

SchrodingersGat pushed a commit to SchrodingersGat/InvenTree that referenced this pull request Oct 2, 2023
SchrodingersGat added a commit that referenced this pull request Oct 2, 2023
- Backport of #5627

Co-authored-by: Oliver Lippert <oliver@allesit.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Apply this label to a PR to enable auto-backport action part Related to Part models stock Related to Stock models
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stocktake doesn't save parts with no stock
2 participants