summaryrefslogtreecommitdiff
path: root/odoo/addons/base/tests/test_misc.py
AgeCommit message (Collapse)Author
2020-09-15[FIX] core: add test on pre/post-commit callbacksRaphael Collet
This test ensures that method `Callbacks.run` is re-entrant, i.e., it can be called from a callback being run. The behavior is to execute the remaining callbacks, and then resume the current one. This completes https://github.com/odoo/odoo/pull/57469. closes odoo/odoo#57774 X-original-commit: 7de434ebc091c4d85615c6cf69240e07b98fe767 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-09-03[FIX] core: cursor hooks API and implementationRaphael Collet
Python 3.8 changed the equality rules for bound methods to be based on the *identity* of the receiver (`__self__`) rather than its *equality*. This means that in 3.7, methods from different instances will compare (and hash) equal, thereby landing in the same map "slot", but that isn't the case in 3.8. While it's usually not relevant, it's an issue for `GroupCalls` which is indexed by a function: in 3.7, that being a method from recordsets comparing equal will deduplicate them, but not anymore in 3.8, leading to duplicated callbacks (exactly the thing GroupCalls aims to avoid). Also, the API of `GroupCalls` turned out to be unusual and weird. The bug above is fixed by using a plain list for callbacks, thereby avoiding comparisons between registered functions. The API is now: callbacks.add(func) # add func to callbacks callbacks.run() # run all callbacks in addition order callbacks.clear() # remove all callbacks In order to handle aggregated data, the `callbacks` object provides a dictionary `callbacks.data` that any callback function can freely use. For the sake of consistency, the `callbacks.data` dict is automatically cleared upon execution of callbacks. Discovered by @william-andre Related to odoo#56583 References: * https://bugs.python.org/issue1617161 * python/cpython#7848 * https://docs.python.org/3/whatsnew/changelog.html#python-3-8-0-alpha-1 (no direct link because individual entries are not linkable, look for bpo-1617161) X-original-commit: a986f4929bab95759086cc77ca5e60795f82e91a
2020-06-24[FIX] tools: Return input_str when removing accents if emptyNasreddin (bon)
Issue The misc feature remove_accents(input_str) return a string 'False' if the param is a boolean. Solution Return input_str if equal '' or False. opw-2278959 closes odoo/odoo#53572 X-original-commit: 3fc7ce3b5599355933734e5e3f59d14a7a9b199c Related: odoo/enterprise#11391 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com> Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
2020-02-05[ADD] sql_db: pre/post-commit/rollback hooksRaphael Collet
2020-01-10[FIX] requirements: update library versions to match Debian BusterChristophe Monniez
Some library versions are outdated since the release of Debian Buster. With this commit the required libraries versions will match as close as possible the versions available in the current Debian stable release (Buster). Also, the requirements were tested against a Windows Python 3.7 to ensure that a "pip install -r" can be used without the need of a CPP compiler. As Babel format_time now returns 'HNE' (Heure Normale de l'EST) for Fr locale instead of the zone offset, the test is adapted. Finally the babel.dates is explicitely imported, otherwise the proper import of this submodule is relying on a side effect. closes odoo/odoo#43106 X-original-commit: 32e455bf72980e6330871aa9cd99c26c6e1225d7 Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2019-11-19[IMP] base: split and deprecate load_langMartin Trigaux
load_lang was a kind of hybrid method trying to active or creating a language if not found. This was error prone. Instead rely on two methods with clear purpose: ResLang._create_lang(lang, lang_name=None) - create a new res.lang entry using the locale of the server return the res.lang record to match the API of _activate_lang ResLang._active_lang(code) - activate the given code lang Most of the time, _active_lang is what is expected tools.trans_load_data and IrTranslation._load_module_terms no longer activate the language if not active. Loading the translations should be explicit on an activated language, it is too error prone to silently activate/create a language if not found. Remove lang_name from trans_load_data as no longer needed.
2019-11-05[IMP] base: Adapt tests to work with/without demo dataYannick Tivisse
2019-08-21[IMP] fields: extend selection with a given orderRaphael Collet
When extended with the selection_add parameter, a singleton (value,) where `value` appears in the overriden selection, can be used. The new values are inserted in an order that is consistent with the overridden selection and this list. selection = [('a', 'A'), ('b', 'B')] selection_add = [('c', 'C'), ('b',)] > result = [('a', 'A'), ('c', 'C'), ('b', 'B')]
2019-07-16[MERGE] Forward port of saas-12.4 to master up to beba36416fdf2Martin Trigaux
closes odoo/odoo#34924 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-07-11[IMP] core: improve test_tagsXavier-Do
Add the support to be able to specify exlicitely module, class and method name in test_tags Before this commit, there is no distinction between module tag and test tag. Meaning that --test-tag module_name will replace the default +standard tag and execute all test of the module. This commit tries to keep the initial behaviour, while addind new features, like explicit modules tag with /module_name, as well as class (:class) and method (.method) Some usage examples: --test_tags /module will execute all standard test of module --test_tags :class will execute all standard test with class name 'class' --test_tags .method will execute all standard test with method name 'method' --test_tags external/module will execute all external test of module --test_tags */module will execute all tests of module, --test_tags */module,-standard will execute all non standard tests of module, --test_tags -/website:TestUiTranslate.test_admin_tour_rte_translator will disable only rte translator test closes odoo/odoo#34756 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2019-07-04[IMP] tools: introduces format_timejem-odoo
In some module, we gonna need to display time part in name_get. So, it is interesting to have a helper doing that for us. Time part label depends on the language, format, and timezone. This commit introduces this tool, based on `babel` lib like the other helpers. Tests are provided. Task-2024216
2019-06-28[REF] mail: template: move formatting to toolsThibault Delavallée
This commit moves formatting helpers method used in mail.template to tools. The goal is to reuse them anywhere in odoo, and not only in mail templates. Thoses method are used to format date, datetime, amount, ... according to user localization (currency, language, pattern, ...). This commit also improve the formatting methods of 'date' and 'datetime': we are now taking the 'lang_code' into account. Indeed, as the implementation uses `babel` lib, it is easy and usefull to add the language option, to display the given dates into a particular language. This parameter is optional to keep compatiblity with existing code. Task-2025396 Code Courtesy of @tde-banana-odoo
2018-08-10[FIX] orm: Adapt test and read_group_fill_temporalFrancois Volral
In the commit 4a40db2. the implementation of read_group_fill_temporal was simplified during final review and tests needed to be adapted. Also fix the implementation issues as detected by the tests.
2018-08-10[IMP] orm: add support to fill temporal holes (read_group)Francois Volral
This commit add an extra parameter 'fill_temporal' to read_group which allows the orm to add missing groups for date intervals. This is useful for charts. Suppose that we are in a use case where data are grouped by a date fields (typically months but it could be another interval) and displayed in a Bar Chart or a Line Char. Let's says a request has to group records by month for August, September and ...December. If we don't changed anything, we would get a Bar Chart looking like this : ___ ___ | | | | | | | | ___ | | | || || | |___||___||___| Aug Sep D December follows directly after September, it can be unintuitive for the user, so we change that. We add some fake records for each missing months between the earliest and the lastest date of the result ___ ___ | | | | | | | | ___ | | | || | | | |___||___| ___ ___ |___| Aug Sep Oct Nov Dec This commit is part of task #1835644
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-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-02-09[IMP] tools: add format_date methodNicolas Martinelli
Add a method to format a date in a given language. This appears to be useful since formatting is not always done by QWeb, but also: - in mail templates - in formatted strings (error messages, pre-filled text fields)
2016-09-02[REF] openerp: move `openerp` to `odoo`Raphael Collet