diff --git a/InvenTree/plugin/helpers.py b/InvenTree/plugin/helpers.py index 33259dadf4..0de0c0aaec 100644 --- a/InvenTree/plugin/helpers.py +++ b/InvenTree/plugin/helpers.py @@ -35,7 +35,19 @@ def get_plugin_error(error, do_raise: bool = False, do_log: bool = False, log_na try: package_name = pathlib.Path(package_path).relative_to(install_path).parts[0] except ValueError: - package_name = pathlib.Path(package_path).relative_to(settings.BASE_DIR) + # is file - loaded -> form a name for that + path_obj = pathlib.Path(package_path).relative_to(settings.BASE_DIR) + path_parts = [*path_obj.parts] + path_parts[-1] = path_parts[-1].replace(path_obj.suffix, '') # remove suffix + + # remove path preixes + if path_parts[0] == 'plugin': + path_parts.remove('plugin') + path_parts.pop(0) + else: + path_parts.remove('plugins') + + package_name = '.'.join(path_parts) if do_log: log_kwargs = {}