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

[PLG:APR] Approvals Plugin TemplateSyntaxError #16

Closed
csmith73 opened this issue Feb 15, 2024 · 13 comments
Closed

[PLG:APR] Approvals Plugin TemplateSyntaxError #16

csmith73 opened this issue Feb 15, 2024 · 13 comments
Labels

Comments

@csmith73
Copy link

@matmair thank you for your work on this plugin. I am not sure if this is the best place to put these issues I am having, if there is a better place to post please let me know. I was able to successfully install the approvals plugin by adding the repo and the plugin name to the plugins.txt file. I enabled the plugin along with making sure that check plugins on startup, app integration, and url integration were all enabled. I was able to enable the plugin successfully but if I navigate to /plugin/inventree-approval I get the below error. This error also occurs when I try to issue a PO. I am running the latest stable release of Inventree 0.13.5, Python 3.10.13, Django 3.2.23 Do you have any suggestions on how to fix this?

Traceback (most recent call last):

File "/root/.local/lib/python3.10/site-packages/django/template/defaulttags.py", line 1037, in find_library
return parser.libraries[name]

KeyError: 'inventree_approval'


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

File "/home/inventree/InvenTree/plugin/views.py", line 26, 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 209, in render_template
tmp = template.loader.get_template(template_file)

File "/root/.local/lib/python3.10/site-packages/django/template/loader.py", line 15, in get_template
return engine.get_template(template_name)

File "/root/.local/lib/python3.10/site-packages/django/template/backends/django.py", line 34, in get_template
return Template(self.engine.get_template(template_name), self)

File "/root/.local/lib/python3.10/site-packages/django/template/engine.py", line 143, in get_template
template, origin = self.find_template(template_name)

File "/root/.local/lib/python3.10/site-packages/django/template/engine.py", line 125, in find_template
template = loader.get_template(name, skip=skip)

File "/home/inventree/InvenTree/InvenTree/template.py", line 27, in get_template
template = CachedLoader.get_template(self, template_name, skip)

File "/root/.local/lib/python3.10/site-packages/django/template/loaders/cached.py", line 58, in get_template
template = super().get_template(template_name, skip)

File "/root/.local/lib/python3.10/site-packages/django/template/loaders/base.py", line 29, in get_template
return Template(

File "/root/.local/lib/python3.10/site-packages/django/template/base.py", line 155, in __init__
self.nodelist = self.compile_nodelist()

File "/root/.local/lib/python3.10/site-packages/django/template/base.py", line 193, in compile_nodelist
return parser.parse()

File "/root/.local/lib/python3.10/site-packages/django/template/base.py", line 478, in parse
raise self.error(token, e)

File "/root/.local/lib/python3.10/site-packages/django/template/base.py", line 476, in parse
compiled_result = compile_func(self, token)

File "/root/.local/lib/python3.10/site-packages/django/template/defaulttags.py", line 1094, in load
lib = find_library(parser, name)

File "/root/.local/lib/python3.10/site-packages/django/template/defaulttags.py", line 1039, in find_library
raise TemplateSyntaxError(

django.template.exceptions.TemplateSyntaxError: 'inventree_approval' is not a registered tag library. Must be one of:
account
admin_list
admin_modify
admin_urls
allauth
barcode
cache
crispy_forms_field
crispy_forms_filters
crispy_forms_tags
crispy_forms_utils
djmoney
feature_flags
flags_debug
generic
i18n
import_export_tags
inventree_extras
l10n
log
markdownify
mptt_admin
mptt_tags
plugin_extras
report
rest_framework
socialaccount
spa_helper
sso
static
tz
user_sessions
@csmith73
Copy link
Author

I deleted everything and did a full clean install with docker and it did seem to help some. I installed the approvals plugin again with the plugins.txt file and then enabled it without any errors, but now I am getting the following error when I submit a PO.

Traceback (most recent call last):

File "/root/.local/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)

psycopg2.errors.UndefinedTable: relation "inventree_approval_approval" does not exist
LINE 1: SELECT COUNT(*) AS "__count" FROM "inventree_approval_approv...
^



The above exception was the direct cause of the following exception:


Traceback (most recent call last):

File "/root/.local/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)

File "/root/.local/lib/python3.10/site-packages/rest_framework/generics.py", line 190, in post
return self.create(request, *args, **kwargs)

File "/home/inventree/InvenTree/InvenTree/mixins.py", line 75, in create
self.perform_create(serializer)

File "/root/.local/lib/python3.10/site-packages/rest_framework/mixins.py", line 24, in perform_create
serializer.save()

File "/home/inventree/InvenTree/order/serializers.py", line 312, in save
order.place_order()

File "/usr/local/lib/python3.10/contextlib.py", line 79, in inner
return func(*args, **kwds)

File "/home/inventree/InvenTree/order/models.py", line 525, in place_order
return self.handle_transition(self.status, PurchaseOrderStatus.PLACED.value, self, self._action_place)

File "/home/inventree/InvenTree/generic/states/transition.py", line 77, in handle_transition
rslt = override.transition(current_state, target_state, instance, default_action, **kwargs)

File "/usr/local/lib/python3.10/site-packages/inventree_approval/ApprovalPlugin.py", line 167, in transition
).count()

File "/root/.local/lib/python3.10/site-packages/django/db/models/query.py", line 412, in count
return self.query.get_count(using=self.db)

File "/root/.local/lib/python3.10/site-packages/django/db/models/sql/query.py", line 528, in get_count
number = obj.get_aggregation(using, ['__count'])['__count']

File "/root/.local/lib/python3.10/site-packages/django/db/models/sql/query.py", line 513, in get_aggregation
result = compiler.execute_sql(SINGLE)

File "/root/.local/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1175, in execute_sql
cursor.execute(sql, params)

File "/root/.local/lib/python3.10/site-packages/django/db/backends/utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)

File "/root/.local/lib/python3.10/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)

File "/root/.local/lib/python3.10/site-packages/django/db/backends/utils.py", line 79, in _execute
with self.db.wrap_database_errors:

File "/root/.local/lib/python3.10/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value

File "/root/.local/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)

django.db.utils.ProgrammingError: relation "inventree_approval_approval" does not exist
LINE 1: SELECT COUNT(*) AS "__count" FROM "inventree_approval_approv...
^

@matmair
Copy link
Member

matmair commented Feb 15, 2024

@csmith73 this is the right place to post about this.

There will be an update soon(ish) that needs 0.14.0 so your problem could be solved then.

This error looks like it could be a missing migration. Maybe restart the server and check in the plugins admin pane for any notifications.

@csmith73
Copy link
Author

I tried uninstalling and reinstalling the plugin and restarting the server and now I am getting the following error when I try and issue a PO.

Traceback (most recent call last):

File "/root/.local/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)

File "/root/.local/lib/python3.10/site-packages/rest_framework/generics.py", line 190, in post
return self.create(request, *args, **kwargs)

File "/home/inventree/InvenTree/InvenTree/mixins.py", line 75, in create
self.perform_create(serializer)

File "/root/.local/lib/python3.10/site-packages/rest_framework/mixins.py", line 24, in perform_create
serializer.save()

File "/home/inventree/InvenTree/order/serializers.py", line 312, in save
order.place_order()

File "/usr/local/lib/python3.10/contextlib.py", line 79, in inner
return func(*args, **kwds)

File "/home/inventree/InvenTree/order/models.py", line 525, in place_order
return self.handle_transition(self.status, PurchaseOrderStatus.PLACED.value, self, self._action_place)

File "/home/inventree/InvenTree/generic/states/transition.py", line 77, in handle_transition
rslt = override.transition(current_state, target_state, instance, default_action, **kwargs)

File "/usr/local/lib/python3.10/site-packages/inventree_approval/ApprovalPlugin.py", line 181, in transition
instance.status = PurchaseOrderStatus.PENDING_APPROVAL.value

File "/usr/local/lib/python3.10/enum.py", line 437, in __getattr__
raise AttributeError(name) from None

AttributeError: PENDING_APPROVAL

@matmair
Copy link
Member

matmair commented Feb 15, 2024

Which version did you install?

@csmith73
Copy link
Author

Version 0.4 of approvals plugin and 0.13.5 Inventree version

@matmair
Copy link
Member

matmair commented Feb 15, 2024

@csmith73
Copy link
Author

How do I make sure that it installs the latest one? My current plugins.txt file looks like this

# InvenTree Plugins (uses PIP framework to install)
--index-url https://git.invenhost.com/api/packages/invenhost-c1/pypi/simple/
inventree-approval

I am getting the version # from the plugin admin page inside Inventree is that the correct place to see the version number?

image

@csmith73
Copy link
Author

@matmair I changed my plugins.txt to the following and it installed version .5b4 and it all seems to be working now. Thanks so much for your help.

# InvenTree Plugins (uses PIP framework to install)
--index-url https://git.invenhost.com/api/packages/invenhost-c1/pypi/simple/
inventree-approval==0.5b4

@matmair
Copy link
Member

matmair commented Feb 15, 2024

The version I linked is an alpha so it should not be installed generally - the setting you have is correct normally. You can force the install of the newer (alpha) version by adding ==0.5b4 to the version.

The version you listed is correctly read out.

edit: you were faster than me

@matmair
Copy link
Member

matmair commented Feb 15, 2024

@csmith73 so can I close this? I recommend following me on polar to get notifications when I release InvenHost plugins: https://polar.sh/invenhost/

@matmair matmair added the c/1 label Feb 15, 2024
@matmair
Copy link
Member

matmair commented Feb 15, 2024

Related to #1

@matmair matmair changed the title Approvals Plugin TemplateSyntaxError [PLG:APR] Approvals Plugin TemplateSyntaxError Feb 15, 2024
@csmith73
Copy link
Author

@matmair yes you can close this issue. I am having a different issue now where there is no way to receive items and complete a PO after approval. Should I make a new post for this? Thanks for the polar link I will be sure to follow you on there.

@matmair
Copy link
Member

matmair commented Feb 15, 2024

Yes please make a new issue. I am still figuring out how to track issues for technically closed-source projects (I am using JIRA to manage all this in the backend). InvenHost is a way to test out monetisation strategies for the ecosystem but TBH I am going back open-source if tracking bugs keeps being this hard.

@matmair matmair closed this as completed Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants