From d33ce2b4d1e7521cb1d86b9b69ccf670205a2750 Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Mon, 26 Feb 2018 15:33:37 +0100 Subject: [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. --- addons/base_import_module/models/ir_module.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'addons/base_import_module/models/ir_module.py') 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 -- cgit v1.2.3