summaryrefslogtreecommitdiff
path: root/addons/base_import_module/models/ir_module.py
AgeCommit message (Collapse)Author
2020-10-07[FIX] base_import_module: avoid accessing deleted columnsAdrian Torres
Commit 59eee6ba5fed0ba74221f44a296ec6efedbc2527 introduced a cleanup mechanism for external data modules being uninstalled from a database, this meant deleting the ir.module.module entry created when first installing the aforementioned external module. However, the above patch has one small oversight: the access of the `imported` field introduced by the `base_import_module` module is done after the `super().module_uninstall()` call which, in the case of the uninstall of the `base_import_module` module, will delete the `imported` column and the following call to filtered will fail because the column has already been deleted and the registry hasn't been reloaded yet. The solution to this, as explained in the code comment, is to simply compute the `modules_to_delete` before the call to `module_uninstall()`. closes odoo/odoo#59412 X-original-commit: c0226087b82ffda3971bb953d8d00b8c5e67642c Signed-off-by: Raphael Collet (rco) <rco@openerp.com> Signed-off-by: Adrian Torres (adt) <adt@odoo.com>
2020-06-18[IMP] *: replace to new _() syntaxMartin Trigaux
Using a few regex like \((_\(.*%s.*)(\) % )([\w\[\]][\w .\[\]\(\)'"]*)\) ($1, $3)) Old syntax is still compatible but starts the migration to the new syntax that catches error.
2019-12-20[IMP] base_import_module: clean up after itselfDamien Bouvy
Uninstalling an imported module leaves behind an ir.module.module entry which is entirely useless: it cannot be reinstalled without re-uploading the module. A quick solution is provided here by simply cleaning up after the uninstallation and deleting the ir.module.module records of imported modules that just got removed. Another possibility could be to store the uploaded module for good in an attachment and re-load it from there upon re-installation, but that would lead to some conflict with Studio, as uninstalling the studio_customization module usually means you want to get rid of it for good.
2019-10-30[IMP] core: mark a few osutil functions as deprecatedXavier Morel
* walksymlinks is useless, os.walk got followlinks in 2.6 * tempdir is redundant with tempfile.TemporaryDirectory added in 3.2 * listdir(recursive=False) is just os.listdir (I guess recursive=True is somewhat useful) * zip_dir is *not* redundant with shutil.make_archive: - zip_dir handles the archived root differently - zip_dir sorts files, make_archive sorts directories - make_archive explicitly adds entries for directories (including empty), sorts directories, doesn't sort files; zip_dir sorts files (including with a custom key function) but ignores directories - zip_dir filters out a bunch of trash files closes odoo/odoo#39573 Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-20[IMP] module.py: deprecate openerpJulien Castiaux
[PEP-594] is deprecating the `imp` module, that module is used in `module.py` in order to dynamically import addons using any of the `odoo.addons` or `openerp.addons` import anchor. We are deprecating `openerp` module/addons imports in v13 in order to remove the support in v14 and greatly simplify how modules/addons are loaded. If you are still using the old `import openerp` or `import openerp.addons`, `import odoo` and `import odoo.addons` are drop-in replacements. The `odoo.modules.module.ad_paths` addon paths list has been deprecated too. The list is now accessible on `odoo.addons.__path__` where they are now directly loaded [2]. See also: [PEP-594]: https://python.org/dev/peps/pep-0594/ [2]: https://packaging.python.org/guides/packaging-namespace-packages/ closes odoo/odoo#36597 Task: 2003936 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2019-07-17[REM] *: calls to @api.multiAdrian Torres
Multi is the default api for methods, it is not necessary to explicitly decorate methods with it, adds clutter and most people use it because they see that the rest of the code uses it. Done with `find . -type f -name '*.py' | xargs sed -i '/@api.multi/d'`
2019-06-05[REF] *: removes datas_fname from ir.attachmentThanh Dodeur
This commit removes the field `datas_fname` from `ir.attachment` as it was unnecessary and most of the time the duplicate of `name` or `url`. Task #1909865 closes odoo/odoo#32976 Signed-off-by: Martin Geubelle (mge) <mge@openerp.com>
2019-05-13[MERGE] forward port branch saas-12.3 up to 60e71302a38Christophe Simonis
2019-05-07[IMP] base_import_module: improve module dependencies error messageJuhil Somaiya
Currently, when trying to import a module, if there is an error related to dependencies, it is not shown in a decent format. For example, technical names of the modules are being displayed in a single line, separated by comma. This commit makes the dependency error message readable by displaying short description of the modules (instead of technical names), each on a new line. task-1830483 closes odoo/odoo#33029 Signed-off-by: Martin Geubelle (mge) <mge@openerp.com>
2019-04-26[MERGE] forward port branch 12.0 up to c9913152ecbDenis Ledoux
2019-04-25[MERGE] forward port branch saas-11.3 up to 6fd637e1319Denis Ledoux
2019-04-24[MERGE] forward port branch saas-15 up to 0c46c8a929dDenis Ledoux
2019-03-06[IMP] base_module_import: ignore garbage directoriesxmo-odoo
If the zipfile contains some garbage directories (e.g. leftover empty directories from git, `__MACOSX` metadata folder, …) it seems unnecessary to log an error, just skip the directory and don't mark it as a proper / successful module. closes odoo/odoo#31639 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2018-11-29[REF] *: replace deprecated pycompat helpers for builtinsAdrian Torres
This commit replaces calls to pycompat helpers that were intended for python 2 <-> python 3 interoperability for python 3 builtins, as python 2 is no longer officially supported by Odoo. This includes: * calls to imap/izip/ifilter replaced by map/zip/filter * uses of text_type replaced by str * uses of unichr replaced by chr * calls to implements_to_string, implements_iterator removed * string_types and integer_types replaced by str, int respectively * calls to to_native replaced by calls to to_text This is done in preparation to the removal of these deprecated helpers in the following commit.
2018-05-28[IMP] all: Improve error messagesBenjamin Stiens
Many error messages are misleading or too "vague" This task aims to improve all error message. Task #47042 PR #23321
2018-04-23[FIX] base_import_module: imported module versionNicolas Martinelli
- Create a simple module, set version to 2.0 - Import the zip file The 'Latest Version' (field `installed_version`) is set to 11.0.1.0, while one would expect 11.0.2.0. There are several reasons for this. First, the method `get_values_from_terp` doesn't return the version, so at this point the information is already lost. Then, the field `installed_version` is a computed field which retrieves the version from the `__manifest__.py` file. In the case of an imported module, there is no such file in which we can look up for the value (even though the imported module contained one). To avoid this, we explicitly set the 'Installed Version' (field `latest_version`) to the version retrieved at import. Since this field refers to the version installed in the database, it makes sense to use it this way. Moreover, in the case of imported modules, we use the value of `latest_version` for `installed_version`. Fixes #23988 opw-1833522
2018-02-26[FIX] base_import_module: don't assume data/ existsAdrian Torres
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.
2017-11-24[FIX] base_import_module: decoding errorNicolas Martinelli
In P3, `url_path` is already decoded in UTF-8, and therefore cannot be decoded. opw-783978 Closes #20912
2017-10-31[FIX] base_import_module: display correct errorAdrian Torres
Previous to this commit, when importing a studio module with unmet dependencies that were not studio the error message would just display the Studio is required to install Studio customizations. With this commit it should now correctly display the missing dependencies by checking if only web_studio is in the set of unmet dependencies opw-777642
2017-10-11[IMP] base_import_module: Add layer of security (#19175)Adrian Torres
Previous to this commit, anyone could import studio customizations into a community db, this was troublesome since some people would just install studio, do their customizations and then move them into a community db, not paying anything at all. This commit fixes this by checking whether the exported views were created with studio or not and if studio is installed
2017-08-20[FIX] P3: remove pycompat.{keys,items,values} helpersOlivier Dony
Now that we're closer to switching to P3 for good, these helpers have outlived their usefulness, and mostly add noise. All remaining dict.iter*() or dict.view*() must be converted to the normal keys(), values() or items() calls. Whenever the result is likely to be used for more than the scope of a loop, or when the dict needs to be modified during iteration, the calls must be wrapped in a ``list()``, to protect the new P3 semantics. Those cases are very exceptional. Also removed some dead code or improved the API to remove unnecessary conversions.
2017-08-20[FIX] P3: fix base64 and StringIO usesXavier Morel
* StringIO removed from stdlib, replace with io * try to correctly handle BytesIO/StringIO (one is for bytes the other is for text) * fix base64: Python 3 removed bytes-encoding and bytes-bytes codecs (via #encode) so replace all calls to str.encode('base64'), also b64encode is a bytes->bytes conversion so attempt to properly handle that issue #8530
2017-06-09[MERGE] forward port branch saas-16 up to cc38b93ab2aChristophe Simonis
2017-06-09[MERGE] forward port branch saas-15 up to 49f819a7a79Christophe Simonis
2017-06-07[MERGE] Forward-port saas-11 up to fff4af36abb28a26977928455fe20fbcd135399eOlivier Dony
2017-06-07[MERGE] Forward-port saas-6 up to b604f3b3daf063a621bb118befb5a0fd792f0af0Olivier Dony
2017-06-07[MERGE] Forward-port 8.0 up to c6b9b69f6a483e7ccebf0b823240b71a8f426fd3Olivier Dony
2017-06-07[FIX] base_import_module: allow selective access to module filesOlivier Dony
As a consequence of rev. 76cd8d2558d2a1fc11681dbc4a134ba06fb698c0, imported modules were unable to access their resource files during import. Rather than further modifying the file_open API to whitelist paths (the whole thing needs a redesign in master), we temporarily whitelist the temporary directory by including it in the global addons_paths, making sure to undo it afterwards. This gives all lower level function access the resource files via file_open, without having to pass around whitelisted paths through many different calls.
2017-06-06[MERGE] forward port branch saas-16 up to 6f3eada2c3aChristophe Simonis
2017-06-06[FIX] base_import_module: make low-level method privateOlivier Dony
The import_module() method does not need to be public, so let's mark it private. It's not called by anyone except import_zipfile(). After 76cd8d2558d2a1fc11681dbc4a134ba06fb698c0 it would fail anyway because addons_path would not be prepared by import_zipfile().
2017-05-10[FIX] P3: list -> iterable builtins (#16811)xmo-odoo
In Python 3: * various builtins and dict methods were changed to return view/iterable objects rather than lists * and the separate Python 2 view/iterable builtins and methods were removed altogether This is problematic when using these items as list (which the happens repeatedly in Odoo), but more viciously when iterating *multiple times* over them (which also happens, which I've messed up multiple times while writing this, and which is a pain to debug even when you've just created the issue). Convert all code using these to semantics-matching cross-version helper functions to get the LCD behaviour between P2 and P3, and forbid the builtins via lint. issue #8530
2017-04-11[#8530] convert exception handlers to except..as syntaxXavier Morel
Futurize fixers: * lib2to3.fixes.fix_except
2016-10-10[MERGE] forward port branch saas-12 up to 43cb4acChristophe Simonis
2016-10-03[MERGE] Forward-port 8.0 up to 3d55aff1c83d3157228852d1fe28efe82d7cc329Olivier Dony
2016-10-03[FIX] base_import_module, tools: raise a clear error for unsupported file typesOlivier Dony
Also restrict XML data attribute evaluation context even for real module data files. This will prevent accidentally depending on context parameters that would not be available inside base_import_module.
2016-10-03[FIX] base_import_module, tools: raise a clear error for unsupported file typesOlivier Dony
Also restrict XML data attribute evaluation context even for real module data files. This will prevent accidentally depending on context parameters that would not be available inside base_import_module.
2016-07-13[MIG] base_import_module: Migrated to new APIMohammed Shekha
2015-11-25[MERGE] forward port of branch saas-6 up to dade7e3Christophe Simonis
2015-11-17[MERGE] forward port of branch 8.0 up to c9fce1aDenis Ledoux
2015-11-06[FIX] base_import_module: exception logger for module importsDenis Ledoux
When importing a module, if an error was raised during the import, the traceback wasn't displayed anywhere, making harder the debugging. While it make sense to not display the entire traceback to the user, in the web client, this is useful to diplay the traceback in the logs, for debugging purposes. opw-653882
2015-10-01[MERGE] forward port of branch saas-6 up to e9f1ee4Christophe Simonis
2015-09-30[MERGE] Forward-port 8.0 up to rev. 26d0fe6d9f645ec128182bb2f4f8b9808ad05004Olivier Dony
2015-09-28[FIX] base_import_module: special chars in error messagesArnaud Pineux
use ustr() instead of str() to avoid traceback with translations Closes #4272
2015-08-31[ADD] base_import_module: add boolean field `imported` on `ir.module.module`Thomas Groutars
2015-01-16[IMP] Cleanup and refactoring of exception handlingGoffin Simon
Unify and refactor exception handling in framework and addons. The generic `except_osv` is now deprecated, and replaced by more specialized exception subtypes: - `UserError` (renamed from Warning, as it conflicts with the built-in `Warning`) raised when a non-technical error occurs during a business operation. It could be a missing information in the data provided by the user, or a misconfiguration. - `AccessError`: raised when any operation is denied because the user conducting it does not have the required access rights. - `AccessDenied`: raised when an operation that requires authenticated access is attempted via an unauthenticated request. - `MissingError`: raised when an operation is attempted on a record that does not exist. - `ValidationError`: raised when an operation violates a SQL or Python constraint. - All other exceptions are internal errors due to a system problem or bug, and raised untouched to the client-side, which should display a traceback. All exceptions take a single message argument. The `test_exceptions` module has been updated to showcase both new and old (deprecated) exceptions. A great many old `except_osv` had a useless title with "Error!" or "Warning", those have been removed, as this is handled by the client-side widget that displays the messages. This commit introduces a more consistent policy for logging errors and warnings: - All messages that do not require administrator attention should be logged at INFO level or lower. This includes all errors that are notified to the user in a friendly manner, even for access right problems or validation errors during business operations. - All messages that indicate a likely misconfiguration or malicious use by the users should be logged at WARNING level, as they typically require administrator attention. - All other unhandled internal errors cannot typically be handled by the user and should be logged at ERROR or higher level, as they require immediate administrator attention.
2014-09-05[FIX] Some fixes for base_import_moduleFabien Meghazi
- Properly check unmet dependencies - Set imported module's state to 'installed' - Fix bad translation usage
2014-06-11Added --force to odoo deployFabien Meghazi
Will force --init mode even if module is already installed
2014-05-22[IMP] improved code to show import result in wizard and improved typotpa-odoo
2014-05-22[ADD] add wizard to import zipped moduletpa-odoo
2014-03-24[IMP] Properly import filesFabien Meghazi
bzr revid: fme@openerp.com-20140324151711-89mfg14573dpnh0p