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

Cannot merge storage items #277

Open
mase76 opened this issue Aug 12, 2022 · 1 comment
Open

Cannot merge storage items #277

mase76 opened this issue Aug 12, 2022 · 1 comment

Comments

@mase76
Copy link
Contributor

mase76 commented Aug 12, 2022

Hi!
When trying to merge storage items i get a server error and this traceback:

File "/home/partuniverse/env/lib/python3.9/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/partuniverse/env/lib/python3.9/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/partuniverse/env/lib/python3.9/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/partuniverse/env/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/home/partuniverse/env/lib/python3.9/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/partuniverse/env/lib/python3.9/site-packages/django/views/generic/base.py", line 97, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/partuniverse/env/lib/python3.9/site-packages/django/views/generic/edit.py", line 142, in post
    return self.form_valid(form)
  File "/home/partuniverse/partuniverse/partuniverse/partsmanagement/views.py", line 581, in form_valid
    storageiitem.part.merge_storage_items(
  File "/home/partuniverse/partuniverse/partuniverse/partsmanagement/models.py", line 600, in merge_storage_items
    si2.delete()
  File "/home/partuniverse/env/lib/python3.9/site-packages/django/db/models/base.py", line 921, in delete
    collector.collect([self], keep_parents=keep_parents)
  File "/home/partuniverse/env/lib/python3.9/site-packages/django/db/models/deletion.py", line 224, in collect
    field.remote_field.on_delete(self, field, sub_objs, self.using)
  File "/home/partuniverse/env/lib/python3.9/site-packages/django/db/models/deletion.py", line 22, in PROTECT
    raise ProtectedError(
django.db.models.deletion.ProtectedError: ("Cannot delete some instances of model 'StorageItem' because they are referenced through a protected foreign key: 'VerifiedStock.storage_item'", <QuerySet [<VerifiedStock: ATTINY85-20SU; Werkstattmagazine->Werkstattmagazin 1 2022-08-11 21:43:46.630413+00:00>]>)

However the amount of one item is added to the other item, but the other one is not deleted.

@mase76
Copy link
Contributor Author

mase76 commented Aug 21, 2022

#285 fixes this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant