diff --git a/docs/PATCH_ADDONS_PATH.md b/docs/PATCH_ADDONS_PATH.md new file mode 100644 index 00000000..f02979ed --- /dev/null +++ b/docs/PATCH_ADDONS_PATH.md @@ -0,0 +1,48 @@ +# Fix for _NamespacePath Concatenation Error + +## Issue + +After upgrading, Odoo failed to start with the following error: + +``` +TypeError: unsupported operand type(s) for +: '_NamespacePath' and 'list' +``` + +This occurred in `odoo/tools/misc.py:169` in the `file_path()` function. + +## Root Cause + +In Python 3.7+, namespace packages use `_NamespacePath` objects for the `__path__` attribute. This special type cannot be directly concatenated with a Python list using the `+` operator. + +The problematic code was: +```python +addons_paths = odoo.addons.__path__ + [root_path] +``` + +When `odoo.addons.__path__` is a `_NamespacePath` object, attempting to add it to a list `[root_path]` raises a `TypeError`. + +## Solution + +Convert the `_NamespacePath` to a list before concatenation: + +```python +addons_paths = list(odoo.addons.__path__) + [root_path] +``` + +## File Modified + +- `odoo-bringout-oca-ocb-base/odoo/tools/misc.py` line 169 + +## Related Code + +The `file_path()` function is used throughout Odoo to: +- Verify file paths under known `addons_path` directories +- Locate module resources (icons, static files, etc.) +- Validate file access for security purposes + +This fix ensures the function can properly construct the list of addon paths to search. + +## References + +- Python namespace packages: [PEP 420](https://www.python.org/dev/peps/pep-0420/) +- Working commit reference: 3f19943cec2680164696765266fc0cdb4e9220c5 diff --git a/odoo-bringout-oca-ocb-base/odoo/tools/misc.py b/odoo-bringout-oca-ocb-base/odoo/tools/misc.py index 5dad940b..290f3cfa 100644 --- a/odoo-bringout-oca-ocb-base/odoo/tools/misc.py +++ b/odoo-bringout-oca-ocb-base/odoo/tools/misc.py @@ -166,7 +166,7 @@ def file_path(file_path, filter_ext=('',), env=None): :raise ValueError: if the file doesn't have one of the supported extensions (`filter_ext`) """ root_path = os.path.abspath(config['root_path']) - addons_paths = odoo.addons.__path__ + [root_path] + addons_paths = list(odoo.addons.__path__) + [root_path] if env and hasattr(env.transaction, '__file_open_tmp_paths'): addons_paths += env.transaction.__file_open_tmp_paths is_abs = os.path.isabs(file_path)