summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/core/domain.js
AgeCommit message (Collapse)Author
2021-05-17[FIX] web: domain: (=)(i)like operatorsAaron Bohy
Before this commit, evaluating a domain containing a like/ilike operator with an evaluation context in which the value was false crashed. Moreover, those operators were wrong w.r.t. the case sensitivity: like was case insensitive, whereas ilike was case sensitive, and both =like and =ilike were case insensitive. This commit fixes thoses issues. The first issue was spotted on our prod, as we tried to add an invisible attrs in a form view, using the ilike operator (it thus crashed in create mode). The second issue was spotted while writting the test cases. To the best of our knowledge, those operators aren't used in attrs (for now), explaining why those issues haven't been found before. closes odoo/odoo#70876 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-02-11[FIX] web: keep null/false/true strings in domainsAaron Bohy
Before this commit, occurences of 'null', 'true' and 'false' strings as autocomplete values in the search view were replaced respectively by None, True and False. Fixes #65743 closes odoo/odoo#65900 X-original-commit: 74311c753e7286c27b83dca2b598e040ed9e586f Signed-off-by: Géry Debongnie (ged) <ged@openerp.com> Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-06-17[FIX] web: fix in and not in js domainjvm-odoo
This commit fix the in and not in operators in domain.js. _.contains works only if you have an array in the left part. So if you have an array in the right part it will not work correctly. Using _.intersection solves the problem. OPW-2274990 closes odoo/odoo#53150 X-original-commit: 7e3fbfaf5a39f7e26b3a9073144f682086265920 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com> Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
2020-06-04[IMP] web: Comparison menuMathieu Duckerts-Antoine
This commit replaces the "time range menu" in the control panel by a new component: the "comparison menu". Its purpose is roughly the same: compare a period of data in a reporting view with the previous period or the previous year. Its implementation is a bit simpler: it will only appear if at least one date filter is selected in the search view, and will suggest to compare each selected date option with the previous period or the previous year. Task ID: 2245719 Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: Julien Mougenot <jum@odoo.com>
2020-05-05[IMP] web: Standardize FALSE and TRUE leaves/domainsJulien Mougenot
Add four static properties on the Domain.js class: (TRUE|FALSE)_(LEAF|DOMAIN). This increases consistency for domains using these concepts.
2020-02-12[FIX] *: domains should not have as many binary operator as there are termsXavier Morel
* modify client-side domain normalisation to error if the domain is invalid (not enough terms / segments for the number of operators) * add better error reporting to attrs / modifiers parsing * add a few layered error augmentation to provide clearer context e.g. "error: invalid domain <thing>" is helpful but "error while parsing modifiers for field foo: modifier invisible: invalid domain <thing>" is much more helpful * rework _evalModifiers to deduplicate it in order to more easily implement this contextual augmentation * test that improper domains are properly found improper * fix a bunch of incorrect attrs domains * also removed an apparently undefined (& unused) "options" argument to a _applyModifiers call closes odoo/odoo#44642 Related: odoo/enterprise#8175 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2019-08-13[IMP] web: review date filters and groupbys functioningMathieu Duckerts-Antoine
This commit modifies the functioning of date filters in the control panel Filters and Group By submenus. For a filter with date attribute set, the list of proposed options is shorter but allows a bigger set of domains to be quickly created (through combinations of the options). The resulting list of domains is different of the previous one: domains like "Today" or "Last Week" are left aside but many others (and their unions) are now accessible. The domains generated in that way are no more dynamic but it is still possible to save dynamic filters in general. This commit also reintroduces the multi selection of options for groupbys of type date/datetime in the groupby menu. Task ID: 2028787
2019-04-05[MERGE] forward port branch saas-12.1 up to f2d0995362cChristophe Simonis
2019-02-13[IMP] web: add 'Last 5 Years' as a period optionPriyanka Kakadiya
This commit adds the option 'Last 5 Years' in the list of periods available to selection in the filter menu and the time range menu for the date/datetime fields. Task: 1916017 closes odoo/odoo#29423
2019-04-02[FIX] web: Wrong comparison in invoice analyesGoffin Simon
Steps to reproduce the bug: Let's consider that we are in 2019 - Create two customer invoices: I1 and I2 - I1 with invoice date = 2 april 2019 and amount = 100€ - I2 with invoice date = 2 april 2018 and amount = 1000€ - Go to Reporting > Invoices - Click on widget "Time Ranges" and set "Based on" Invoice Date and "Range" This Year "Compare To" Previous Year Bug: The untaxed total for previous year was 1100€ instead of 1000€ because it counted previous year and this year. opw:1962027 closes odoo/odoo#32331 Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2019-01-17[IMP] web_editor,*: Refactoring the wysiwyg editor and 'html' fieldChristophe Matthieu
* Creating a new structure by transforming all the plugins in the library using the odoo inheritance system. Plugins are easier to implement with the AbstractPlugin to add Odoo behaviors. * From now on, the methods of the library (in this case Summernote) can no longer be called by other modules or files. Only the wysiwyg widgets can access it, to simplify the updating process. The wysiwyg object serves as an interface. * Depending on the options the snippets will be loaded or not, the editor will be in an iframe or not... all of this is transparent from the outside. * Regarding iframes, all controllers related to editing have been removed: the new API no longer needs them. This speeds up loading, eases testing and removes complexity for the same features. PUBLIC FEATURES There are several public methods on the Wysiwyg class: * Wysiwyg.prepare (WidgetParent): returns a deferred resolved when the library (xml, lazy, assets...) is loaded. * Wysiwyg.getRange (DOM): returns the range (selection in the dom) * Wysiwyg.setRange (startNode, startOffset, endNode, endOffset): creates a range (selection in the dom) * Wysiwyg.setRangeFromNode (DOM, options) that creates a range from an element (option available to select all, start or end) A jQuery selector was added: :o_editable, which indicates whether the current element is editable. That is, if it is contained in a tag with the attribute 'contentEditable = "true"' or in a tag with the class o_editable. Several methods are also present: * focusIn: makes a focus and places the cursor at the beginning of the element * focusInEnd: makes a focus and places the cursor at the end of the element * selectContent: makes a focus and selects the content HTML FIELD The HTML field can receive different options: * style-inline: {boolean} transforms a class into an inline style when saving and vice versa when reading. * no-attachment: {boolean} prevents the use of attachments (in media dialog) * cssEdit: {xml_id} to use a template containing the css to loaded in an iframe when editing * cssReadonly: {xml_id} to use a template containing the css to load into an iframe when viewing in readonly * snippets: {xml_id} snippets template (can be used with or without cssEdit) * wrapper: {template} qweb static template (containing a tag: id = "wrapper") that will include the content during editing (removed on save) MASS MAILING A widget was created for mass mailing. There are now two fields: body_html and body_arch. body_arch contains the code with the class without conversion into inline style, useful when editing and one with the inline style that is visible in readonly mode and sent by email. Advantage: no spreading errors, able to update css/theme, able to do more changes when converting to inline style so that a maximum of mail clients have an impeccable rendering. Co-authored-by: Antoine Guenet <age@odoo.com>
2018-08-31[FIX] web: domain: quarter and last quarterAdrien Dieudonne
Before this commit, it was not possible to compare data if the time range selected was quarter or last quarter. String and integer was concatenated and the returned domain to evaluate was wrong: -3 3 - (context_today().month - 1) % 3 instead of: -3 + 3 - (context_today().month - 1) % 3 Offset period param is always an integer but it's not the case of boundary params. For 'quarter' and 'last quarter', it's an expression to evaluate. Anyway, this part of code will be refactored in a while but it's important to make the test to avoid this king of issue.
2018-08-31[FIX] web: domain: quarter and last quarterAdrien Dieudonne
Before this commit, it was not possible to compare data if the time range selected was quarter or last quarter. String and integer was concatenated and the returned domain to evaluate was wrong: -3 3 - (context_today().month - 1) % 3 instead of: -3 + 3 - (context_today().month - 1) % 3 Offset period param is always an integer but it's not the case of boundary params. For 'quarter' and 'last quarter', it's an expression to evaluate. Anyway, this part of code will be refactored in a while but it's important to make the test to avoid this king of issue.
2018-08-27[FIX] doc building and warningsXavier Morel
doc: * fix incorrect doc comments (documenting params which don't exist) * correctly quote non-refs * fix role label syntax (backticks must be escaped) * add newline to fix warning JS doc parser: * fix handling of already-resolved objects * fix handling of non-string properties (e.g. foo[0] at module toplevel) * don't blow up if subject of .include call can't be resolved (just ignore) Others: * add translator support for ``problematic`` node (apparently used for some refs by recent Sphinx)
2018-08-14[IMP] web: new TimeRangeMenu widget in search viewMathieu Duckerts-Antoine
This commit introduces a new widget 'TimeRangeMenu' used in the search view. It allows a user to easily: - search data with a given date or datetime field value in a specified period of time - compare the data of interest with data of the previous period or the previous year. The time range menu is available in the search view when one of the four following view types is instantiated: graph, pivot, cohort, or dashboard. Task Id: 1835644
2018-08-13[IMP] web: add method to convert JS domain into python conditionChristophe Matthieu
2018-07-06[IMP] web: easy selection of a period in filters menuMathieu Duckerts-Antoine
This commit allow to create easily a range of periods (related to a field of date or datetime type) to select in the filters menu. Two new attributes on elements with tag 'filter' are now usable in combination in a search view arch: - date: string. A valid field name with associated type date or datetime - default_period: string (optional). To choose in the following list: - 'today' - 'this_week' - 'this_month' (default) - 'this_quarter' - 'this_year' - 'yesterday' - 'last_week' - 'last_month' - 'last_quarter' - 'last_year' - 'last_7_days' - 'last_30_days' - 'last_365_days' Example: <filter string="Creation Date" name="period_generator" date="create_date" default_period="this_quarter"/> Note: the attribute 'domain' can not be used for such filters. The generated domains are dynamic and can be saved as such via the favorites menu.
2018-07-06[REF] *: rename web.pyeval into web.py_utilsGéry Debongnie
The pyeval name is quite confusing, given that there is already an eval and an evaluate function in py.js, and that the web.pyeval exports two evaluate functions. Since this file is more about odoo specific customization to py.js, it is renamed in py_utils to better express its intended use.
2018-02-21[FIX] web: evaluation of xml templates must be retro compatibleChristophe Matthieu
Issue: domain="[('date','=',time.strftime('%%Y-%%m-%%d'))]" is converted into a domain equal [('date','=','%2017-%12-%12')] instead of [('date','=','2017-12-12')]
2017-09-29[IMP] web: x2m list: conditionnaly hide a columnfwi-odoo
This commit introduces a new way to hide a column in a x2m list view. The attribute 'tree_invisible' can be add in the field attrs in the x2m view definition. This attribute can use the 'parent' key to make a reference to the parent record (e.g. 'parent.id').
2017-04-11[FIX] web: Domain: don't return frozen domainAaron Bohy
In a recent commit, the fields object describing all fields of a model is (deeply) frozen by the data_manager. As a consequence, if a field has a domain (represented by an Array), this domain is frozen as well. Moreover, when the function getDomain is called on a dataPoint, the returned domain is the one in fields, not a copy. Problem is that the Many2One field updates this domain to add the blacklisted ids, which produces an error if the domain is frozen.
2017-04-11[FIX] web: allow to build a domain from a numberqsm-odoo
Some views were trying to make fields invisible thanks to `attrs="{'invisible': 1}"`. This is not supposed to be valid as an attrs value is supposed to be a domain and not a number. To make the fields always invisible, use the "invisible" *attribute*. This also allows the client to make the fields invisible without any domain computation. However, to keep supporting those kind of attrs and to be more generic, the Domain class is adapted by this commit to consider numeric domains to be valid (numbers different than 0 are considered "true" domains and 0 is considered a "false" domain).
2017-04-11[REF] web: some linting and documentationqsm-odoo
2017-04-11[IMP] web, *: compute contexts and domains from datapointqsm-odoo
This commit tries to refactore the management of contexts and domains in the webclient. - Get rid of CompoundDomain: use standard array manipulation to join multiple domains or use the Domain class (to be improved) - Get rid of data.js build_domain and build_context methods - Link this.record to the data point from the basic model for all fields (not only relational fields) - Add a getContext and a getDomain function to the basic model data point (localData element) so that AbstractField implementations can use them thanks to their this.record element. - Remove the autocontext binding for field RPCs (see FieldManagerMixin)
2017-04-11[REF] web, *: redesign all JS viewsGéry Debongnie
This commit introduce a full redesign of all JS views. We started basically from scratch. The goal was to unify all the various views under a common framework, to make them testable, to make then usable in different conditions (in studio, or in the frontend), and to make our lives easier. Some important points are: - we introduced new coding guidelines (camelCase, 80 chars width, ...) - we have a brand new testing framework (still QUnit based) - kanban view moved to the web addon - calendar view (formerly web_calender) moved to web as well - the tree view was removed - all new code should be documented We hope that this code is the start of a new era for the Odoo web client, we want to have a high quality codebase, well documented, well tested, well designed. Work done by the framework team: mostly aab, ged, chm, dmo, qsm