diff options
| author | Adrian Torres <adt@odoo.com> | 2018-02-26 15:33:37 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-26 15:33:37 +0100 |
| commit | d33ce2b4d1e7521cb1d86b9b69ccf670205a2750 (patch) | |
| tree | 613b758db8475a7cf0221a4b9b9ea408b9f02d2a /addons/base_import_module/models/ir_module.py | |
| parent | 25b49fe6247930f71a0a43e2ec55a1ed30b275d1 (diff) | |
[FIX] base_import_module: don't assume data/ exists
Before this commit, while performing a check on whether a customization
being imported was done using studio or not, we would assume that the
.zip would, at the very least, contain a data folder.
This is not the case as loose files can be imported and the data folder
is only generated by studio customizations.
To solve this, we walk over the whole zip instead of walking over the
data/ folder only (which may be non-existant), so loose files, files
inside the data folder and potentially files in other folders can be
parsed without raising unexpected errors.
Diffstat (limited to 'addons/base_import_module/models/ir_module.py')
| -rw-r--r-- | addons/base_import_module/models/ir_module.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/addons/base_import_module/models/ir_module.py b/addons/base_import_module/models/ir_module.py index aaa1e69946a..d9c3d4092a2 100644 --- a/addons/base_import_module/models/ir_module.py +++ b/addons/base_import_module/models/ir_module.py @@ -145,12 +145,13 @@ def _is_studio_custom(path): Returns True if any of the records contains a context with the key studio in it, False if none of the records do """ - path = os.path.join(path, 'data') - filenames = next(iter(os.walk(path)))[2] - filenames = [f for f in filenames if f.lower().endswith('.xml')] + filepaths = [] + for level in os.walk(path): + filepaths += [os.path.join(level[0], fn) for fn in level[2]] + filepaths = [fp for fp in filepaths if fp.lower().endswith('.xml')] - for filename in filenames: - root = lxml.etree.parse(os.path.join(path, filename)).getroot() + for fp in filepaths: + root = lxml.etree.parse(fp).getroot() for record in root: # there might not be a context if it's a non-studio module |
