summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic
AgeCommit message (Collapse)Author
2020-10-14[FIX] web: fetching reference fields' name_get batched in grouped listLucas Perais (lpe)
Commit e10fd34682a0c55568cba66eb271b3aa5bed7c1d introduced batched reference fields name_gets across groups but was also buggy as follows: Have a grouped list view showing at least 2 groups Have a reference field with different values showed in the list for each record Before this commit, the name_get of those reference fiels were fetched only for the last group After this commit, the name_get are fetched in a batched fashion (by model) for each group and display correctly closes odoo/odoo#59903 X-original-commit: bbb608a1eff638040f0fc7b951fedf1579cc15b2 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2020-10-02[FIX] web: reference field calls name_createSimon Genin (ges)
An older commit (50bf8309) had refactor part of the basic field _applyX2ManyOperations. During this refactor, the reference field was forgotten to be included in a condition that made the field no longer do the quick create behavior. The name_create function in the backend was no longer called. Adds a test for the reference field checking the call to the name_create function and fixes the problem. Task id 2322048 closes odoo/odoo#59013 X-original-commit: e7d4baa3d52dc73c9631365801fbe41a4d54e3a1 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-09-15[FIX] web: list: call mounted on subcomponents at reloadAaron Bohy
Issue was spotted in list views containing the "badge" widget with decorations (e.g. in the Purchase Order list view). At first, the decorations were correctly applied, but they weren't anymore after a reload (e.g. after toggling a filter). They weren't because the list renderer didn't called 'on_attach_callback' on its subwidgets at reload (thus, 'mounted' wasn't called on its subcomponents, and the decorations are applied in the mounted hook). This commit moves the logic from the FormRenderer to the BasicRenderer, so that it applies on List, Kanban, and Form views. This commit also removes the transition scss rule on the badge field widget as it caused a flickering at reload. Task 2336440 closes odoo/odoo#57762 X-original-commit: 713bce22e8f412f2c26e663b9e30fdd64933ff0c Signed-off-by: Michaël Mattiello <mcm-odoo@users.noreply.github.com> Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-09-11[FIX] web: blank value in many2many_tags for multi_edit popupMohammed Shekha
Let's assume a list that is multi editable and contains a m2m field displayed with widget many2many_tags. Moreover, there are enough values in the comodel s.t. the 'Search More' option is available in the many2many_tags dropdown, and field 'display_name' isn't in the list view that opens in dialog. Enter multi-edition, edit the many2one field to add a value (click on 'Search More', and pick a value from the list): the picked value isn't correctly displayed in the confirmation dialog. The issue occurred because we didn't wait for the display_name to be fetched before opening the dialog. Task : 2150384 closes odoo/odoo#57481 X-original-commit: ccf5834045d8b4fff9af7ddf60814c3a640e8318 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Co-authored-by: Dhruv Patel <dhp@odoo.com>
2020-09-09[FIX] web: no more double discard dialogDhruv Patel
This issue only occurred in community. Steps to produce: 1) Create/Edit any record. 2) Change the menu using menu switcher 3) You will get the discard dialog at the instance and after some time it will also display another duplicate discard dialog. So, we have one extra redundant discard dialog on menu switching. It is working fine when we have dirty form and then click on the breadcrumb or click on any internal child menu. Task : 2312437 closes odoo/odoo#57343 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com> Co-authored-by: Mohammed Shekha <msh@odoo.com> Co-authored-by: Aaron Bohy <aab@odoo.com>
2020-09-04[FIX] web: avoid displaying noContentHelper after kanban quick_createLucas Perais (lpe)
Have a kanban with a filter Quick create a record in one column that won't match the domain Before this commit, the noContent helper was displayed. This was because the count of the group was reset to zero after the web_read_group call. After this commit, the noContent helper is not displayed. Note that in the quick_create situation, the records are not re-fetched i.e. there is no search_read after the read_group. Task-id 2251734 closes odoo/odoo#57066 Signed-off-by: Aaron Bohy (aab) <aab@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-14[IMP] web: support action helper on gantt viewDhruv Patel
Currently, only List and Kanban view supports the action helper and display the folder icon with the helper text. With this commit we have also provided the action helper support for other views. The logic for no content helper has been moved in abstract_renderer.js so that it can be accessed by all views. This was done mainly to give the action helper to the gantt view. closes odoo/odoo#53902 Task: 2284779 Related: odoo/enterprise#11563 Signed-off-by: Mathieu Duckerts-Antoine <Polymorphe57@users.noreply.github.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: Mohammed Shekha <msh@odoo.com>
2020-07-29[IMP] web, base: action buttons in list's controlPanelLucas Perais (lpe)
This commit introduces a new semantics to define action and method buttons in the list view. The aim of this feature is to be able to do some actions on selected records, or on the entire records' domain with the help of buttons located in the controlPanel, much like the form view header buttons. To define such buttons, one must add a `header` node in the list view's xml definition ``` <tree> <header> <button type="action|object" name="actionId|methodName" string="button's text" context="{}"/> </header> <field name="fieldName" /> </tree> ``` task-2246383
2020-07-14[IMP] web: improve eval context datesJulien Mougenot
This commit handles 2 things: 1) the merging of the `py_utils.context()` into the evaluation context returned by `BasicModel._getEvalContext` to access the same time-related keys, 2) the addition of 2 new keys into the `py_utils.context` (thus transmitted to the basic model): `today` (an alias for the already present `current_date`) and `now` which represents the current date and time value. Task 2269697
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-30[FIX] web: renderers with a pie chart can reloadMathieu Duckerts-Antoine
The on_attach_callback methods on the widgets (comming from a tag 'widget') of a form renderer were not called at an appropriate time. They were not called at all or called before the widgets were actually in the dom. This was made manifest in the dashboards that generally use pie charts widgets. Each time a pie chart widget is renderered, a new canvas with a unique id is created. The above mentioned problem explains why Chart.js was not able to acquire the canvas contexts: they are obtained by looking for a specific id in the dom. The present commit fixes that problem by doing in the class FormRenderer what was already done correctly in the child class DashboardRenderer and remove the unapropriate calls to on_attach_callback in _renderWidget. Task ID: 2278717 closes odoo/odoo#53853 X-original-commit: 7641c7074616b4375f1eb4f1fcb5a96e2ed39f94 Related: odoo/enterprise#11537 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-06-25[FIX] web: drag and drop onchange fail should reload kanbanMohammed Shekha
Currently, when kanban card drag and drop, it call onchange method when onchange fails due to python error raised, e.g. UserError, kanban view is not reloaded and kanban card stays in dropped column while kanban card should come back to column from where it is dragged i.e. kanban view should reload if onchange fails. After this commit, if onchange trigerred from kanban drag and drop fails then kanban view will get reloaded and card will come back to column from where it is dragged. note: in not stable version, forceFail option will not be added and promise will fail in all cases but it is not done in stable for safety. task-2267444 closes odoo/odoo#53695 X-original-commit: 27257d34c8b7374bfd8037de71f175f4ecb2913e Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-06-24[FIX] web: action before field willStart endNicolas Lempereur
On a re-render, when: - a field is not yet started (still in willStart because of RPC) - then an action is executed we can get a traceback because we try to save the field before it is started and `this.el` is not set. eg. in MRP on a work order: - click on + to get new serial number => page is re-rendered with RPC call to update duration to mrp.workcenter.productivity().search_read to update time counter - click on "Record production" before RPC is finished => traceback because we try to save `duration` that is not already started (`this.$el.toggleClass` when `this.$el` is `undefined`) Without change, added test fails with: "Cannot read property 'toggleClass' of undefined" in BasicRenderer.canBeSaved "Expected 6 assertions, but 5 were run" Before saas-11.3 5faec34a3c this.el was always set in `init` so this issue did not happen. opw-2272117 closes #53532 closes odoo/odoo#53612 X-original-commit: befcad51fd236fdaf284f76cea5624d21c070b0e Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-06-22[IMP] web: disable keyboard navigation with sample dataJulien Mougenot
Previous commit introduces the sample data feature in list and kanban views. When sample data is displayed, most parts of the renderers can't be clicked on, to prevent the user from interacting with sample records (e.g. to open a sample record in form view from the list). This commit disables keyboard navigation as well, as those sample records could still be accessed with the keyboard. To do so, several refactorings have been done in views: - _giveFocus function added on controllers (so that we can hook on the moment where we want to focus the renderer, and prevent it in sample mode), it kind of replaces giveFocus of ActionMixin which wasn't use from the outside - updateRendererState -> _updateRendererState as it is private - _setState function added on controllers, to have a hook when we set a new state (already existed, but only in kanban) - _renderView function moved from Basic to AbstractRenderer, so that we have a proper hook to deactivate clickable elements in sample mode Task 2232801 X-original-commit: 4482a03fe2f083f4f44fc6eb76d90ae22afbff91
2020-06-22[IMP] web: add support of "sample" attribute in viewsJérémy Hennecart
With this commit, it is now possible to display sample (fake) data in empty views, in the hope of easing user onboarding. This can be enabled (in list and kanban views) with attribute sample="1" on the arch root element. In this case, if there is no data to display, sample data will be generated based on heuristics (depending on field types and names). This can be used in addition to the no content helper. Task 2232801 X-original-commit: 7c8e627ff5029cb539d702705e5ce53d658c76ed Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: Jérémy Hennecart <jeh@odoo.com> Co-authored-by: Julien Mougenot <jum@odoo.com>
2020-06-15[REF] mail, *: refactor messaging with OWLSébastien Theys
This commit is a significant rewriting of client-side discuss, chatter, chat window, and messaging menu using OWL. The behavior should be broadly the same, with some slight functional changes here and there. From a technical standpoint, the code of messaging is mainly organized in 2 main groups of modules: - models, which are logical entities that depict the client-side state of messaging as a whole. - components, which are in charge of displaying information from models. This refactoring also introduces new JS guidelines regarding folder structure (/static) and naming rules for JS modules. Community PR: https://github.com/odoo/odoo/pull/39023 Enterprise PR: https://github.com/odoo/enterprise/pull/6249 Task-1914207 This PR is a collaborative work by Alexandre, Julien, Sébastien and Xavier, with the precious help of Lucas to speed it up towards the end. closes odoo/odoo#39023 Related: odoo/enterprise#6249 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com> Co-authored-by: Alexandre Kühn <aku@odoo.com> Co-authored-by: Julien Giannone <jgi@odoo.com> Co-authored-by: Lucas Perais <lpe@odoo.com> Co-authored-by: Sébastien Theys <seb@odoo.com> Co-authored-by: Xavier Dubuc <xdu@odoo.com>
2020-06-12[IMP] *: update notifications to optional titleJulien Mougenot
closes odoo/odoo#52826 Related: odoo/enterprise#11084 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-06-10[IMP] web: replace property field icon with tooltipHardik Prajapati
PURPOSE The purpose of this task is to improve the interface by removing the fa-building icon which is automatically appended by the property field (i.e. company-dependent) and, instead, indicates that a field has company-specific values in the tooltip of the field. closes odoo/odoo#52313 Taskid: 2266519 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-05-29[REF] web: allow override tooltip optionsRomeo Fragomeli
Before this commit, the options of the tooltip where set inline. After this commit, the options are returned by a function. This allow us to adapt these options in another module. Task ID: 2152124 closes odoo/odoo#52170 Related: odoo/enterprise#10864 Signed-off-by: Adrien Dieudonné (adr) <adr@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[IMP] web: list and kanban: highlight create buttonMohammed Shekha
... when there is no data and user clicks anywhere in the no content helper. Task 2239617 Co-authored-by: Jinal Patel <jip@odoo.com> Co-authored-by: Aaron Bohy <aab@odoo.com>
2020-05-07[FIX] web: Prevent page reload during sale tour testLaurent Stukkens (LTU)
* A step has been added to the sale tour in order to ask the user to update the company data. As a page reload breaks the tour test we need to prevent it in such situation. TaskID :2187222 closes odoo/odoo#46167 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-05-05[REF] web: field decorationAaron Bohy
This commit refactors the way the decoration-xxx attributes are applied to field widgets/components, in a way that it can be overridden in a given field or component to generate the approriate className. By default, 'decoration-x' applies className 'text-x'. This will be necessary for the new 'FieldBadge' component, which needs to apply 'bg-x' classNames instead of 'text-x'. Part of task 2195254
2020-04-24[FIX] web: list: don't call mounted twice on fieldsAaron Bohy
Before this commit, when a list contained owl field components, the mounted hook was called twice on those components. This may cause tricky issues like handlers being bound twice, and memory leaks. closes odoo/odoo#50127 X-original-commit: 206dd91e78f7896fc6b01020507657e61771787f Signed-off-by: Julien Mougenot (jum) <jum@odoo.com> Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-04-17[FIX] web: fix nested o2m edition tracebackStéphane Debauche
There's a traceback when we edit an activity on a campaign * Create a child activity * Save the activity (not the campaign) * Edit again the activity * -> Traceback Introduced in a9cebd5 Task ID 2220930 closes odoo/odoo#49698 X-original-commit: efa8952c39b0bcb0969013dc22e05b5d61ff1c66 Related: odoo/enterprise#9964 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
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-31[REF] web,*: add new field registry for componentsMichael Mattiello (mcm)
* account This commit adds a new field registry for component fields. This field registry is used to only register the new field components and the other one should register the legacy fields. Those two registries will be used together while all legacy fields are not converted to owl component. As the legacy registry now throws an error when adding a component field the existing component fields (account.ShowGroupedList and account.ShowResequenceRenderer) are moved into the new registry. This commit also refactors some field managers (form renderer, list editable renderer, calendar popover) to use the new registry and thus support the component fields. task id: 2193996
2020-03-30[IMP] web: adapt delete feature to list selection changesAaron Bohy
Following the new selection feature in list views, this commit adapts the delete action. Part of task 2185145
2020-03-30[IMP] web: adapt (un)archive feature to list selection changesAaron Bohy
Following the new selection feature in list views, this commit adapts the archive and unarchive actions. Part of task 2185145
2020-03-30[REF] web: move _archive function to BasicControllerAaron Bohy
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-19[FIX] web: editable list: activate correct fieldAaron Bohy
We have an editable list with 4 fields: - fieldA (say boolean) - fieldB with readonly modifier, readonly iff fieldA is true - fieldC with readonly modifier, readonly iff fieldA is false - fieldD Add a new row to the list: fieldA being false by default, fieldC is readonly whereas fieldB isn't. Change the value of fieldA: fieldB becomes readonly, and fieldC is now editable. From that point, before this commit, clicking on fieldC activated fieldD (instead of fieldC). The bug occurred since 3fd7b20, which added a delay between the moment fields are re-rendered (and inserted at the end of allFieldWidgets) and the moment there previous instances are destroyed (and the new ones take their place in the list). So when several fields were re-rendered at the same time, the order in allFieldWidgets could not match the actual column order anymore, and cause issues like the one described above. Part of task 2210323 closes odoo/odoo#48039 X-original-commit: 89b9717c08e148ad94db17d8746faa2312b6a07a Signed-off-by: Michaël Mattiello <mcm-odoo@users.noreply.github.com> Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-03-13[REF] web: Adapt views/actions to new control panelJulien Mougenot
Some web actions/controllers/viewsl have been adapted to properly instantiate the newly refactored control panel and update it accordingly. We needed to adapt the starting mechanism of actions and controllers to ensure that the control panel instantiation did not delay the loading of any widget. Part of task 2196029 Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2020-03-12[FIX] web: prioritize record context instead of bin_sizejvm-odoo
This commit allows to pass a bin_size context to False. Before this commit it wasn't possible because it was always overriden. OPW-2208232 closes odoo/odoo#47491 X-original-commit: 17d53cea1043054dfa9c39b16b430539c4082a9d Signed-off-by: Nicolas Martinelli (nim) <nim@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-09[FIX] web: fix edition of a reference fieldDebauche Stéphane
How to reproduce ================ You must have - a form view with a one2many list - in this one2many list add a column of a reference field How to reproduce 1. open the record associated to the reference field 2. edit this record in the form modal view 3. click on save -> Traceback Bug === In `basic_model` the attribute `localData` become inconsistent because of the method `_fetchReferenceData`. We want to store the ID of the parent and not the all dict. closes odoo/odoo#47171 X-original-commit: af411b866aa2052c01168342f8f05ae3dabad83e Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
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>
2020-02-03[IMP] web: Reload after company creationYannick Tivisse
Purpose ======= At the second res.company creation, the multicompany mode is 'enabled'. But to get the company selector dropdown, the user needs to reload the page. Specification ============= Force a reload at res.company creation, similarly to the forced reload when updating the language (lang) of the user. closes odoo/odoo#44386 Taskid: 2127257 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-02-03[ADD] web: add owl AbstractFieldMichael Mattiello (mcm)
This commit adds the new AbstractField class written in owl, meant to be extended by specific Field owl implementations. Note that its API is not complete yet, but it is enough for basic usecases. This commit also adapts the BasicRenderer to instantiate the future new fields that will be written in owl. closes odoo/odoo#43759 Related: odoo/enterprise#7872 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-01-27[IMP] web: always display statusbar widgetMohammed Shekha
By default, in readonly, unset field widgets (and their labels) are not displayed. However, we would like the statusbar widget to be always displayed (even when it is not set). This commit introduces a new method 'isEmpty' on AbstractField, and uses it (instead of isSet) to determine whether or not a field should be hidden. By default, it uses isSet, so that it doesn't change anything for the other fields, and we override it in statusbar to always return false. There was a need to make the distinction with isSet, as this one is used to determine if a record can be saved (if the field is required, and isSet returns false, it can't be). task-2172272 closes odoo/odoo#43419 Related: odoo/enterprise#7929 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Co-authored-by: Aaron Bohy <aab@odoo.com>
2020-01-21[FIX] web: fix studio child view datapoint contentJason Van Malder
Issue - Install Employees & Studio - Configuration > Check Skills Management - Go on an employee form - Remove all data in Experience, Education & Skills - Open Studio - Click in the blank space before Skills - Edit Form View Traceback Cause The ORM tries to get the parent fields because the generated datapoint includes them. (45bc7c9) Normally the parent model is the same than the child model but not in studio. Solution Merging the fields in the datapoint only if the models are the same. OPW-2125214 closes odoo/odoo#43695 X-original-commit: d2dbc4faaad0988d71f591be7f50c94d455541b0 Related: odoo/enterprise#7849 Signed-off-by: Xavier Morel (xmo) <xmo@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.
2020-01-13[FIX] web: widget noreset if rerendered for modifierNicolas Lempereur
If we have a many2many_tags widget that is writable then becomes readonly, we can have in the code this chain of event: - get list of widgets we need to reset some data for - apply modifiers - reset the widgets but applying modifiers can delete a widget (eg. an editable field that becomes readonly), so when resetting we could call code on a deleted widget which caused an error. For example, if we have an attribute: `<field widget="many2many_tags" attrs="{'readonly': 'condition'}"/>` if the field goes from editable to readonly and is affected by an onchange, we will call `setIDForLabel` on the deleted instance of the widget which will cause an error. Added test without fix fails with error: TypeError: Cannot read property 'attr' of undefined at Class.setIDForLabel (/web/static/src/js/fields/abstract_field.js:324:35) because as said, the function is called on the editable widget that is removed and replaced with readonly widget at that point. opw-2154471 closes #43137 closes odoo/odoo#43244 X-original-commit: 6f5ca16524be7c5bb45b03e7421154a20edc4cf6 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-01-08[FIX] web: fix question error message translationJason Van Malder
Issue - Take a v13 runbot - Open survey's app - Open one of the surveys - Click on edit - Click on a question - Open 'option tab' - Make sur the field 'mandatory answer' is true - Try to translate field 'error message' -> Error Cause this occur because because we try to update the model survey.question from the list coming from survey.survey which mean that the record.viewType is list and not form. Solution As we are looking for the field name we can simply use ev.data.fieldName. Another solution should be to use this.viewType instead of the record one. OPW-2157631 closes odoo/odoo#42952 X-original-commit: ad115d2710aec2b4ff7d4077714a1816cdfb433e Signed-off-by: Jason Van Malder <jvm-odoo@users.noreply.github.com>
2020-01-03[FIX] web: calendar: allow to use fields.ReferenceLaurent Mignon (ACSONE)
Before this change, fields.Reference displayed into the popover of a calendar view was always empty. This was because the popover view generated from a double click on an element in the calendar view creates its own recordModel in JS and the function to create this record did not handle the reference field case. This commit detects if a reference field is defined into the record and adds the necessary processing to process its value and creates the corresponding dataPoint. opw 2151635 Closes #41262 closes odoo/odoo#42707 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com> Co-authored-by: Aaron Bohy <aab@odoo.com>
2019-12-20[IMP] base, web: support `x_active` for archivingDamien Bouvy
While x_name has long been automatically supported as an equivalent of name, x_active was not. This commit adds this behaviour OoB, both in the ORM and the web client. On the ORM-side, a new `_active_name` attribute is supported on models. This attribute specifies the field that should behave as an active marker for records of the model. It is supported the same way `active` has been until now (filtering by the `active_test` context key and toggled by the `action_archive`, `action_unarchive` and `toggle_active` methods). Although no check has been added on the field's type, it is assumed to be a boolean field (the same way no check is present on the `(x_)name` field). On the client-side, the list view and form view now both support detecting the presence of either `active` or `x_active` on records, automatically adding an '(Un)Archive' button in the Action menu if such a field is detected. Note that the ORM implementation does actually need the field to be named in any specific way, but since the web client has no mechanism to load information regarding a model (the lifecycle of an action loading includes loading the action, view and record(s) but no generic information about the model itself besides what is included in the views), we restrict the field's name to `(x_)active` to avoid confusion as any other name would work at the ORM-level but not in the client. In the future, the client might be able to more elegantly get information about models, but this was not the scope of this change and this solution should cover most cases. Note that the `active` field will always takes precedence over the `x_active` field to avoid confusing the polarity, even if both fields are present on the model. In the case of a custom field, it might be slightly annoying that the default value of a Boolean field is `False`, which means that upon adding the column, all existing records are automatically archived. This can easily be worked around using an `ir.default` record for that particular field and an update of existing records (e.g. through the list view). The goal of this change was not to make it easy to add support for custom active fields, but to make it possible - we have therefore kept this implementation which introduces few changes while adding enough flexibility for developers. See https://twitter.com/zubair_shafiq/status/1202587553871880192?s=20 for more info regarding supporting any `_active_name` in the web client. Co-authored-by: Raphael Collet <rco@odoo.com>