summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/views/view_dialogs_tests.js
AgeCommit message (Collapse)Author
2020-07-23[IMP] *: adapt tests to Owl search panelJulien Mougenot
Adaptation of the tests to the changes regarding the refactored search panel and model. Part of task 2228968 Co-authored-by: Julien Mougenot <jum@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2020-06-12[IMP] web: tests: rework mock helpersAaron Bohy
This commit reworks the test helpers, following recent changes on services deployed in the Owl env.
2020-06-10[IMP] web,*: highlight quick create feature to userDhruv Patel
Generally, Users are not necessarily aware that they can quick create a most records by simply typing in their name+enter in the many2xxx field input. The exact purpose of this commit is to make sure the user discovers the quick create feature of our many2xxx fields. For that, when the input is empty, display 'Start typing to create a record...' at the bottom of the dropdown when can_create is set and no_create_edit option not set. So the user can easily understand that by typing and pressing enter will create the new record. Also "Search and Create" options in the dropdown only been shown to the user when it type anything in the input box as the same case in the "Create" option. Task : 2266557 Co-authored-by: Mohammed Shekha <msh@openerp.com> Co-authored-by: Julien Mougenot <jum@odoo.com>
2020-03-13[REF] *: Adapt all module tests to the new control panelJulien Mougenot
Use of the new control panel helpers to increase consistency and change the assertions according to the new DOM/behaviour (e.g. components removed instead of turning invisible). Part of task 2196029 Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2019-12-17[IMP] web: rejected click handlers should not close the dialogDavid Monjoie
Prior to this commit, there was no clean way to have a button triggering asynchronous work (like asking user for confirmaton for example) and close or not close the modal according to the user choice. Your options were: 1. Swallow the pill and just accept that the modal will close even if the user chose not to undertake the action. 2. Set the `close` parameter of the button to false and handle the conditional closing by yourself from outside the dialog. This commit introduces a way to tell the form view dialog that the action has not been processed correctly and that the modal should not be closed by returning a rejected promise. Prior behavior can still be obtained (close no matter the result) by having the handler not returning a promise at all. closes odoo/odoo#33837 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2019-12-09[FIX] web,*: fix all tests and test utils to use native eventsVincent Schippefilt
In this commit: - transformed test_utils helpers to always trigger native events - introduced new test_utils_create helper: prepareTarget - updated qunit asserts to support Owl Components - updated all misused helpers that would crash with the updated test_utils Co-authored-by: Julien Mougenot <jum@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: Pierre Rousseau <pro@odoo.com>
2019-09-11[MERGE] forward port branch saas-12.3 up to 50e571acf7cChristophe Simonis
closes odoo/odoo#36491 Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-08-30[MERGE] forward port branch 12.0 up to 52f6e38cea8Christophe Simonis
2019-08-27[FIX] web: 'create' in context and non inline subviewsAaron Bohy
Let's assume an action with 'create': 0 in the context, and a non inline subview in the form view. Before this rev., the 'create': 0 was applied to both the form view and the subview. This rev. applies the same logic as what the server does for inline subviews: the rule is applied to the subview iff its model is the same as the one of the form view (with key 'base_model_name' set in the context). Task 2035653 closes odoo/odoo#36109 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2019-06-04[IMP] web: add optional fields parameterDavid Monjoie
This commit adds a new parameter on fields for list view and one2many. The parameter name is "optional" and its values are "hide" or "show". Columns of the list view which have the optional parameter set are listed in a dropdown that can be toggled from the last cell of the table header. The ones with optional set to "hide" are hidden by default. User choice is stored in local storage. If no saved parameter can be found in local storage then the default value from the view is used. Due to the overflow behavior of the responsive table, we were forced to wrap the table-responsive div in yet another div. We changed the o_list_view class on the table to o_list_table in order to reuse the more generic o_list_view class on the top-most div. CSS rules and selectors had to be updated according to this change. Task-1902765
2019-05-02[FIX] web: load binary data in separate http reqJulien Castiaux
The `read` done by `_fetchRecord` in `basic_model.js` expicitly set a `bin_size: true` in the context. That context option tells the backend to send the size of the binary payload instead of the payload itself thus slim the response size. Frontend widgets are then responsible to fetch the actual payload in a separated http req. The `search_read` done by `_searchReadUngroupedList` didn't set the context option thus all the binary fields were sent b64 encoded along with the `search_read` response. opw-1963842 closes odoo/odoo#33014 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2019-04-02[IMP] web,board: enable pagination in grouped listsAaron Bohy
With this rev., when there are a lot of groups in a grouped list view, groups are displayed under several pages, whereas they were all displayed in the same page before. This is especially interesting with the new 'expand' attribute, to ensure that we don't read records for a large number of groups. By default, the groups limit is set to 80 (like records), and to 10 is the 'expand' attribute is set to true. This limit can be overriden with the 'groups_limit' attribute. Part of task 1915702
2019-03-06[REF] web: adapt code after jQuery updateVincent Schippefilt
Part of task 1896658 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com> Co-authored-by: svs-odoo <svs@odoo.com> Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
2019-02-12[FIX] web: quotes and backslashes in search viewMathieu Duckerts-Antoine
The commit 6d3ada178f7caf6ea159b871648ca4c440c7845b aimed to solve problems occuring whith (single or double) quotes when creating new custom filters. Unfortunately, the point was missed and bugs were still present. The present commit solves the orginial problem satisfactorily. There was also a problem in the management of backslashes. Type '\\' in the search bar would lead to a domain like [('...', 'ilike', '\\\\\\\\\\\\\\\\')]. This has also been fixed. Note that it is necessary to input "\\" if one is looking for a backslash in db (as before). A remark on the _formatAST function (py_utils.js): We deescape only the chars `'`, `"`, and `\` because it does not seem possible to produce a string in the search view that would intend a search for a line return or a tab for example. A general remark: Domains should always be in normalized form. In that way they could be manipulated and combined together without a tokenization/parsing! closes odoo/odoo#29756
2018-12-07[REF] web: move ControlPanel inside controllers/actionsGéry Debongnie
This branch introduces a large-scale reorganization of the component tree generated by the web client. The short version is that now, the control panel is a child of the view controller and no longer a sibling. Graphically (and simplified), we go from this: webClient / | \ ... ... actionManager / \ controlPanel viewController / \ to this: webClient / | \ ... ... actionManager | viewController / | \ ControlPanelController / \ CPRenderer CPModel The motivation is that this work moves the code where it should be. Before this commit, it was kind of weird to have code in the controllers to render buttons outside of their root node (in renderButtons). Also, the action manager had to take care of coordinating search view states between view transitions. So, this work simplifies the code. It also makes it easier to extend. We see day after day that Odoo needs to take care of more complex UI needs, and in many cases, these needs were quite difficult to implement (we prefer spaghettis in our plates, not in our code). The changes in this branch should open the way to implement these features. For example, - it will now be easy to add the possibility of views (for example, the search view or a new ControlPanel view) to add custom buttons (of type action or object) in the control panel. - Another need will be to serialize/ restore the state of the search view across action boundaries (needed by the dashboard). - Another example is the possibility for views to customize easily the presence/absence of sub menus (filters/groupbys/favorites/ time range/...) - Another need is an easier way for views/client action to customize their control panel. This commit also contains a large rewrite of the search view (so it is more inline with our architecture and easier to maintain). Part of task 1893568 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com>
2018-11-29[MERGE] forward port branch 12.0 up to 82a1e1dcc33Christophe Simonis
2018-11-29[MERGE] forward port branch saas-11.3 up to c0eef427111Christophe Simonis
2018-11-28[MERGE] forward port branch 11.0 up to bb6f6c57f97Christophe Simonis
2018-11-16[FIX] web: correct forward-ported testChristophe Simonis
2018-11-15[MERGE] forward port branch 11.0 up to 468dab6748aChristophe Simonis
2018-11-19[REF] *: update js test suite to use helpersGéry Debongnie
This rev. introduces robust helpers to use in the JS tests suite to interact with DOM and components, and starts using them (almost) everywhere. All the helpers are exposed though testUtils.js. There are 2 kinds of helpers: 1. Assertions ------------- * assert.containsNone, containsN, containsOnce check that the DOM (or a specific part of the DOM) contains a `selector`. It generates a correct error message automatically. ex: assert.strictEqual(form.$('.o_form_editable'), 1, "msg"); -> assert.containsOnce(form, '.o_form_editable'); * assert.isVisible, isNotVisible check that the DOM has an element visible or not. They also check that the element is actually in the DOM (before most tests didn't verify this). * assert.hasClass, doesNotHaveClass, hasAttrVAlue, check specific properties of a DOM element, and also validate that it is applied on a single existing DOM element (before most tests didn't verify this). ex: assert.notOk(form.$('button').hasClass('btn-primary')); -> assert.doesNotHaveClass(form.$('button'), 'btn-primary'); 2. Utilities ------------ The goal of the utilities is to centralize the definition of many standard components and interactions, ensuring that when we refactor the JS framework, we do not need to change all the tests. Existing mock utilities (addMockEnvironment, intercept, path, patchDate, unpatch and fieldsViewGet) are moved to 'testUtils.mock.*'. Existing DOM utilities are moved to 'testUtils.dom.*'. New dom utilities are created for opendDatePicker, click, clickFirst and clickLast. Helper `click` verifies that there is exactly 1 element visible in the DOM you click on, `clickFirst` and `clickLast` verify that there are more than one element on the DOM. ex: form.$('button').click(); -> testUtils.dom.click(form.$('button')); New Form utilities: (testUtils.form.*) clickEdit, clickSave, clickCreate, clickDiscard, all clicks on the control panel buttons of the form. `reload` reloads the form data. New modal, graph, kanban and pivot utils (testUtils.pivot.*, testUtils.kanban.*, etc.). New fields utils: (testUtils.fields.*) * editInput, editSelect: allow to change the value of a field, using a selector to identify it. They validate that the input exists and trigger the change event automatically. * editAndTrigger: allow to modify a field and trigger specific events after the value change * many2one (testUtils.fields.many2one.*) clickOpenDropdown, clickHighlightedItem, clickItem, searchAndClickItem: use a field name instead of a selector and do all the complex mechanism to open, filter and highlight many2one fields. Joint work with aab, dam, ged, mge, svs and vsc.
2018-11-16[MERGE] forward port branch saas-11.3 up to bab2a191d29Christophe Simonis
2018-11-13[FIX] web: load SubViews without previous' view _view_ref context keysLucas Perais (lpe)
On a form view (of model A), define a many2one (model B) with a [form|tree]_view_ref context key In that view, have a x2m field (model C) with a different [form|tree]_view_ref context key Before this commit, the second load_views (i.e. on the model C) crashed because the wrong context key was sent to the server, which returned the view to which the _view_ref points i.e. the view of the model B After this commit, we clean the context of subviews loading, because those keys are only useful for the python and one shot. Hence, there is no crash OPW 1903780 closes odoo/odoo#28260
2019-04-24[REF] web, *: remove `one2many_list` widgetMartin Geubelle
This widget was exactly the same as a `one2many` and was kept for backward compatibility reasons. It can be safely removed in master. Related to task 1918327
2018-11-26[FIX] web: propagate can_create into the search popupLucas Perais (lpe)
When creating a SO line and clicking on search more for product_id Before this commit, every user had the button "Create" to create a product.product After this commit, only user in groups that actually can create a product have the button OPW 1910371 closes odoo/odoo#28924
2019-02-15[FIX] web: quotes and backslashes in search viewMathieu Duckerts-Antoine
The commit 6d3ada1 aimed to solve problems occuring whith (single or double) quotes when creating new custom filters. Unfortunately, the point was missed and bugs were still present. The present commit solves the orginial problem satisfactorily. There was also a problem in the management of backslashes. Type '\\' in the search bar would lead to a domain like [('...', 'ilike', '\\\\\\\\\\\\\\\\')]. This has also been fixed. Note that it is necessary to input "\\" if one is looking for a backslash in db (as before). A remark on the _formatAST function (py_utils.js): We deescape only the chars `'`, `"`, and `\` because it does not seem possible to produce a string in the search view that would intend a search for a line return or a tab for example. A general remark: Domains should always be in normalized form. In that way they could be manipulated and combined together without a tokenization/parsing! closes odoo/odoo#31025
2018-07-27[REF] *: BS4, adapt tables (and list view)qsm-odoo
`table-condensed` -> `table-sm` Also SCSS variables were renamed. Also restore list view design.
2018-07-27[REF] *: BS4, remove the use of btn-smqsm-odoo
Odoo made the bad choice of using the 'btn-sm' class for every button instead of configuring the padding for default 'btn' to be smaller. In BS4, the style of btn-sm is actually more complex, lowering the font-size too. Also, btn-xs was removed so we would not have the possibility to display smaller button than our default ones. This commit removes btn-sm wherever it was used. Unfortunately, this might remove it at some places where it made sense but this can be restored in a second time.
2018-07-09[FIX] *: fix some side-effects of ↵qsm-odoo
https://github.com/odoo/odoo/commit/9de1bc0eef6f5bfaa2a8d745431caa361ae91548 - JS Modals were not correctly built anymore, their .modal-body element was duplicated and many without-effect JS lines were introduced (as a side effect, the form view design was broken when inside modals) - Tests were changed to make bugs go unnoticed. For example, the media dialog functionnality was entirely broken because the .modal-dialog element was not receiving the correct class anymore. - The JS translation function is _t, not _ - Do not use the <title/> tag as a regular DOM element, it is meant to be unique, in the <head/> section - CSS rules were added to the utils.scss file, which is meant to contain functions and mixins, otherwise, the rule is duplicated in every asset - Some icons were still broken, as missed by https://github.com/odoo/odoo/commit/f90cf060a3cfeb37a67bec83264c0aaab8892b56 - Tests were changed to use [role="dialog"]/footer/header in their selectors without any reason, this commit restores some of that to avoid rebase conflicts with the BS4 work. - ... Note: other elements should still be discussed, like the direct use of the 'o_form_label' class in views definition... but those do not cause direct problems.
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-06-22[IMP] Improve compatibility with screen readers (accessibility) (#24574)kujiu
Today, Odoo is really tricky to use without seeing the screen, it must be improved to be usable. This PR forbid to use labels without a "for" attribute, add some title, rule and aria attributes in HTML. With that, Odoo will be fully usable with a screen reader. * [IMP] Labels must have a for attribute. Improve accessibility. * [IMP] Better error message when trying to read a missing cached value * [FIX] Add some aria-label and title attributes for screen readers. * [FIX] Template name is not included in the error message in case of SyntaxError in QWeb * [FIX] Improve the Tour failed at step error message to be more explicit. * [IMP] Add aria-labels * [FIX] Add missing aria-label on failing test * [IMP] aria-hidden means hidden. Fix all bad aria-hidden and hide aria-hidden for all. * [IMP] Color names on kanban views and many2many tags * [IMP] Add some checks on views for accessibility. * [IMP] Add `alt` attribute on `img` tags. * [IMP] Add aria-label and title on non-described icons * [IMP] Add button role to widgets with btn class * [IMP] Translate aria and formatted attributes. * [IMP] Remove wrong aria-labelledby * [IMP] Add menu role on dropdowns * [IMP] Buttons must be focusable * [IMP] Add aria attributes on progress bars * [IMP] Improve accessibility of basic widgets * [IMP] Change main layout to more semantic tags * [IMP] Add menuitem role when missing * [IMP] Remove wrong role='presentation' * [IMP] Improve accessibility of tab panels * [IMP] Add aria-invalid on invalid fields * [IMP] Add aria-sort on ordered columns * [IMP] Add role on alerts * [IMP] Use dialog role, header, main and footer tags for modals * [IMP] Add labels on o_status * [IMP] Improve accessibility of kanban view with feeds and articles * [IMP] Add alerts in case of new messages * [IMP] Add widget, navigation or img role to aria-labelled items
2018-03-20[MERGE] forward port branch 11.0 up to 2835d299792Christophe Simonis
2018-03-13[FIX] web: view dialog select among filtered entriesLucas Perais (lpe)
On an editable line with a many2one Click to create a record Click on create a record in the many2one It opens the form view of the object in a modal, which has a many2many list, which choices are domainized Click 'add an item' on this list It should open a modal with the filtered choices Click on any of the existing record Before this commit: There was a traceback in JS That was because the event bubbled up to a parent, when it shouldn't After this commit: The whole flow unfolds without errors OPW 1823205
2018-03-06[FIX] web: create favorite filters in dialogsAaron Bohy
This is a manual forwardport of rev. b466b3bc608. Consider the following scenario: open in edit mode a form view containing a many2many field displayed with widget many2many_tags, on the many2many field dropdown, click on 'Search More' (it opens a dialog), and in the dialog, try to save the current search in the searchview's favorite menu. Before this rev., it crashed because it tried to retrieve the action's context (to add to the saved filter), whereas there is no action in this case. Actually, the action's context should never been used in this case. What must be used is the controller's context (this mainly makes sense for Pivot and Graph views). Fixes #23293
2018-03-01[MERGE] forward port branch 11.0 up to c2e878e34c8Christophe Simonis
2018-03-01[FIX] web: prevent footer from being rerenderedGéry Debongnie
In some cases, the footer in a form view dialog could be duplicated. The reason was that the form view was rerendered completely, footer included, by the renderer, out of the formcontroller control (it is the formcontroller's job to move the footer buttons to the footer). A possible fix is to work on the form renderer to make it aware that the footer buttons are expected to be only rendered once, but it has the disadvantage to be a fix specific to this issue, and any other form view behaviour with some side effects may have the same issue. This commit tries to prevent the form view from rerendering itself completely in those cases. This also has the disadvantage of possibly not being a complete fix, if some edge cases are missed. However, I have the feeling that we still want to avoid rerendering the full view if possible.
2018-02-12[FIX] mail,web,*: Cleaning some JS codeAlexandre Kühn
- Whitespace trailing - Split long lines - Replace some 'self' to 'this' - Improved some JS docs - DRY in tests using services
2018-01-16[REF] web,*: ActionManager/ViewManager refactoringAaron Bohy
This rev. is the first part (out of 3) of the refactoring of the ActionManager and ViewManager layer of the webclient. The main changes are: - there is no ViewManager anymore, its work is now handled by the ActionManager itself, but isolated in a specific file ; this eases a lot of things, as the breadcrumbs handling for example. - the ActionManager code is converted to the new coding principles and guidelines ; mainly, children widgets communicate with it by triggering events up, and not by function calls anymore. - the ActionManager layer is now testable, and a lot of tests have already been written. - the code in other addons has been adapted consequently. What's coming next: - introduce the 'AbstractAction' Widget, and make client actions and view controllers inherit from it ; this widget will implement a common API that could be used uniformly by the ActionManager (e.g. restore(), canBeLeft(), renderButtons(), getTitle()...). - move the ControlPanel handling from the ActionManager to the AbstractAction.
2017-11-23[REF] web: tests: make load_views RPCs go through mockRPCAaron Bohy
This allows to inspect those RPCs and the given arguments as well.
2017-11-13[FIX] web: grouped list views: allow sorting groupsAaron Bohy
Before this rev., sorting groups in list views wasn't supported. It hadn't been implemented in the new views. This rev. activates the feature, so groups can now be sorted on their aggregates again. It also implements a basic (first level only) sorting in mockReadGroup, in the mock server. opw 781288
2017-11-10[FIX] web: prevent test interferenceGéry Debongnie
In the view dialog test suite, a few tests created a parent widget, then created a view dialog, and destroyed the view dialog at the end, but not the parent widget. As a result, the environment was not properly restored at the end. In this case, the test 'SelectCreateDialog correctly evaluates domains' changed the session (with user_context: {uid: 2}), and this made other tests crash (web_editor test in particular)
2017-11-07[FIX] web: correctly evaluate domains and contexts in dialogsAaron Bohy
An error occurred if the domain or context applied on a view opened in a dialog needed to be evaluated (e.g. if they contained something like [['some_field', '=', uid]]). For instance, create a custom filter with such a domain for the Contact model, then go to Contact, create a new one, and on the parent_id many2one, click on search more. Before this rev, no eval context was given so the domains and contexts couldn't be evaluated, and it crashed.
2017-08-17[FIX] web: avoid SelectCreateDialog editable list viewMartin Geubelle
As its name indicates, the SelectCreateDialog is meant to select and create, not edit. If the view is editable, clicking on an element will edit it instead of selecting it. For this reason, the view is set in `readonly` even if the view arch uses the attribute `editable`. Before this rev., you couldn't select a "Close Reason" when closing a subscription (in "Search More").
2017-06-13[FIX] web: SelectCreateDialog uses the domain of the view when searchingChristophe Matthieu
before this fix: the domain is used when opening the dialog but it is not used if the user update the filter or the group_by.
2017-05-09[FIX] web: prevent view_dialogs from changing envGéry Debongnie
With this commit, we prevent view dialogs from changing the 'global' environment in the view manager. Here is how it could cause a problem: * open a form view for a bill of material * click on one of the component, it will open a form view in a dialog (and will change the environment with a wrong res_id) * click on the many2one product -> it will open a new action in the background, and change the environment again * click on the breadcrumb to come back to the bill of material: the view manager will try to restore the correct res_id (which is the wrong id from the component form view), the form view will do a read (when reloading the data), will get an empty result, will update its information with no data, then will be in a wrong state which means that the basicmodel will fetch a x2many with a wrong res_ids list * boom
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.