SergeoLacruz / inventree-supplier-panel

Put the parts from a purchase order into a supplier shopping cart
MIT License
11 stars 1 forks source link

NoReverseMatch error #6

Closed HannesMorre closed 1 month ago

HannesMorre commented 7 months ago

When i create a mouser purchase order in inventree I get this error, but have no idea how to solve this.

'suppliercart' is not a registered namespace inside 'plugin'

Traceback (most recent call last):

File "/root/.local/lib/python3.11/site-packages/django/urls/base.py", line 71, in reverse
extra, resolver = resolver.namespace_dict[ns]
~~~~~~~~~~~~~~~~~~~~~~~^^^^

KeyError: 'suppliercart'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/home/inventree/InvenTree/plugin/views.py", line 25, in get_plugin_panels
panels += plug.render_panels(self, self.request, ctx)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/inventree/InvenTree/plugin/base/integration/mixins.py", line 161, in render_panels
panel['content'] = render_template(self, content_template, ctx)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/inventree/InvenTree/plugin/helpers.py", line 243, in render_template
html = tmp.render(context)
^^^^^^^^^^^^^^^^^^^

File "/root/.local/lib/python3.11/site-packages/django/template/backends/django.py", line 61, in render
return self.template.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/root/.local/lib/python3.11/site-packages/django/template/base.py", line 175, in render
return self._render(context)
^^^^^^^^^^^^^^^^^^^^^

File "/root/.local/lib/python3.11/site-packages/django/template/base.py", line 167, in _render
return self.nodelist.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/root/.local/lib/python3.11/site-packages/django/template/base.py", line 1005, in render
return SafeString("".join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/root/.local/lib/python3.11/site-packages/django/template/base.py", line 1005, in <listcomp>
return SafeString("".join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/root/.local/lib/python3.11/site-packages/django/template/base.py", line 966, in render_annotated
return self.render(context)
^^^^^^^^^^^^^^^^^^^^

File "/root/.local/lib/python3.11/site-packages/django/template/defaulttags.py", line 471, in render
url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/root/.local/lib/python3.11/site-packages/django/urls/base.py", line 77, in reverse
raise NoReverseMatch(

django.urls.exceptions.NoReverseMatch: 'suppliercart' is not a registered namespace inside 'plugin'
HannesMorre commented 7 months ago

This issue is solved, the mouser cart is working, but we have an issue with digikey now. {"ErrorCode" : "invalid_request", "Error" :"Invalid redirection uri https://{url}/plugin/suppliercart/digikeytoken/"}

This probably happens because our inventree instance is not accessible from outside our organization? How can we solve this?

SergeoLacruz commented 7 months ago

Hi, Did you set the base URL in the InvenTree settings?

HannesMorre commented 5 months ago

Hi, yes the base url is set in the InvenTree settings The previous error was on our staging environment of inventree where we test new updates and plugins. Now I am trying on our production environment and I get the same error when I try to request a token

HannesMorre commented 5 months ago

Update: Now it works, but I get redirected to our inventree home page and the tokens are not set for Digikey

HannesMorre commented 5 months ago

Update: I made it work now, all default plugin settings were disabled image

SergeoLacruz commented 5 months ago

Good to hear that it works in your environment.

HannesMorre commented 5 months ago

Just a question about part creation, is it possible to create parts with this plugin like kintree does?

SergeoLacruz commented 5 months ago

No. We create parts manually using some kind of review process. It is not done that often. So automation is not required in our case. The plugin can create supplierparts for existing parts if you know the exact SKU of the supplier.

HannesMorre commented 5 months ago

yes, the supplier part creation is very convenient Thanks for the extra info.

HannesMorre commented 5 months ago

@SergeoLacruz just after my last comment I am trying to add supplier parts from digikey but unfortunately this is not working properly. For mouser parts there is no problem, but i cannot add digikey supplierparts.

SergeoLacruz commented 5 months ago

Is the token created and valid? Does the Digikey shopping cart transfer work? The logs show a green message each time the token is checked and a red one when the token is invalid. Any error message in the message bar?

HannesMorre commented 5 months ago

How can I check if the token is valid? It is created, so should be valid I guess. Shopping cart transfer works. No logs when trying to create supplier part. No error messages either.

SergeoLacruz commented 5 months ago

If the shopping cart transfer to Digikey works, the token is valid. You should see in the log

https://api.digikey.com:443 "POST /v1/oauth2/token HTTP/1.1" 200 273
Token refresh SUCCESS

This shows get_digikey_partdata has been called. You should further see

Remaining requests: 

This tells you how many requests Digikey still allows you for the actual time period The message header should be blue and show 200. This is the response status code. If the status code is not 200 the bar is red and shows an error message e.g. Part not found at Digikey.

HannesMorre commented 4 months ago

Hi @SergeoLacruz I just tried again to add a supplier part, but now I get this error:

image

What can be done to fix this?

SergeoLacruz commented 4 months ago

This is a message caused by Digikey. Please supply the log for that request. Where are you located? Which currency did you set?

HannesMorre commented 4 months ago

And where exactly can I find these logs? Today I got a different error code btw: image

I am located in Belgium and the currency of inventree is set to Euro

SergeoLacruz commented 4 months ago

The InvenTree server creates logs. The second message is obvious, your Client ID is invalid.

HannesMorre commented 4 months ago

It is weird that the Client ID is invalid since it does work to transfer the cart and create a token. I asked my colleague for the logs

HannesMorre commented 4 months ago

I tried to reproduce this again to generate new logs and this is what i get: image

SergeoLacruz commented 4 months ago

Try a page reload.

HannesMorre commented 4 months ago

How can we fix the invalid Client ID problem?