oca-ocb-core/docs/PATCH_ADDONS_PATH.md
Ernad Husremovic dd3f495ba4 Fix _NamespacePath concatenation error in file_path function
Convert odoo.addons.__path__ to list before concatenation with [root_path]
to fix TypeError when using Python 3.7+ namespace packages.

Error: unsupported operand type(s) for +: '_NamespacePath' and 'list'
Location: odoo/tools/misc.py:169

Added documentation explaining the fix in docs/PATCH_ADDONS_PATH.md

🤖 assisted by claude
2025-10-16 16:51:35 +02:00

1.4 KiB

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:

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:

addons_paths = list(odoo.addons.__path__) + [root_path]

File Modified

  • odoo-bringout-oca-ocb-base/odoo/tools/misc.py line 169

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