summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/core/util_tests.js
AgeCommit message (Collapse)Author
2021-05-28[IMP] web: add findWhere utilsBruno Boi
closes odoo/odoo#70936 Taskid: 2412172 Related: odoo/enterprise#18366 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-06-22[IMP] web: utils: add groupBy functionJulien Mougenot
This commit introduces a new utility function: 'groupBy'. It is similar in API and result as the underscore method of the same name. X-original-commit: 834a1967161dc537cb2d5543314a062dbac08f9c
2020-05-05[IMP] web: add sortBy to core.utilsJulien Mougenot
Add a "sortBy" helper to core utils. This function takes an array and an optional criterion as arguments and returns a new array sorted according to the given criterion.
2020-03-16[FIX] web: rounding errorNicolas Martinelli
In JavaScript, the following computation introduces numerical errors: ``` Math.pow(10, -4) = 0.00009999999999999999 Math.pow(10, -5) = 0.000009999999999999999 ``` In the context of `round_decimals`, such errors propagate to `round_precision`, ultimately leading to inconsistencies between Python and JS (see #47300 for detailed use case). Instead of computing `Math.pow(10, decimals)`, we parse the scientific notation to prevent such inaccuracies. We also introduce tests in line with the Python tests. opw-2205092 closes odoo/odoo#47694 X-original-commit: cb471897bfa08d1fee6a9f49e90d9c120e1733fc Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-03-13[REV] web: allow patching gettersJoseph Caburnay
This reverts commit d6b854306cae245343a7acb9edc4178d245a49fe. The reverted commit introduced issues in patching class methods. Introducing getters in the patch function is not actually compatible with the original method patching. Test for patch method is also introduced to guard patch from future invalid modification that happened. A more robust way of patching classes is now being developed. closes odoo/odoo#47557 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-03-06[IMP] web: allow patching gettersJoseph Caburnay
Previous implementation of patch (web.utils) only allows patching methods. This commit allows patching getters as well. closes odoo/odoo#47047 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2020-01-06[FIX] web: human readability of negative numbers.Arnaud Joset
Before this commit, negative numbers are never rendered as human readable (e.g. 34000 -> 34k). closes odoo/odoo#42789 Taskid: 2160790 X-original-commit: b51877c4c4c9d8cd873dd0205954fd807d62ee01 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2019-02-22[MERGE] forward port branch saas-12.1 up to 0f4abc5c228Christophe Simonis
2019-02-15[FIX] web: remove human_number limitationsMathieu Duckerts-Antoine
The formatting of very big numbers (like 1.0045e+22) was not handled adequately by the function 'human_number' in web.utils. For those numbers, it seems more appropriate to use the scientific format. The only difference introduced here is the following. Beyond a magnitude of e+21, we represent the numbers by themselves but we keep the number of decimals provided as parameter (or zero by default) and we remove useless zero decimals like in the other cases. For instance, 1.0045e+22 is replaced by 1e+22 instead of 1.00e+22 if ask 2 decimals of precision (and by 1.005e+22 for 3 decimals). We have also fixed a small bug occuring in the previous version of the function: the symbol 'E' was never used. So by the past the above number would have be represented as 10045000P and, even worse, 1.01e+45 by 1.012e+28P. closes odoo/odoo#31140
2019-01-10[Generic] unaccent searchmgh-odoo
- added unaccent search on POS customer/partner and product - moved unaccent from "mail.utils" to "web.utils" - added more character to make function accurate We might use str.normalize(from ES6) but the problem is str.normalize method can not consider some double characters i.e. accented character when normalized it returns 2 normal characters and normalize method returns single character, so here custom unaccent method is used to normalize the string What we can improve here: We can use str.normalize method and check if string is still have unaccented charaters that we can call our unaccent method but this unaccent method is also working and performing well closes odoo/odoo#27671
2018-03-08[FIX] web: 'image_small' field not displayed for non-latin translationstrue-datura
Before this commit, images in kanban view of the Contact app were not displayed on non-latin languages, such as Russian. This was caused by the is_bin_size helper that wrongly assumes that a certain string is not a binary size, although it is (e.g. 64.2 Кб). This commit fixes the issue by including such strings as valid binary sizes. Bug found and fixed by @true-datura Test by @alexkuhn closes #23526 closes #22519
2017-04-11[REF] account, web, web_diagram: rename static test folderGéry Debongnie
For consistency, every static test folder should be named 'tests', with a s.