summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields
AgeCommit message (Collapse)Author
2021-04-28[FIX] web: make test pass on chrome 90Aaron Bohy
The changed test uses the drag&drop helper, and an operation does not work as expected with the given params on chrome 90. The runbot currently uses chrome 80, so it is not an issue, but if your chrome is up-to-date, and you try to run the test suite, this test would fail. closes odoo/odoo#70008 X-original-commit: 43994da9980e4133274984f720bb58f3546ea0f9 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com> Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-04-13[FIX] web: onchange: send correct nested x2manys valuesAaron Bohy
Commit [1] recently fixed an issue with nested x2many fields and onchanges: in some cases, all field values weren't sent to the server as they should. However, there is a small issue with this fix. We didn't correctly apply the default value to option `changesOnly`: when not given, it was considered false, whereas in this particular function it should have been true. It caused an issue in the following scenario: Have a form view with an x2many field (say A) displayed as a list. In the list, there is another x2many field (say B), and (whatever its type) a field C with an onchange. When the user changes C, the onchange is performed, and we send to the server the value of all fields. In particular, in the row, we send the value for the many2one field pointing to the main record (the inverse field of the x2many relation). The value for that field is basically the whole record, containing itself field A. For field A, the value is a list of commands, and for the updated record, it is a command 1. Before this commit, in the values sent for this command, field B was the empty array, even if it wasn't empty. This issue was reproducible in account.move, on an existing record having already a line in invoice_line_ids (this is field A). In that line, tax_ids (this is field B) must have a tax which is included in the price. When changing the quantity of the product, the subtotal wasn't correctly computed. [1] https://github.com/odoo/odoo/commit/a8b43d02066b2299ac2f4b88056c37725e9ce6cd opw~2489755 closes odoo/odoo#69167 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2021-03-24[FIX] web: can update one2many with custom field widgetKrzysztof Magusiak
One might design a custom field widget to display/interact with a one2many field. Before this commit, if this field widget triggered a field_changed event to update a related record, it crashed, because the code assumed that there was a view associated with the field. Closes #68276 opw~2468238 closes odoo/odoo#68294 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com> Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Co-authored-by: Aaron Bohy <aab@odoo.com>
2021-03-11[FIX] web: nested one2manys, onchange and no commandAaron Bohy
Let's assume the following situation. We have a form view with a one2many field A displayed as a list. In the list, there is a one2many field B. B can't be edited, its value is computed by an onchange. By default, it contains a single record (i.e. the first value returned by the onchange is [[5], [0, 0, {...}]]). When another field (say C) changes, B's value is re-computed to [[5]]. Moreover, there is an onchange on A. In this form view, let's assume the following scenario. Create a new record and add a line to A. In this new line, B already contains a record. Change C. This triggers an onchange that returns [[5]], and B is now empty. It triggers a second onchange, on the main record (as field A changed). Before this commit, in this second onchange, B's value wasn't sent among the other values of the new line. The spec says that for onchanges, we must send all data, not only what has really changed. From that perspective, the above scenario highlights an issue. That issue had two root causes. First, commit [1] wrongly fixed another issue, and as a consequence, when building what to send for the onchange, we didn't generate the values for fields that hadn't changed inside an x2many (for added subrecords at least). This commit reverts the fix of [1], and fixes it differently by only sending a command 1 (update) after a command 4 (link to) when the record is dirty (i.e. when it has been modified). See [1] for context and details. Second, the code that generates the values to send to onchanges is the same as the one that generates the values to save records (write or create). However, when saving, we only send what has really changed. The values are at some point processed to remove empty command lists from the list of changes (as it means that nothing changed). However, here we ignored the flag that stated whether we want all field values or just what has changed. This commit takes the flag into account before removing the field's value. [1] https://github.com/odoo/odoo/commit/3e3a244e1afc4d74920a6302a14fa2590e8b6648 Issue reported in task~2352524 Model: account.move One2Many (A): account.move.lines Nested computed One2Many (B): tax_detail_ids Field triggering the onchange (C): tax_ids closes odoo/odoo#67679 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com> Co-authored-by: Géry Debongnie <ged@odoo.com>
2021-03-08[FIX] web: FieldMany2Many: link/unlink optionsAaron Bohy
Commit [1] altered the way the FieldMany2Many behaves with respect to 'create' and 'delete' options. Indeed, for many2many fields, adding or removing records doesn't mean "creating" or "deleting" records, as it is only about adding/removing records to/from a relation. This is completely fine and correct. Unfortunately, a feature has been lost in the process: it is no longer possible to state that a many2many field should be editable but should not allow to add (or remove) record to the relation. This commit fixes the issue by adding two new options: 'link' and 'unlink' for that purpose. [1] https://github.com/odoo/odoo/commit/c98579d25af01c14df4baf57fb4652f3e7469096 opw~2466213 closes odoo/odoo#67358 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2021-02-09[FIX] web: fields info for a specific view can be undefinednie
Steps: - Install mrp - Go to Manufacturing > Master Data > Bills of Materials - Create a BoM - Components: - Add a component - Save - Click the component - Close the modal window - Click the component once more Bug: Traceback here: https://github.com/odoo/odoo/blob/55a6642a9621fa9683895d5d45a015bb04c3017b/addons/web/static/src/js/views/basic/basic_view.js#L147 Error: can't convert undefined to object Explanation: As seen on the line just above: https://github.com/odoo/odoo/blob/55a6642a9621fa9683895d5d45a015bb04c3017b/addons/web/static/src/js/views/basic/basic_view.js#L146 `fieldsInfo` might not have the view we are looking for. opw:2452142 closes odoo/odoo#65805 X-original-commit: b27c0698d95cbccaa6c35a1fd3faa852a71ac2c2 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Signed-off-by: backspac <backspac@users.noreply.github.com>
2021-02-05[FIX] web: nested x2many with non inline viewsAaron Bohy
This commit partially reverts commit [1], and backports commit [2] from 14.0. Even though [1] correctly fixes the faulty scenario, there is a variation of this scenario which isn't handled. It has been fixed in 14.0 by [2], and that fix also fixes the original issue of [1]. So we keep the tests of both [1] and [2], and the fix of [2]. [1] dd97d446ee94a32089f200bb7122139d31e69873 [2] f6c06bd0b87dac11d76a3134eb61c7ef4eb59270 closes odoo/odoo#65562 X-original-commit: 63c60549ef5185f5ec61dc985f0bcc2cb82ccc89 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com> Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-02-01[FIX] web: Auto close dropdown is brokenRomain Estievenart
Steps to reproduce: 1. Go to Project App 2. Open and edit a task 3. Click on Customer => search more 5. Click on "Filters" 6. Click on "Group by" => The "Filters" and "Group by" dropdown are open at same time => bug Since odoo/odoo@e4f87710e16357f24f388159a7b1e82eccda598a, we added a way to prevent bs and owl dropdown to be open in the same time. But when the web-editor is present, the CSS selector used to match the opened modal ("search more" in this case) conflicts with the DOM created by the web-editor (modals identified by the classes: .web-editor, .note-picture-dialog, .note-link-dialog, .note-help-dialog). To avoid this conflict, this commit uses a more restrictive CSS selector to match only the first (active) opened modal (as web-editor doesn't attach its modals at the root of the body). closes odoo/odoo#65274 Signed-off-by: Pierre Paridans <pparidans@users.noreply.github.com>
2021-01-28[FIX] web: nested x2many with no widget and onchangesNicolas Lempereur
Let's assume the following situation: in a form view, there is a one2many field A displayed as a list (non editable). In the list, there is another one2many field B displayed with no widget (it basically displays "X records"). In A's form view, B is also displayed, but this time as a list. There is an onchange on the main form view that adds a line in A, (and simply sets B to [[5]], i.e. 'No record'). Before this commit, if the user opened the newly added sub record in A, and clicked on 'Add a line' of B, it crashed. The cause of the crash was that the wrong viewType was used to create the new (default) record in B: it used the original viewType, which was undefined (B is displayed with no widget in A's list). With this commit, we use the viewType of B that is used to edit it, in this case 'list'. In the slighlty different scenario where B is displayed with widget many2many_tags in A's list, there were no crash, but wrong fieldNames were sent to the 'default_get' RPC. As a consequence, default values for fields in B's list were potentially not loaded. opw-2422806 closes #64793 closes odoo/odoo#65157 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com> Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Co-authored-by: Aaron Bohy <aab@odoo.com>
2021-01-14[FIX] web, purchase_product_matrix: can open twice the matrixAaron Bohy
Let's assume the following scenario with 'purchase_product_matrix' module installed: - create a new Purchase Order - add a line in the one2many - select "Customizable desk" as product - [the desk matrix opens] - close the matrix - select "Conference chair" instead - [the desk matrix opens, whereas it should be the chair one] It didn't work because of a small bug in the FieldOne2Many. This field is configured to be reset when any other field in the view changes. The product configurator feature relies on that. However, when another field changes, the One2Many didn't update its internal state with the new record (and it skipped the rendering, which is fine). The matrix product configurator thus read an obsolete value in the internal of the one2many. Since the internal state is now always up-to-date, we can directly read there the grid information, instead of looking inside other fields that have been updated (attempt done in [1]) It would be nice to rethink the whole product configurator stuff in master, to make it more robust, maybe when converting it to owl? [1] https://github.com/odoo/odoo/commit/21bcafc053be7f80eed7a684fee2dc1e3caaafa5 opw~2421798 closes odoo/odoo#64552 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2020-11-27[FIX] web: BasicModel: nested x2many and unknown fieldsAaron Bohy
Consider the following situation: - have a form view with an x2many field displayed as a list - the x2many field has a form view that contains an x2many field, which isn't in the list - for that x2many field, we can also open a form view to see/edit the related records. As the x2many field isn't in the list, when we open a subrecord, we modify the fieldsInfo to add the information about the x2many field we didn't know before. Doing so automatically applies raw changes that we might have stored earlier (from onchanges) for that field, because we couldn't apply them before knowing the type of that field. Before this commit, the function that applies the raw changes was called recursively on the dataPoint and all its children (thus on the x2many list datapoint), which produced a crash as this function is designed to work on dataPoints of type record. Actually, calling it on sub datapoints is useless, as it properly works recursively, and applies raw changes on x2many fields itself when necessary. This commit ensures that we don't call this function on list datapoints anymore. Closes #62334 OPW 2389991 closes odoo/odoo#62399 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2020-11-18[FIX] web: race condition with x2many control panelAaron Bohy
The ControlPanel has been converted in Owl [1], and the code using it has been adapted accordingly. However, in the FieldX2Many, we didn't properly wait for the ControlPanel to be updated (an update of the ControlPanel was synchronous before owl, and is now async, like every Owl renderings, as it waits for the nextAnimationFrame). As a consequence, we might have tricky issues because the mounted hook of the control panel might be called multiple times for a single call to willUnmount later on. In mobile, we bind a global event handler (on scroll) in mounted, and unbind it in willUnmount, so we had leftover event handlers, that crashed when called after the ControlPanel was destroyed. Note that even if the issue popped in mobile, calling mounted on already mounted Components isn't a good idea, and this should be fixed anyway. The issue could be reproduced for instance in FieldService (with collaborative pads activated in Project), in mobile, by opening a task in Edit mode. Then, you might get a traceback by scrolling after having discarded the edition Here is a description of what technically happened: - when clicking on Edit, all widgets (including the FieldX2Many are destroyed and re-instantiated in 'edit' mode). - the pad widget directly triggers a field_changed event which causes a reset of the FieldX2Many (i.e. 'render' is called again) - the FieldX2Many detects that it already has a renderer (and a ControlPanel) so it updates them - it first updates the renderer, and when it's done, it updates the ControlPanel BUT doesn't wait for its promise, so the promise returned by that call to 'render' in FieldX2Many is resolved before the ControlPanel is actually updated - note that at this point, all thoses new widgets are not in the DOM yet - when all widgets are ready, the renderer patches the view (i.e. the former content is removed from the DOM, and the new one is attached into the DOM). As soon as this is done, the renderer calls 'on_attach_callback' on its children, including the FieldX2Many, which leads to a call to 'mounted' on the CP. - then, just before the nextAnimationFrame, Owl complete the rendering of the CP, and detects that it is now in the DOM (it wasn't at the beginning), so 'mounted' is called a second time, will cause the issue described above. This commit fixes the issue by properly waiting for the CP to be rendered in the FieldX2Many. However, this required on cascade changes: - Form view renderings with a FieldX2Many are now *really* async (+- 16ms), meaning that the user can easily trigger concurrent renderings by, e.g. clicking quickly several times on 'Edit', 'Save' or 'Discard'. Concurrent renderings are properly handled so to prevent this from happening, we disable the buttons and re-enable them when the rendering is done (like already done in [2]) - in the FieldX2Many, '_updateControlPanel' was called at several placed, but we never waited for it. As this method was originally sync, its calls have probably been naively adapted, whereas their should have been deeply rethought (for instance, as it is async, and we need to wait for it, we don't want it to be called multiple times sequentially when something happens). This commit does that work, i.e. we clean the places where this function is called such that it is (hopefully) never called sequentially twice. To do so, we changed a bit the spec of the pager in multi page, and we also fixed a paging-related bug. In a few words, here is what we did/do when adding a new row in the bottom of a full page: - before: tweak the count in the data to fool the pager and make it think that no new record has been added (so basically, let it display something wrong) - now: temporarily increase the pager limit so that the new record is displayed on the current pager, and the pager values are correct w.r.t. the displayed records. Some tests needed to be adapted accordingly. - By waiting for the ControlPanel when updating the FieldX2Many, a bunch of QUnit tests failed. Those tests have something in common: they spawn an X2Many (list or kanban theoretically, but always list in practice) containing a FieldBoolean (only field widget of /web converted in owl). When the FieldX2Many is updated, we update the renderer (i.e. re-renderer the FieldBoolean, so we have to wait for the nextAnimationFrame), and when this is done, we update the page (again, we have to wait for the nextAnimationFrame). So basically, we have to wait for two nextAnimationFrames to see the result in the DOM. For this, we added a new test util which basically does a nextTick ('owlCompatibilityNextTick'), and called it everywhere it was necessary. When everything will be written in Owl, we could get rid of this util and its calls. [1] https://github.com/odoo/odoo/commit/fbf347498f1cc7b74ef373179b7bcae201715c24 [2] https://github.com/odoo/odoo/commit/39f08950d6e20460e3a20a5b9c33e4ddf66dce78 closes odoo/odoo#61593 Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2020-10-29[FIX] *: correct typos and bad EnglishMartin Trigaux
Courtesy of translators Reexport .pot of modified modules closes odoo/odoo#61002 Related: odoo/enterprise#14485 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-08-20[REF] web: BasicModel: combine default_get and onchangeLucas Perais (lpe)
This commit adapts the BasicModel to combine calls to `default_get` and (first) `onchange`. When creating a new record, we now only call `onchange`, which thus return default values and potential onchange values. Tests (and the MockServer) have been adapted accordingly. NOTE 1. If the `default_get` within the `onchange` returns a value for a field that is not in the view, we ignore it, and it won't be saved. Before, that value was kept and sent upon save. This change in behavior may prove problematic, although the overall risk is small. Decision has been made to keep heavy comments and code snippets if we were to revert back somehow to the previous situation. NOTE 2. Putting a context on a many2one field may change the value returned by `name_get` for that field. By default, the calls to `name_get` are done by `onchange`. If the context on a field must be used for `name_get`, one has to set the option `always_reload` to `True` on the field. In that case, every `onchange` that changes the value will trigger an extra `name_get`. NOTE 3. Suppose that a one2many field has a list view with field A, and a form view without field A. When adding a line, we now send all known fields (main view and inline views) to the `onchange`, which may return a default value for A. The value will appear on the list view, but not in the form view. The former behavior was to call `default_get` with the fields that occur in the form view only, and therefore field A would be left to value `False`. NOTE 4. A test surprisingly adds an extra call to `read`. The test was actually wrong before. With the changes in MockServer, we now correctly receive a command `[6, false, [1]]`, whereas before we received `[1]`, which isn't a valid command, and which was ignored. As a consequence, an extra `read` is done, whereas the test asserts it shouldn't. But it already didn't work before (I checked by sending the correct command). This needs to be bugfixed elsewhere (task-id-2323491): in a o2m with a onchange and default order records on an other page than the first should not trigger a `read`. Task 2261084 Co-authored-by: Raphael Collet <rco@odoo.com> Co-authored-by: Aaron Bohy <aab@odoo.com>
2020-08-13[IMP] web, *: improve mock server and replace most mail mockRPCSébastien Theys
Improve mock server: - add support for mocked `fetch` - add support for `active_test` - add support for x2m `in` in domains - add support for default values computed from a function - implement a more natural "next id" compute - allow initial data without ids - ensure write and x2m commands integrity - improve bad data/bad commands error messages - always warn for failing RPC, not only in debug mode - fix all existing tests that had inconsistency data Other changes done in mail (or dependents) that are not just related to tests: - remove `direct_partner` from formatter result ->`correspondent` can be computed from other keys, especially `members` - fix `livechat_visitor` convertData -> only process if there is value - add `current_partner` and `current_user_id` as `init_messaging` result -> easier to mock than session - remove usage of `need_moderation` -> that was just a search indirection to `moderation_status` - adapt `partner_id` -> `res_partner_id` key in `_notification_format` -> to be consistent with field name - add name in result of `mail_partner_format` -> sometimes display_name is not the same - remove usage of `is_moderator` -> that was just an indirection to `moderation_channel_ids` Enterprise counterpart: https://github.com/odoo/enterprise/pull/11523 task-2287171 closes odoo/odoo#55854 X-original-commit: 7ba3fecb3377a720d1eb70e7515a0c45da73836d Related: odoo/enterprise#12391 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2020-07-09[FIX] web: trying to create record based on name_create w/o _rec_nameJoseph Caburnay
There are orm models that don't have _rec_name defined. The orm doesn't allow creation of record via name_create if _rec_name is not defined in the model. This commit considers this fact, such that if name_create returns false, we don't proceed on displaying the non-existing record. Note: _rec_name defaults to 'name' if not specified so only few models don't have _rec_name. closes odoo/odoo#54270 Task-id: 2285036 X-original-commit: 676c2b8e4fdf7347d44bc5afb7ca51d39338a527 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-06-23[FIX] web: list: buttons with attrs column_invisibleAaron Bohy
Since commit 042b4060bdbbd, attrs 'column_invisible' on button was ignored. This commit makes this work alongside the adjacent button grouping feature: if all adjacent buttons have their attrs column_invisible evaluated to true, no column is rendered for this group of adjacent buttons. closes odoo/odoo#53489 X-original-commit: 3110e34ab8e5ec3bf7160655af21f72b4d2179db Signed-off-by: Julien Mougenot (jum) <jum@odoo.com> Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-06-12[FIX] *: adapt tests to env reworkAaron Bohy
This commit adapts tests following recent changes on the helpers. The main change is that addMockEnvironment (and all functions using it) are now async, as they need to wait for services to be started.
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-05-27[FIX] web: resquencing stop at first controllerNicolas Lempereur
When a resequencing is done inside an object hierarchy of two controllers, since 9b90d8727d we would call resquencing code one time per controller. So if for example we are in a list view inside a form view (eg. a "Search More" modal in a form view) the resequencing would work for the list view, but then cause traceback when it is handled by form view. With this changeset, the first controller that get the event `resequence_records` even gobbles it up. Without change, added test fails because of original traceback: Cannot read property 'res_id' of undefined@ 202 ms Source: TypeError: Cannot read property 'res_id' of undefined at /web/static/src/js/views/basic/basic_controller.js:744:67 ... opw-2256818 closes #51827 closes odoo/odoo#52018 X-original-commit: eef4b99fdb9469c040af80d055933eda367b7b3d Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-05-08[FIX] web: failing quick create in m2o inside x2mAaron Bohy
Write something in a many2one field, and click on 'Create "..."' to quick create a record with the given value (name_create). When the name_create fails (e.g. because there are mandatory fields in the model), we open a form view. Before this commit, when this happened for many2one fields inside x2many editable lists, it crashed, since [1]. [1] 50bf8309f88fb6c8d8e27b14d40450e92e5a4e4e closes odoo/odoo#50948 X-original-commit: 43c513306094444ff25ad98584b426ddb8a3b525 Signed-off-by: Julien Mougenot (jum) <jum@odoo.com> Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-05-05[IMP] web: FieldMany2one: reword and simplify dialogDhruv Patel
This commit improves the dialog that opens when a user clicks out of an 'un-commited' many2one. It is no longer possible to edit the value, and the sentence has been reworded. closes odoo/odoo#49528 Task: 2234212 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-05-05[IMP] web: add Many2OneAvatar field widgetAaron Bohy
In readonly, this widget displays the image of the related record next to its display_name. In edit, it behaves exactly like the regular many2one. Part of task 2195254
2020-04-06[IMP] do not propagate default_* key from parent context to sub viewMohammed Shekha
before this commit: from commit: https://github.com/odoo/odoo/commit/d58d6e270f4106d717821438490f60bc4f71306e parent context was propagated to sub views, propagating whole context to sub view creates issue as it contains default_* key inside it, there is a chance that sub view has same field name which matches with default_fieldName in context, e.g. go to sale order form view and create sale order line, while selecting product, write in product_id field so that Create and Edit option comes, select Create and Edit option, so whatever previously written in product_id field will be added in product.product form's context as default_name, now go to Purchase tab of product form and try to create Supplier, but note that Vendors One2many should be editable, if it is not then to produce this issue, make Vendor o2m list editable top/bottom, as soon as you click on Vendor o2m's create button traceback generated which comes from name_get of res.partner, issue raised because vendor o2m has m2o of res.partner and field name is 'name', when default_get for vendor o2m is called it will propagate context and context has default_name='typed string in product_id', as name field is m2o with res.partner it will generate traceback as m2o accepts (id, name) tuple not string after this commit: propagate context to sub view but remove default_* keys from parent context task-2121161 closes odoo/odoo#49075 X-original-commit: 2e3756e0ce96a9e0c5fa304632a2600cbd832ef5 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-03-20[FIX] web: nested x2many with non inline viewsAaron Bohy
Let's assume a form view with an x2many list, containing itself an x2many field (no widget, so simply displaying the number of records). When a record of the list is clicked, a form view opens and displays the same sub x2many field, with widget many2many_tags. Both list and form views of the x2many aren't inline (thus have to be fetched on demand). Before this commit, it crashed when the user clicked on a row of the x2many list. The bug has been introduced by a9cebd5a, which wrongly removed the code handling this specific situation. At least, now we have a test attesting that this code isn't useless. Note that the diff isn't as scary as it looks like (we just added an if/else, and thus indented the former code inside the else clause). closes odoo/odoo#48116 Signed-off-by: Géry Debongnie (ged) <ged@openerp.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>
2020-03-09[FIX] web: FieldMany2ManyTags: failing quick create recordAaron Bohy
The FieldMany2One allows to quick create record (name_create). However, sometimes, required fields on the co-model make the name_create crash. In this case, the FieldMany2one opens a form view in a dialog to let the user specify those fields, and create a new record with the 'create' method. This was working fine. The FieldMany2ManyTags embeds a FieldMany2One to let the user search for and select or (quick) create tags. In this case, failing quick creation didn't fallback on the dialog form view, but displayed a server error instead. This commit fixes this issue. Bug introduced by 50bf8309f88fb6c8d8e27b14d40450e92e5a4e4e Task 2192754 closes odoo/odoo#47183 X-original-commit: 63ab065f3298c13bb19ae1245d7fd2652581b254 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-03-09[FIX] web: save all values returned by onchangeAaron Bohy
Let's assume a form view with a boolean field and a one2many field, displayed for instance with widget many2many_tags. There is an onchange on the boolean field, which populates the one2many, e.g. [[5], [0, 0, {display_name: 'name', other_field: 'value'}]] Before this commit, only the display_name was sent to the server on save, because 'other_field' is unknown by the webclient. Similar situations occurred with one2manys displayed as lists, and onchanges returning values for fields that aren't in the list. These situations probably didn't exist in Odoo yet, but a pending task on website event adds one. This commit ensures that all values returned by the onchange for the x2many subrecords are sent back to the server when the user saves. closes odoo/odoo#46807 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2020-03-09[FIX] web: x2many: use correct viewTypeAaron Bohy
This commit fixes two issues that occurred in the following situation: in a form view, have a one2many field F1 displayed as a list, that contains another one2many field F2, displayed with widget many2many_tags (in the list), and with a list in the form (in the dialog). In the dialog, the list of F2 displays a field, say 'name', which has an onchange that sets 'display_name'. Moreover, there is an onchange in the (main) form view, that populates F1 and F2, for instance, it returns something like: { F1: [[5], [0, 0, { F2: [[5], [0, 0, { display_name: 'xxx', name: 'xxx', }]] }]] } 1) If the user opens a related record in F1, and adds (in the dialog) a related record in F2, then validates the dialog, the newly created record in F2 isn't correctly displayed in the many2many_tags (the display_name is `false`), i.e. the onchange hasn't been applied. 2) If field 'name' in F2 in the list is required, the new record can't be saved, even if the user enters a correct value. In both cases, the reason is that we use the incorrect viewType in datapoints: as we don't specify that we specifically want 'list', the 'default' one is taken, and we thus use the fieldsInfo of the many2many_tags, which only knows field 'display_name'. As a consequence, onchanges aren't correctly applied (issue 1), and fields aren't correctly reset (issue 2). Issue reported on task 2189529
2020-03-09[FIX] web: BasicModel: always set a valid limitAaron Bohy
When x2many fields are displayed with widgets like many2many_tags, there is no limit on the number of related records to fetch and display. In this case, the 'limit' attribute on the datapoints is undefined. This could lead to weird issues when the limit is used in computation, e.g. var index = list.offset + list.limit; // = NaN There are several occurrences of the above examples in the code, which can be observed in specific scenarios, e.g. the one encoded in the test. In this scenario, when the bug occurs, new records added to editable list views are inserted on top (even if the list is editable="bottom"), but the edited row is the last one. Issue reported on task 2189529
2020-03-09[FIX] web: handle nested one2manys and onchangeAaron Bohy
Let's assume the following scenario in a form view: - have a one2many field, say fieldA, displayed as a list, containing another one2many, fieldB, (no widget, thus displaying 'n record(s)') - the one2many list is not editable, so there is a sub form view, displaying fieldB as a list, and in this list some random field, say fieldC, is displayed - have a random field on the main form view, with an onchange to populate the one2many - set that random field s.t. the onchange returns something like fieldA: [[5], [0, 0, {fieldB: [[0, 0, {fieldC: 'value'}]]}]] - there is now a record in fieldA's list, displaying '1 record' as value for fieldB - click on that record to open it in a form view (dialog) - in the dialog, in fieldB's list, we expect to have a single row displaying 'value' as value for fieldC Before this rev., it crashed when opening the record in the dialog, whether the form view was inline or not. The crash occured because fieldB was already in the list view, so datapoints already existed for it (a list datapoint, and record datapoints for records in the relation, in our example one record datapoint). However, those datapoints didn't have the fieldsInfo of the form view. When opening the form view, we added the fieldsInfo of the form to the datapoint of the record we opened, but we didn't recursively apply the fieldsInfo to its children. As a consequence, when rendering the list view for fieldB in the dialog, we haven't the information about fieldC, and it crashed. Note that if fieldB wasn't present in fieldA's list view, it worked fine because datapoints didn't exist before we opened the record in the dialog. Task 2120235
2020-03-04[IMP] web: trim many2one search termsMohammed Shekha
This commit trims leading and trailing spaces in search terms of many2one. task-2187414 closes odoo/odoo#45282 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-02-06[IMP] web: many2many list editable as m2m_tagsLucas Perais (lpe)
Before this commit, there was a discrepancy between many2many_tags widget and regular many2many list That is, in tag mode, when someone had read access alone on the comodel he could modify the members of the m2m relation on the current model Which couldn't be done in m2m list After this commit, it is possible in a m2m list to add records to a relation, even if we don't have CRUD access on the comodel Task 44074 closes odoo/odoo#40194 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-01-22[IMP] web: conditional create/delete options on x2many fieldsMohammed Shekha
After this commit, x2many fields can have options like create/delete which accept a domain, to make create/delete on x2many conditional, say for example x2many field can have options like: options="{'create:' [('foo', '=', True)]', 'delete:' [('foo', '=', True)]'}" With this when foo field is True, Create and Delete actions will be available, but if foo is False then they won't. In case of one2many fields, if 'create' is false, then 'Add a line' (list) or 'Add' button (kanban) won't be displayed. In case of many2many fields, 'Add a line' or 'Add' button will always be displayed even if 'create' condition is false as it doesn't really create records (but rather links existing ones). Same applies for delete. Task-2092953 closes odoo/odoo#42919 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Co-authored-by: Parth Chokshi <pch@odoo.com> Co-authored-by: Aaron Bohy<aab@odoo.com>
2020-01-21[FIX] web,*: fix race condition with m2o quick createAaron Bohy
*sale,sale_product_configurator Let's assume a form view containing a many2one with an onchange that updates the value of a one2many. Do a quick create in the many2one. While the name_create request is pending, add a row to the one2many but do not leave it. When the name_create returns, and the onchange has been performed, the one2many is reset, and the row is no longer in edition (worse, it could be invalid, i.e. in a state that the user could not have reached in a normal situation). This commit fixes this issue by considering the whole [name_create + onchange] operation as one. This operation is executed in the mutex of the model, so the other request (adding a row to the one2many) is delayed until the many2one value has been correctly set. This fixes an issue with the sale and rental tours (on sale_order), that had been deactivated for a while.
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-12-09[REV] web: reverts update to fontawesome 5.11.2Kevin Baptiste
This reverts commit ff1c35513aecef5fbc30f7c2f3834450e719714e. closes odoo/odoo#41480 X-original-commit: 116057b26e71db4692280463669f3e80d813ddcc Related: odoo/enterprise#7110 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-11-28[IMP] web: update to fontawesome 4.7.0 to 5.11.2Kevin Baptiste
FontAwesome 5 introduced new names for some icons as described on https://fontawesome.com/how-to-use/on-the-web/setup/upgrading-from-version-4#name-changes This commit replaces the old names to the new ones. closes odoo/odoo#35826 Taskid: 2050241 Related: odoo/enterprise#5180 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-11-20[FIX] web: handle m2o whose comodel name field is an m2oAaron Bohy
This is a weird situation, but the python handles it. Let's assume a many2one field F1 on model M1 with comodel M2, and on M2 the name field (which is the _rec_name) being itself a many2one, and the following scenario: - create a new record for M1 - for field F1, select 'Create and Edit': it opens a form view for M2 in a dialog - type something in F2 input, and click 'Quick create' - save the dialog Before this rev., the value of F1 was [object Object]. Now, the new value is properly displayed. OPW 2091106 closes odoo/odoo#40549 X-original-commit: 5a04ea848abf50b1fb1f9893d1fcd98013bc025d Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2019-10-07[FIX] web: m2o updates its value after reloadJulien Mougenot
Changes the behaviour of many2ones when their value is changed via a form dialog. Before this commit, when editing a m2o with a form dialog opened by an external button, the field triggered an onchange with its old value before reloading its widget. This caused the edition in list views to display outdated information when saving multiple records. Now, the reload is executed first, then the onchange occurs so that the value is the newly updated one. Part of task 2078807 closes odoo/odoo#37576 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2019-09-30[FIX] web: multi-hell-ditable listVincent Schippefilt
only activate multi-edit on list with specific attribute. When the attribute multi_edit="1" is set on the tree view the user can select a/some records and it will activate the multi-edit with confirmation dialog (even for a single record). Also, on-change are not applied when using multi-edit closes odoo/odoo#37525 Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
2019-09-25[FIX] web: correctly handle 'oe_read|edit_only' in listsAaron Bohy
ClassNames 'oe_read_only' (resp. 'oe_edit_only') can be used in x2many lists to hide columns in 'edit' (resp. 'readonly') modes. However, before this rev., there were two issues: 1) Having such a className on a <button> tag didn't work well as the 'display: none' rule didn't apply on the body cell (it only applied on the button). Same could be observed on <widget> nodes. 2) Having more than one invisible column (with those classNames) didn't work either, because the footer cells weren't hidden. We didn't notice it with one invisible column, because the footer contained one cell less than the header and the body. Those two issues could be observed on the mrp.bom form view. Task 2068261
2019-09-19[FIX] web: fix m2mtags widget to be able to use 'SAVE & NEW'Samuel Degueldre
PURPOSE Previously when the 'SAVE & NEW' button was pressed in the 'create and edit...' menu of the many2many_tags widget was pressed, the modal window would close and the button would act exactly like the 'SAVE & CLOSE' button. This was due to the fact that whenever a new record was created and added to the field, it would reset the many2one field it uses for display, which would destroy the edit modal. This commit fixes that by not notifying the underlying many2one field of any change until the modal is closed by the user. This has the disadvantage that tags display, if visible behind the modal 'shade', will not be updated until the modal is closed, but restores the functionality of the save&new button. It also adds a test for this behaviour task-2070454 closes odoo/odoo#37114 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2019-09-18[FIX] web: list: m2o doesn't trigger fieldChange when emptyJulien Mougenot
Gives time to the user to enter an actual value in m2o in list views. Before this commit, emptying a many2one field (selecting all > BACKSPACE or DELETE) triggered instantly a field_change. This was an issue in multi edition as a field changed triggered instantly a save on selected records without giving time to the user to enter a new value. Now, many2ones only trigger a fieldChange when selecting a new valid value. Task 2068280
2019-08-26[REF] web: remove test coverage overlap in mobile test suitePierre Paridans
The tests in the file `relational_fields_mobile_tests.js` - which is part of the mobile test suite - are actually not specific to mobile. This commit merges those tests asserts into the tests already present in the regular test suite. It ensures that all the existing asserts remains and the actual coverage stays the same.
2019-08-26[REF] web,*: native event dispatching in test utilsJulien Mougenot
*: mail,partner_autocomplete: adapted tests Added a new function to trigger the adequate type of event on an element (native JS event to DOM Nodes and jQuery event to jQuery objects), and refactored the generic event-triggering functions to call this new function.
2019-08-23[FIX] web: editable list: widths when toggling fieldsAaron Bohy
Let's assume the following situation: - an empty editable x2many list with date field (or any other fixed width field) and optional fields - add a record to the list, but discard it directly - toggle an optional field After those steps, the date field doesn't have its hardcoded, absolute width anymore. This rev. fixes this issue by clarifying the way the stored widths are erased when the columns change, preventing to reach a corner case in which we have stored widths, but we can't apply them, and thus let the browser uniformly divide the space amongst columns.
2019-08-23[IMP] web: list: keep widths when removing last recordAaron Bohy
When there were records in the list (and the browser computed the optimal column widths according to them), and the user removes them, we want to keep the widths as they are instead of forcing them according to the field's types.
2019-08-23[IMP] web: list: keep columns width when adding recordsAaron Bohy
Mainly, when adding the first record to the list, as this is when we switch from forcing the column's widths (when there is no data), to letting the browser optimally divide the available space. Some other cases had to be handled, like the multi edition.
2019-08-21[IMP] web: keep dirty fields dirtyGéry Debongnie
Before this commit, a simple optimization was done: if a field was modified in such a way that the new value is the same as the initial value, then it is not considered changed. However, with the new changes in the ORM, it may be an issue, because doing so loses the intent of the user. If an onchange changes a field, then the user changes it back, the server is not aware of that fact. With this commit, we simply keep the field in the list of changes to send to the server. opw #2057230 closes odoo/odoo#35890 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>