-
- Downloads
[FIX] base_import_module: restore `<field file="...">` feature
Revision odoo/odoo@cabb9e7e573b86cd523980588360d8514090d370 introduced a regression: This is no longer possible to import a data module using `<field file="..."/>` in their data file. This revision targets to restore the feature as expected. The unit tests added covers the feature, so that regression no longer happens in the future. It introduces a new concept of temporary directory `file_open` can read from. e.g. ```py with odoo.tools.file_open_temporary_directory(self.env) as module_dir: with zipfile.ZipFile('foo.zip', "r") as z: z.extract('foo/__manifest__.py', module_dir) with odoo.tools.file_open('foo/__manifest__.py', env=self.env) as f: manifest = f.read() ``` Note that `file_open` will be allowed to read from that temporary directory only if `env` is passed to `file_open`, and if the `env` is part of the same transaction/request than the `env` passed to `file_open_temporary_directory`. This is to avoid having users, whether from other databases, or even the same database, trying to access these directories not belonging to them. e.g. If an admin uploads sensitive data in this temporary directory, no one than him must be allowed to read from these files, not even another user from his database. closes odoo/odoo#126320 X-original-commit: ea5cfe2e Signed-off-by:Denis Ledoux (dle) <dle@odoo.com>
Showing
- addons/base_import_module/models/ir_module.py 42 additions, 55 deletionsaddons/base_import_module/models/ir_module.py
- addons/base_import_module/tests/test_import_module.py 40 additions, 0 deletionsaddons/base_import_module/tests/test_import_module.py
- odoo/tools/convert.py 1 addition, 1 deletionodoo/tools/convert.py
- odoo/tools/misc.py 40 additions, 3 deletionsodoo/tools/misc.py
Loading
Please register or sign in to comment