summaryrefslogtreecommitdiff
path: root/odoo/modules/module.py
AgeCommit message (Collapse)Author
2019-09-12[IMP] core: improve logging in case of subtest failureXavier-Do
closes odoo/odoo#36787 Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2019-08-07[IMP] *: fix typos in commentsmreficent
closes odoo/odoo#35404 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-07-30[FIX] core: log error on addSubTestXavier-Do
Since #34996, in some case, the error detail was not logged keeping only the final summary "x errors, x failures" when running TestSuite. Making fail test test_cache_invalidation for instance won't show a detailed message when breaking test_01_project_tour will. This issue occurs when using subtest, like with assertQueryCount, @users decorator, test_all_l10n, and test_youtube_urls. Since Testresult addSubTest append directly to error and failures instead of calling addError and addFailure, we need to ovewrite addSubtest too. closes odoo/odoo#35270 Signed-off-by: Denis Ledoux <beledouxdenis@users.noreply.github.com>
2019-07-25[IMP] core: improve test logsXavier-Do
1. Make test logs clearer & remove redundancies Instead of having an ERROR log right when the test fails then print the useful / relevant information at the end of the test suite, immediately print the traceback. Keep the final summary. Also avoids having to wait for the entire test suite to end before a dev' can know the failure details of a specific test. Done by working at a lower level and replacing the custom test stream mess by a custom Result class which prints and formats the information we want. Replace TextTestRunner by a bare-bones custom Runner object to tie it in. 2. Provide useful location information on test failure Leverage the work above to log the test function's failure location: previously logging would point to within TestStream which is not useful. Here, on failure the traceback is used to discover the caller info and point to the test line which fails instead. similar to unittest's _exc_info_to_string (https://github.com/python/cpython/blob/93e8aa62cfd0a61efed4a61a2ffc2283ae986ef2/Lib/unittest/result.py#L173). 3. Replace direct logging in browser_js by raising errors Properly marks the test as in error, and the error traceback points to the tour definition / launcher (python side) rather than common.py and/or module.py. Also removes unused dbname parameter that was added in /278ed718e9805edf088642ba10d3b7c4e5716c31/openerp/modules/module.py#L361 for nor visible reason closes odoo/odoo#34996 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2019-06-05[IMP] core: log traceback in one groupXavier-Do
Traceback coming from tests are currently logged line by line. This will implies that runbot will have one ir_logging entry per line which is not practical. More than that, the log prefix can make the traceback less readable because of line returns and difficult to copy paste. This commit simply remove this feature. After discussion with odo and chs, we will also remove the docstring from test shortDescription since most of the time this information is not clear and can be accessed in source code if needed. closes odoo/odoo#33911 Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2019-05-07[IMP] core: allow auto_install restriction on a subset of dependenciesXavier Morel
Currently, auto_install is triggered when all dependencies get installed, but there are cases where one would want such trigger on only a subset thereof. e.g. we want `website_sale_dashboard` to auto-install when `website_sale` is installed. Currently, it requires `web_dashboard` to also be auto-installed otherwise `website_sale_dashboard` would "wait" for both dependencies to be explicitly installed before the auto-install triggers. That's despite `web_dashboard` not being very useful on its own. More generally this is an issue with technical modules which need to be marked as auto_install so as not to block e.g. bridge modules from automatically installing. This change allows setting `auto_install` to a subset of `depends`: * if auto_install is set to `False`, the module does not get automatically installed (no change in semantics) * if auto_install is set to `True`, the module gets automatically installed if and only if all its dependencies are installed (also no change in semantics) * if auto_install is set to a list of dependencies, the module will be installed when all *these* dependencies are installed, other dependencies (excluded from auto_install) will be installed alongside as a consequence * auto_install can be set to an empty list, in this case the module will always be automatically installed regardless of its dependencies (and will force their installation). So after this change, `web_dashboard`'s auto_install can be set to `False` (such that it's not installed if no module defining dashboards is installed) and `website_sale_dashboard`'s manifest can be edited to: 'auto_install': ['website_sale'] possibilities: # no automatic installation 'depends': ['a', 'b'], 'auto_install': False # automatic installation if both a and b are installed 'depends': ['a', 'b'], 'auto_install': True # automatic installation if both a and b are installed (explicit) 'depends': ['a', 'b'], 'auto_install': ['a', 'b'] # automatic installation if b is installed, a will get forcefully # installed if it isn't yet 'depends': ['a', 'b'], 'auto_install': ['b'] # always automatically installed, will cause the installation of # its dependencies even if they're not marked explicitly 'depends': ['a', 'b'], 'auto_install': [] Task 1851328 closes odoo/odoo#29431 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2019-01-18[MERGE] forward port branch 12.0 up to f854e01a983Christophe Simonis
2019-01-16[MERGE] forward port branch saas-11.3 up to 83cc046e9a9Christophe Simonis
2019-01-15[MERGE] forward port branch 11.0 up to 4f2f2995346Christophe Simonis
2018-11-29[REM] pycompat: remove python 2 shims and helpersAdrian Torres
Odoo no longer supports python 2, thus some of these helpers can and have been replaced by python 3 built-ins, therefore there is no need for them to stay defined. The removed helpers are: * izip, imap and ifilter * unichr, text_type * implements_to_string, implements_iterator * string_types, integer_types * to_native The python 2 shims have also been removed, and only the python 3 helpers have been kept, because they can still be usable (i.e. accepting both bytes and str for functions that can only accept one of the two) [REM] pyjsparser: remove PY3 shims They're no longer necessary as Odoo doesn't officially support python 2 anymore. closes odoo/odoo#28519
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-11-01[FIX] odoo: fix addons paths on windows with use of normcaseAndreas Perhab
This is necessary to get --dev=xml working on windows, because the xml import uses normcase in file_open and the case normalized filename is then used to find the addon path (which was not found before on windows) With this fix arch_fs is now correctly filled in windows and --dev=xml works. closes odoo/odoo#28331
2018-08-06[IMP] *: only show 'learn more' when there is a web page describing the moduleFabien Pinckaers
2018-01-18[IMP] tests: Add the possibility to tag testsChristophe Monniez
Purpose: When running tests, all the tests for the installed/updated files are done. This commit adds a 'tagged' decorator that can be used to tag tests. Combined with a new 'test-tags' CLI option, it adds the ability to filter which tests are executed. For example, @tagged('slow') will add a tag 'slow' to the test. The CLI option 'test-tags="slow"' will only run tests tagged 'slow'. One can use prefixes to select cases with tags. '+' or no prefix means that the tests tagged with this tag are selected for execution. '-' prefix will exclude the tests tagged with this tag. Exclusion takes precedence over inclusion. Also, by default, all Odoo tests cases are tagged 'standard' and with the technical name of the module. This means that when selecting tests with the 'test-tags' parameter, if '-standard' is not specified, all tests tags are going to be executed. When tagging tests, one can remove such automatic tag by prefixing the tag name with '-'. E.g. @tagged('-standard') will remove the standard tag from the test. Another example, if one wants to test the 'sale' module alone, even without adding any 'tagged' decorator thos tests can be selected like that: --test-tags="sale" Tests are selected or deselected using a TagsSelector. When instanciated, a string is passed with comma separated tests selectors like '+slow,-standard'. When the 'check' method is called with a test as argument, it returns True or False if the test has to be executed or not.
2017-10-03[FIX] odoo: bad imports in tests don't fail silently anymoreRichard Mathot
Before this fix, you can break a test class by simply adding an incorrect import like this: `from gloubiboulga import Casimir` --> No error message, the test is simply not run This is due to the fact that we want to ignore ImportError's... only when there is no `.tests` submodules (actually, we ignored them all!) This commit fixes the condition and re-enables error logging when tests actually encounter ImportErrors
2017-10-03[imp] module,http: open manifest files as utf-8 in a python2/3 compatible wayChristophe Monniez
2017-10-03[FIX] modules: Verify that an addons path existsChristophe Monniez
2017-08-20[FIX] P3: ImportError text changed & text model fixXavier Morel
2017-08-19[FIX] P3: reorder finders in meta_pathXavier Morel
So that was a fun one: mock.patch calls would regularly fail refusing to find the addon in odoo.addon (e.g. essentially getattr(odoo.addon, 'account_budget' deep within the bowels of mock). Turns out the answer is that our import hooks would not be used for many imports: while in Python 2, sys.meta_path is empty and the default finders are run after all meta_path finders fail as noted by the documentation[0]. However when the import system was rewritten in Python 3.3[1] meta_path was "despecialised" and the default finders were moved to meta_path rather than be a hidden part of the import machinery[2]: > sys.meta_path and sys.path_hooks now store all of the meta path > finders and path entry hooks used by import. Previously the finders > were implicit and hidden within the C code of import instead of > being directly exposed. The result of this change is that ``sys.meta_path.append`` means the default finders should take priority and the custom ones should be fallback. This is the exact opposite of what we want. Fix issue by ``sys.meta_path.insert``-ing our finders at the start of the path rather than appending them at the end. This should change nothing in Python 2 but seems to fix the issue in P3. [0] https://docs.python.org/2/library/sys.html?highlight=meta_path#sys.meta_path [1] https://docs.python.org/3/whatsnew/3.3.html#importlib [2] https://docs.python.org/3/whatsnew/3.3.html#visible-changes
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-27[FIX] builtins removed from Python 3xmo-odoo
* Reverse wrapper courtesy of @rco-odoo's original P3 branch * thin compat module stripped down from werkzeug (to augment as needed) issue 8530
2017-04-14[MERGE] forward port branch saas-15 up to b0992d082daChristophe Simonis
2017-04-13[FIX] modules: do not log warnings for `studio_customization`Raphael Collet
2017-04-11[#8530] convert exception handlers to except..as syntaxXavier Morel
Futurize fixers: * lib2to3.fixes.fix_except
2017-01-27[FIX] module: allow disabling 1-click installOlivier Dony
As discussed on issue #15225, it should be possible for system administrators to disable the 1-click installation system. The plan is to disable the feature by default, but make it relatively easy to turn on when it is explicitly desired. 1. At the moment we cannot guarantee that all Apps published on the Odoo Apps Store are safe. And it is a security risk to let end-users deploy Python code on their Odoo servers without requiring any review/deployment by a competent system administrator. We will work on improving the validation process of the Store, but this will require time, and won't probably be a 100% safe process in any case. 2. The one-click install feature is however really useful to help non-technical users install Apps, as long as the feature has been explicitly allowed by the system administrator. This is a common feature in other software suites as well. So we'd like to keep it as an opt-in feature. 3. Administrators of multi-tenant servers, cloud hosting services, etc. understandably expect to be able to turn off the feature for security/control reasons. 4. By turning off the feature by default, but still exposing it in the UI, we keep it *discoverable* for users. The error message should be helpful to direct users to their sysadmins. 5. By using the permissions of the download folder as a flag for turning off the feature, we avoid introducing an extra server parameter. The folder is still created (read-only) by default, for the sole purpose of making it easier to locate. Fixes #15225
2016-11-22[FIX] modules: add missing parameter to find_moduleangelfentanez
AddonsImportHook's find_module method to follow PEP302 by setting None as default for the path parameter Similar to edeb5a8c Fixes #14087 Closes #14088
2016-09-30[REF] packaging: make odoo a namespaced package=?UTF-8?q?St=C3=A9phane=20Bidoul=20=28ACSONE=29?=
by auto-extending addons path with odoo.addons.__path__. This patch also introduce * an explicit declaration of odoo.addons as a namespace package This is necessary because the standard way of declaring namespace packages in setup.py does not work as long as odoo/__init__.py contains code. * a more reliable way to find odoo root path.
2016-09-16[FIX] core: adpat 9874892b9 to multiple manifest filesChristophe Simonis
2016-09-16[MERGE] forward port branch saas-12 up to 10cde43Christophe Simonis
2016-09-05[IMP] support v10 manifest file naming conventionOlivier Dony
- As of v10, manifest files should be named `__manifest__.py` - For backwards-compatibility, __openerp__.py manifest files will still be supported for the time being - Limited refactoring, to add support for the 2 different naming conventions - All textual references to __openerp_.py updated in documentation and examples
2016-09-05[IMP] module: parse manifest files with literal_evalOlivier Dony
Manifest files are literal Python dictionaries, and aren't supposed to contain expressions that require a full-fledged eval. `literal_eval` is therefore sufficient *and* safer. This parsing method was already used when listing addons during startup of the Root controller (http.py, load_addons())
2016-09-02[FIX] odoo: rename imports and adapt import hooksRaphael Collet
2016-09-02[REF] openerp: move `openerp` to `odoo`Raphael Collet