summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields_tests.js
AgeCommit message (Collapse)Author
2019-04-12[MOV/IMP] web, mail: update attachment widget and moved the common scss code ↵jpr-odoo
from mail to web with this commit, we have updated the attachment widget view same as like chatter attachment view moved the common scss code from mail to web for many2many_binary widget, which is used for attachment and update test case according to the widget Task ID: 1930087
2019-04-02[IMP] web: editable list: table-layout: fixedAaron Bohy
This rev. changes the layout of *editable* list views to a fixed layout. This means that we are now responsible of the width of each column. To do that, we associate with each field type a factor, and the higher the factor is, the larger the column will be (w.r.t. the others). This default value can be overriden in the arch. The fixed layout allows to remove the absolute positionning of widgets inside editable lists (done in the next commit). Part of task 1915702 Co-authored-by: Martin Geubelle <mge@odoo.com>
2019-04-01[MERGE] forward port branch saas-12.2 up to 18c735361a6Christophe Simonis
2019-03-29[MERGE] forward port branch 12.0 up to 09fb2469b49Christophe Simonis
2019-03-29[MERGE] forward port branch saas-11.3 up to ec29b4d3648Christophe Simonis
2019-03-25[FIX] web: modal in modal => no block mobileNicolas Lempereur
On a form view: - we open a modal form view - in this modal we open a modal form view - we close that second modal => the modal is closed and the first one is still opened, but on mobile we can't scroll to above or below the modal. This is because bootstrap remove .modal-open class on body when we close the second modal, but this class is necessary to scroll (this is not much an issue on desktop since scroll is often not necessary). We already had a fix that was weakened in 02a063fd73. With this changeset, we keep .modal-open as long as a modal is opened. Without the change, added test failed with: 10. Modal is said opened (expected: true, result: false) opw-1948423 closes #32106 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-03-14[MERGE] forward port branch 12.0 up to a26496b6e79Christophe Simonis
2019-03-14[MERGE] forward port branch saas-11.3 up to f5ab04ce509Christophe Simonis
2019-03-13[MERGE] forward port branch 11.0 up to c23d1186e7bChristophe Simonis
2019-03-13[FIX] web: hide handle on readonly x2mMartin Geubelle
The widget handle was displayed on x2m fields in form views, even when the field was readonly, which makes no sense. It is now correctly hidden. Fixes #30580 opw-1937833 closes odoo/odoo#31743 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2019-03-25[MERGE] forward port branch saas-12.2 up to 230ad8c381eChristophe Simonis
closes odoo/odoo#32088 Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-03-13[MERGE] forward port branch saas-12.2 up to c9f832d9f03Christophe Simonis
closes odoo/odoo#31790 Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-03-11[FIX] web: use stricter css selector in new testChristophe Simonis
It allow not matching the dropdowns of the search view. closes odoo/odoo#31738 Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-03-08[MERGE] forward port branch 12.0 up to c023d0784f2Christophe Simonis
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-07[MERGE] forward port branch 12.0 up to a46138cb019Christophe Simonis
2019-02-06[FIX] web: only call name_get when necessaryAaron Bohy
For many2one fields, 'default_get' only returns the id, whereas 'onchange' (like 'read') returns an array with id and display_name. Before this rev., when creating a new record, we always called 'name_get' for all many2ones, whether or not their value was obtained by 'default_get' or 'onchange', i.e. even if their display_name was already known. It may just look like unnecessary RPCs, but those RPCs could actually cause a crash when the user has access to the main model (and thus can access the display_name of the many2one thanks to related sudo), but doesn't have access to the many2one comodel. closes odoo/odoo#30892
2019-01-15[MERGE] forward port branch 11.0 up to 4f2f2995346Christophe Simonis
2019-01-11[FIX] web: one2many list: quickly switch between pagesAaron Bohy
Before this rev., a crash might occur when the user quickly switched twice between pages (e.g. go to page 2, then page 3) on a slow network. In the given example, when data of page 2 returned, the list was re-rendered. Unfortunately, the offset of that list' datapoint was already changed due to the switch to page 3, meaning that the view tried to render a page that wasn't loaded yet, leading to a crash if there were modifiers to evaluate, or to empty records being displayed. This rev. ensures that the view is rendered with the data of the page it expects. closes odoo/odoo#30150
2019-01-11[FIX] web: reset offset in the search more view dialogNans Lefebvre
Start on the modal obtained by a "search more". The offset is never reset. So suppose you are on page 2, looking at record 81-160. Do a research that gives less than 80 records. The result of the search is nothing, since is has been done with a 80 offset. It should be reset to 0 when we do a new search. opw 1920826 closes odoo/odoo#30109
2019-01-08[MERGE] forward port branch 11.0 up to c07b7200b26Christophe Simonis
2019-01-04[FIX] web: X2Many read propagates field contextNicolas Lempereur
Most operations on X2Many widget possibly propagates a field context (name_create, name_search, ...) but the original read or read on an onchange does not. With this changeset, the field context is also used in these instances. The assertions added in the added test failed with: expected: ["world"], result: [undefined] expected: ["world","world"], result: [undefined,undefined] fixes #29203 opw-1914466 closes #29866
2019-01-02[FIX] web: adapt forward-ported testChristophe Simonis
2019-01-02[MERGE] forward port branch 11.0 up to d82c0d133edChristophe Simonis
2019-01-16[MERGE] forward port branch saas-11.3 up to 83cc046e9a9Christophe Simonis
2019-01-08[MERGE] forward port branch saas-11.3 up to 2d824a5b7adChristophe Simonis
2019-01-04[MERGE] forward port branch saas-11.3 up to 27a084eb814Christophe Simonis
2018-12-19[FIX] web: read records up to list limitlen-odoo
Fine-tuning of commit e7fab234201e357da52c3576ad2e8fc9ceee9359 In a one2many with more than one page with a limit of k records, add a line l. It increments the list limit to k+1. Remove a line above (of index <= k). It will try to load a line l' to replace it, that it will find on page 2. However when deciding if it should read missing fields on that record, it will scan at most u records, skipping virtual ids. Here u is the min between the current number of lines and the list limit without the temporary increase due to the added record. Since there are at least two pages, u = k. However since l is in the list at index k, then l' won't be read, and since it was on page 2 its data hasn't been loaded. Therefore the js would traceback when trying to evaluate it. opw 1913361 closes odoo/odoo#29338
2018-12-18[FIX] web: x2m in x2m with different fields in different viewsMartin Geubelle
Use case: a x2m (ex: attribute values) displayed in a x2m (ex: attributes on product) using different fields in different views (ex: tags in product form view and list in product attribute form view). When opening the x2m record (in a wizard) then going back on the form view, the tags are empty because the `display_name` value has been lost when fetching x2m for the second time. In this case, the list `fieldsInfo` needs to be updated with the existing (default for tags) one so all the fields will be correctly loaded. Task 1916891 closes odoo/odoo#29598
2019-01-18[FIX] web: correct forward-portChristophe Simonis
2019-01-18[MERGE] forward port branch 12.0 up to f854e01a983Christophe Simonis
2019-01-09[MERGE] forward port branch 12.0 up to 3e4138deaa2Christophe Simonis
closes odoo/odoo#30045
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-12-04[MERGE] forward port branch 11.0 up to 2156af480fdChristophe Simonis
2018-12-18[FIX] web: call _applyX2ManyChange with the correct viewtypeNans Lefebvre
Have a one2many display records in a kanban subview, which opens a form view when edited. Edit a field displayed only on the form view. A call to _applyX2ManyChange is done without giving it the viewtype argument, therefore the fieldinfo is taken from the wrong view, traceback ensues. opw 1914163 closes odoo/odoo#29607
2018-11-30[FIX] web: prevent crash in some cases (o2m)Géry Debongnie
Recent works in the orm (see [1] for example) changed the behaviour of the server in the case of onchanges: it tries to optimize Odoo by sending a minimal diff to the web client in onchanges. Concretely, this means that the web client receives commands 4 (link to) instead of command 1 (update + record data). It also sends a minimal diff in that case. This is a big issue for the web client, because it relied on the knowledge of the data from the command 1 to be able to evaluate some modifiers. The good news is that we can mitigate the issue in one case: we do not actually need to evaluate the modifiers in the case of a command 4 (comming from the server), because we can assume that the record is valid. So, we simply bypass the check in that case. Note that this should fix most of the problem, but a deeper problem still remains: a crash can still happen when an onchange modifies a record in a one2many (but in a different page), and we also have a modifier which needs to be evaluated. opw: #1904514 [1] https://github.com/odoo/odoo/pull/29086 closes odoo/odoo#29172 closes odoo/odoo#29086
2018-11-28[MERGE] forward port branch 11.0 up to bb6f6c57f97Christophe Simonis
2018-11-30[FIX] web: prevent crash in some cases (o2m)Géry Debongnie
Recent works in the orm (see [1] for example) changed the behaviour of the server in the case of onchanges: it tries to optimize Odoo by sending a minimal diff to the web client in onchanges. Concretely, this means that the web client receives commands 4 (link to) instead of command 1 (update + record data). It also sends a minimal diff in that case. This is a big issue for the web client, because it relied on the knowledge of the data from the command 1 to be able to evaluate some modifiers. The good news is that we can mitigate the issue in one case: we do not actually need to evaluate the modifiers in the case of a command 4 (comming from the server), because we can assume that the record is valid. So, we simply bypass the check in that case. Note that this should fix most of the problem, but a deeper problem still remains: a crash can still happen when an onchange modifies a record in a one2many (but in a different page), and we also have a modifier which needs to be evaluated. opw: #1904514 [1] https://github.com/odoo/odoo/pull/29086 closes odoo/odoo#29172
2018-11-29[MERGE] forward port branch saas-11.3 up to c0eef427111Christophe Simonis
2018-12-05[MERGE] forward port branch 12.0 up to 053bb45706fChristophe Simonis
2018-11-28[FIX] web: context orderedBy not propagated to x2mLucas Perais (lpe)
Have: - Model A with a x2m to model B - Object A with multiple objects B in x2m (that will be sorted) - On the list view of model A, click on a column to sort by a field - this field shall not exist in B - open a record A (towards form view) Before this commit, the sorting of the x2m crashed, because the key orderedBy was propagated Due to commit e713ed2a69af9fe97fbe2d54843adc8f1ce689aa After this commit, it doesn't crash OPW 1913133 closes odoo/odoo#29094
2018-11-22[MERGE] forward port branch 11.0 up to 263b388c504Christophe Simonis
2018-11-29[FIX] web: correct test definitionChristophe Simonis
Oversight of previous forward-port
2018-11-29[MERGE] forward port branch 12.0 up to 82a1e1dcc33Christophe Simonis
2018-11-23[MERGE] forward port branch 12.0 up to b3052b690faChristophe Simonis
2018-11-22[MERGE] forward port branch saas-11.3 up to b09f624f207Christophe Simonis
2018-11-19[FIX] web: m2o+o2m in o2m onchange no lose dataNicolas Lempereur
Steps: - open a modal form view from tree view first line and make a change - open a modal from the second line and make a change - open the second line back: the change were lost In a given number of conditions (a many2one inside the form view, there is a one2many in the form view not inside the tree view, ....) this happened because: - when we save the first line, we get onchange data for the second one - this onchange data can't be applied before second line is loaded, but it is saved so it can be applied if second line is ever opened - when the second line is opened the saved change is applied => OK - when the second line is opened a second time the saved change is applied again, possibly overwriting posterious change => BAD With this changeset, when the record with unapplied onchange is loaded for the first time, the unapplied onchange is applied only once. Added test without the change failed with: - only 1 turtle for second partner (result: 0 not 1) - second partner turtle is Michelangelo (result: "" not "Michelangelo") opw-1846820 closes #28644
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-12[REF] web: split relational fields tests into multiple filesVincent Schippefilt
The file relation_fields_tests.js was a huge 12K lines files for which some editors have a hard time managing. We have split it in 4 files to be more managable and removed remove unused data and import. closes odoo/odoo#28561
2018-11-09[FIX] web: extend the fieldsInfo of a view with the origin view to evaluate ↵Aaron Bohy
extra fields Suppose you are editing a SO to add a new line. Depending on the configuration, a sale order line wizard may open (e.g. if packages are activated). This wizard is a form view, opened from the tree view of the sale order lines. We have commit 8e5156938a9c87b80512bff9ecd025891406e624 that adds extra fields from the originating view. (However it doesn't work if the other view is inlined, so we modify this part to add the extra field even in this case.) Then we need the field info from the origin view in the target view; we do so by extending the former with the content of the latter. opw 1904337 closes odoo/odoo#28441