summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/form
AgeCommit message (Collapse)Author
2021-05-11[FIX] web: Allow user to add product Description with studioAchraf (abz)
What are the steps to reproduce your issue ? 1. From the product form, go to the website version, edit it to add tabs 2. Using studio, add the field "Description for website" to a tab of the notebook 3. Save, click Edit, go to the tab that has the field What is currently happening ? Traceback: form_renderer.js:258 Uncaught (in promise) TypeError: Cannot read property 'querySelector' of undefined at Class.setLocalState (form_renderer.js:258) at Class.setLocalState (form_editor.js:131) at Class.prototype.<computed> [as setLocalState] (class.js:90) at view_editor_manager.js:184 What are you expecting to happen ? Correctly add product description without tracebacks Why is this happening ? Because the number of tab is not equal to the number of pages How to fix the bug ? Before accessing the element, check if it exists opw-2378743 closes odoo/odoo#70513 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-02-17[FIX] web: correctly close confirm dialogAaron Bohy
Let's assume the following scenario: - have an action in target new (e.g. a form view) - in the dialog, have an action/object button with confirm attribute - when clicking on that button, a confirm dialog opens - if validated, the following action returned by the server is again an action in target new Before this commit, the confirm dialog remained in the DOM. This issue occurred because it's parent wasn't correctly set (wrong use of `this`), so when the first dialog was destroyed, the confirm dialog wasn't automatically destroyed in turn. OPW~2440712 closes odoo/odoo#66345 X-original-commit: 2016fe31af970976775c9df160a31abfbec742ba Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2021-02-17[FIX] web: fix issue of notebook page with invisiblity modifierMohammed Shekha
before this commit: when there is only one page in the notebook tag and there is a boolean field in form to show/hide that notebook page based on invisibility attrs, if we toggle boolean field notebook hides, that's OK but when we toggle boolean field again then notebook page is displayed but it is not active and due to that content of notebook page is not displayed. after this commit: when there is only one page in notebook and it has attrs for invisibilty, when we toggle boolean field to hide/show notebook page then notebook page as well as content is toggled. task-2449053 closes odoo/odoo#66338 X-original-commit: a0b5ecd344d6ac79d8e4d194cfabf3d639259c73 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-02-11[FIX] web,mail: Call on_attach_callback when appending contentJulien Mougenot
Before this commit, the form renderer would call "on_attach_callback" only when the whole _render process was over. The problem was that this process is asynchronous and this callback should be invoked as soon as the widgets are appended. As such, any asynchronous operation is performed before appending the content in a new function "__renderView". Task 2346540 closes odoo/odoo#60791 Signed-off-by: Aaron Bohy (aab) <aab@odoo.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-09-28[FIX] sale_timesheet, web: disable autofocus on create invoce actionKamesh Patel
Before this commit: The date range widget opened by default when the 'create invoices' the wizard is opened. because the default focus is 'Timesheets Period' field. After this commit: Disable autofocus on 'create invoice' action, after this changes The date range widget is not opened by default when the 'create invoices' the wizard is opened. Task-2344289 closes odoo/odoo#58676 Signed-off-by: Yannick Tivisse (yti) <yti@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-03[FIX] web: form: Archive action when field not in viewAaron Bohy
Before this commit, when being in a form view without active field (the field is defined on the model, but not present in the view), the action "Unarchive" was available in the Actions menu, even though the record was actually active. The issue has been introduced by [1]. This commit restores the previous behavior: when the active field isn't in the view, the Archive/Unarchive action isn't available in the Actions menu. [1] 220eb4db391d8ba49dd26bdd3d8af1c27b433d78 closes odoo/odoo#57038 X-original-commit: 97b70aab69b491443d862847fbff69c4e29274af Signed-off-by: Julien Mougenot (jum) <jum@odoo.com> Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-08-20[IMP] web: set focus to first visible page when active page invisibleMohammed Shekha
Before this commit: if there are modifiers based on field which hides one page and show another and if active page get invisible then instead of first page second page gets focus, consider following example, `<form> <field name="boolean"/> <page name="page1" attrs='{"invisible": [["bar", "=", false]]}'></page> <page name="page2" attrs='{"invisible": [["bar", "=", true]]}'></page> <page name="page3"></page> </form>` Consider the initial boolean value to be true; initially the first page will be visible. But when "bar" is unchecked then page1 will be hidden and page3 will get the focus as page2 is still not visible: it will be after the computaion/application of all modifiers, which is currently done after the rendering of a tab page. Now: the first visible tab is focused on rendering (same as before) but also after all modifiers have been updated. closes odoo/odoo#56209 X-original-commit: 10365572aa3629e9b19d2b29726b351275de9f52 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com> Co-authored-by: Ipsita Borisagar <ibo@odoo.com> Co-authored-by: Julien Mougenot <jum@odoo.com>
2020-08-05[FIX] web: form: prevent from calling mounted twiceMichael Mattiello (mcm)
With this commit, the FormRenderer no longer directly extends the WidgetAdapterMixin. It doesn't need to as its parent class (the BasicRenderer) already uses it. Worse, they both called WidgetAdapterMixin.on_attach_callback, and thus mounted was called twice on Components in form views. closes odoo/odoo#55401 X-original-commit: 4c627abd310a131a4828e9ee6be451aeee4708db Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-07-16[IMP] web,barcodes: speed up form view renderingAaron Bohy
Large form views (containing a lot of fields), e.g. the crm.lead form view, take a while to render (~ 250 ms). Most form views contain several (sometimes a lot) invisible fields (invisible="1"), whose only purpose in the view is to be fetched, so that they can be used to evalute domains and contexts. This commit implements a trivial optimization of the form renderer, which consists in skipping the rendering of those invisible fields. With this change, we gain ~25% of rendering time on the crm.lead form view. closes odoo/odoo#54368 Related: odoo/enterprise#11875 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2020-07-22[IMP] web: allow to override statusbar's buttons rendererRomeo Fragomeli
Related PR odoo/enterprise#10602 Task ID: 2225270
2020-07-03[FIX] web: do not suggest translation for empty HTML fieldNicolas Martinelli
- Activate more than one language - Install sale_quotation_builder - Create a new quotation model without website description - Create a SO using this model, Save The 'Please update translations of' is displayed for the website desctiption, although it is empty: when clicking on the link, no record is shown. This happens because an empty HTML field always contains at least `<p><br></p>`. We do not consider the latter string for translation. opw-2274203 closes odoo/odoo#54025 X-original-commit: aad4d516b6fb4b286f24bc536e5ecb67558a0c4d Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-07-02[IMP] web: form: labels of several occurrences of a fieldAaron Bohy
Before this commit, when the same field occurred multiple times in a form view, all occurrences were associated with the same id, and all occurrences of the corresponding label (if any) had the same 'for' attribute. As a consequence, besides the fact that there were warnings in the chrome console, clicking on any occurrence of the duplicated label focuses the first occurrence of the field. This commit generates a unique id for each pair label/field, when possible. However, there is a case that can't be handled automatically: when the label isn't automatically generated (field located outside a group, or with nolabel attribute set to "1"). Typically, in this case, there is a <label> node with "for" attribute referencing the associated field. In this situation, the id must be defined in the arch, and used in the "for" attribute: <form> <label for="phone"/><field name="phone"/> <label for="phone_2"/><field name="phone" id="phone_2"/> </form> Task 2261697
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-29[FIX] web: update action on archive/unarchiveHardik Prajapati
Before this commit, when archiving a record through the action menu, the 'Archive' link was not updated to 'Unarchive' and same when unarchive was clicked, the link was not updated to 'Archive'. After this commit, when archiving a record through the action menu, the 'Archive' link is updated to 'Unarchive', same way when unarchiving a record link is updated to 'Archive'. This commit also introduces a new prop 'closeOnSelected' to the Dropdown component, to specify whether the dropdown should be closed when an item is selected, and makes Action Menu dropdown closed on item selected. task-2251739 closes odoo/odoo#53835 X-original-commit: dc5d02ade7747c74c31566c74932ef45c30e9356 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Co-authored-by: Mohammed Shekha <msh@odoo.com>
2020-06-25[FIX] web: formRenderer: apply class on form el for device sizeLucas Perais (lpe)
Before this commit, the size of the form view was handled by a media query It made testing impossible in certain case when the size determined the behavior of the form view (the chatter) After this commit, a class is put on the form view to better be able to test task-2238141 PR #53136 X-original-commit: d42610297b46f4a1624df1907a9cce91de29fafa
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-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-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-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-04-22[FIX] web: handle empty notebooks in form viewsJulien Mougenot
Before this commit, when re-activating a previously active notebook tab, the form renderer would assume that a tab was actually active. However this does not happen if no tab is visible or defined and it results in a crash instead. Now, if no active tab is found, a default active tab (0 = first) is set. This only helps to prevent the crash and does not affect the current behaviour. closes odoo/odoo#50006 X-original-commit: 73e0c0a1395ebd0e2b4ac7f857c863a0358c5e17 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
2020-04-16[FIX] web: export/import form state with pure JSJulien Mougenot
Before this commit, restoring the previously active tab on a form view was done through programatically clicking on the tab and letting Bootstrap handle the switch itself. This caused some cases of race condition since the click handler is asynchronous. Now, classes are applied manually and should not cause any concurrency issue. closes odoo/odoo#49668 X-original-commit: 214b842cba030f451430ff0d8c3fc1868be515e9 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
2020-04-14[FIX] web,mail: many2many_tags_email: increase limitDhruv Patel
A long time ago, commit [1] increased the limit of displayed badges inside a many2many_tags widget, from 40 to 1000 (a large limit that should never been reached with such a widget). However, this solution was specific to the many2many_tags widget, and didn't apply to its extensions (like the many2many_tags_email widget). For instance, open the chatter full composer, add 40 partners in the recipients field and try to add one more: nothing happens. This commit sets the limit on the widget itself. That way, extensions automatically have the same limit, and can override it if needed. [1] d4cf4374d1baa529bb651bb3cc32e9db140963a8 Task : 2091027 closes odoo/odoo#49488 X-original-commit: 02e41f1131b4ea3ad977cc241a3d447c37195f6e Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-04-03[FIX] web: form: hide labels of oe_(read|edit)_only fieldsAaron Bohy
In a form view, nodes with classname "oe_read_only" (resp. "oe_edit_only") are only visible in readonly (resp. edit) mode. Moreover, fields inside a group automatically have an associated label. Before this commit, when one of these classnames was set on a field node inside a group, the effect wasn't applied on its label, so the label was always visible, even if the field was hidden. Bug reported in PR odoo/odoo#48699 closes odoo/odoo#48968 X-original-commit: 705f434f0f18a0e4d2fdb0f86d3e350d190b2a30 Signed-off-by: Julien Mougenot (jum) <jum@odoo.com> 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 (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-23[IMP] web: Show company icon on property(company dependent) fieldNisha patel
Purpose Of the task is, we need a visual cue on those fields to let the user know that their value is company-specific. So, in this commit On company depedent field we added a building icon with title 'Values set here are company-specific' next to the label in the form view. closes odoo/odoo#47178 Taskid: 2001748 Closes: #47178 Signed-off-by: Yannick Tivisse (yti) <yti@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-02-07[FIX] web: attach the trad alert to the formJulien Castiaux
The translation alert dialog was attached to the entire view in case no status bar was found. This resulted in the following layout on large screens: chrome -------------------------------------- | alert dialog | form view | chatter | | | | | -------------------------------------- Whereas when a status bar was set on the form view, the rendering was as follow: chrome -------------------------------------- | status bar | chatter | | alert dialog | | | form view | | -------------------------------------- The fix make sure the alert dialog is always placed just above the form view just like when there is a status bar. closes odoo/odoo#44878 Task: 2075172 X-original-commit: dacdc30681510e9c2db23610c5be5285a72a8949 Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.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-23[FIX] web: notebook tab headers containerPierre Paridans
This commit adds a wrapper element around the form view's notebook tabs headers to allow the use of `overflow` and make it scrollable (e.g. on smaller screens) without breaking the tabs' styling (e.g. the bottom border). This commit fixes an issue introduced by odoo/enterprise@e07aafbe6fee9e568274c0e157645925dc1f6878. closes odoo/odoo#43843 X-original-commit: 967777793cf2a7591ef3d9325497b105eb86577c Related: odoo/enterprise#7906 Signed-off-by: Pierre Paridans <pparidans@users.noreply.github.com>
2020-01-03[FIX] web: form: fix broken layout with o_td_labelAaron Bohy
Rev. bc131c0cfb51 aimed to handle the case of several (conditional and exclusive) <label> tags for a same field. The idea was to wrap those <label> tags into a div with className 'o_td_label' (typically set by the framework), and let the framework move it to the td wrapping the div. However, it causes an css issue (only in community), as the presence of two o_td_label classnames (one on the td, and one on the div), produces two right borders. This commit fixes the issue by removing the classname on the div (we simply 'transfer' it to the td). Closes #42589 closes odoo/odoo#42667 X-original-commit: f71979a681d95d98db19a80feb59fdf684ec361f Signed-off-by: Aaron Bohy (aab) <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>
2019-10-31[IMP] web: allow custom state in action mixinDamien Bouvy
Sometimes, it might be useful for an action (e.g. a client action, although this may be used by standard views as well) to include custom values in its state. Since the state of a 'fullscreen' action is pushed in the URL, this means that it is possible for the action to resume its state properly upon refresh of the page (before this commit, only some standard information were pushed to the state - action_id, menu_id, etc. for window actions and action's name, active_id, active_ids for client actions). By implementing the `getState` method, an extension of the action mixin can thus push any state it wishes to the URL. closes odoo/odoo#39529 Signed-off-by: Damien Bouvy (dbo) <dbo@odoo.com>
2019-12-09[FIX] web,*: fix all tests and test utils to use native eventsVincent Schippefilt
In this commit: - transformed test_utils helpers to always trigger native events - introduced new test_utils_create helper: prepareTarget - updated qunit asserts to support Owl Components - updated all misused helpers that would crash with the updated test_utils Co-authored-by: Julien Mougenot <jum@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: Pierre Rousseau <pro@odoo.com>
2019-11-04[FIX] web,sale_product_matrix: allow to open matrixAaron Bohy
Before this rev, it crashed when opening the (sale or purchase) product matrix (e.g. on runbot, go to quotations, create, add a line, select 'My Company tshirt'). This was due to a recent override of _applyChanges (see 4bf98b47), which didn't return the value returned by super. OPW 2116083 closes odoo/odoo#39747 X-original-commit: 49626acbacb87a6f5d37bea22d0b51a506121914 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2019-10-31[FIX] web: fix form view "More" buttonfw-bot
In form views, when the window size is too small, a "More" button appears and it should contain the overflow buttons. On all browsers, the "More" dropdown doesn't contain the expected amount of buttons, so it is shifted on the second line. Before this commit: - The "More" dropdown doesn't contain the expected amount of buttons, so it is shifted on the second line. After this commit: - The "More" dropdown contains the expected amount of buttons and it is not shifted on the second line anymore. OPW-2079694 X-original-commit: 2bda8230fba07a229fcda77a1528694a0e317917
2019-10-24[FIX] web: list: recompute default values for columns when visibleJulien Mougenot
Before this commit, all the computation of the default widths for column headers was done before the list was attached to the DOM, meaning that no column was actually visible. This was a problem since columns that are meant to stay unseen were taken into account in the calculation of relative column widths. Now, the same algorithm runs once the columns are visible so that invisible columns can be properly excluded. fixes #38744 Task 2076721 X-original-commit: 4bf98b47898b075049975dfe597f0fb92c7c14d1
2019-09-13[MERGE] forward port branch saas-12.4 up to fe59754c520Christophe Simonis
closes odoo/odoo#36721 Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-10[FIX] web: Display archive action if active in viewLucas Lefèvre
Since ee5e972, "Achive" and "Unarchive" actions are automatically displayed in the actions dropdown if the record has an `active` field. The "Archive" action is shown if `active=True`, and "Unarchive" otherwise. However, if the record has the `active` field but it's not in the view, the form controller think `active=False` because `undefined` is falsy. Therefore, the "Unarchive" action is always shown. If `active` is not in the view, neither "Archive" nor "Unarchive" should be shown. closes odoo/odoo#36551 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-09-09[IMP] web: edit translations in new dialogVincent Schippefilt
Before this commit, translations were edited in a list view with a filter on the field that needed to be translated. After this commit, the translations for each fields are translated in a dedicated dialog. The changes done to the current language are taken into account immediately, both ways, from the dialog to the form and from the form to the dialog. Translating terms is also available in create mode, the user will be prompted to save before editing a translation Task ID: 2028152 closes odoo/odoo#36185 Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
2019-09-05[IMP] web: formview auto close dialogjem-odoo
Sometimes when using a form view in a modal (e.i.: in a gantt view), we might want to have some button in the footer. We expect clicking on buttons to close the dialog but nothing happens, since the webclient does not know that this is a modal. To do so, we provide the `close='1'` attribute on the button, in form view. This will trigger the event closing the modal. This is done with the benediction of aab-odoo Task-2024216 closes odoo/odoo#36493 Signed-off-by: Jérome Maes (jem) <jem@openerp.com>
2019-09-11[MERGE] forward port branch saas-12.3 up to 50e571acf7cChristophe Simonis
closes odoo/odoo#36491 Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-04[MERGE] forward port branch 12.0 up to 638eac9baeaChristophe Simonis
2019-09-04[FIX] web: form: race condition when editing in readonlyAaron Bohy
... and switching to 'edit' mode before the write RPC returns. For instance, on a project task form view, in readonly, change the state by clicking on the bullet, and directly switch to 'edit' mode: when the RPC returns, the view is switched back in readonly. Task 2065443 closes odoo/odoo#36400 Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
2019-08-30[MERGE] forward port branch 12.0 up to 52f6e38cea8Christophe Simonis
2019-08-27[FIX] web: 'create' in context and non inline subviewsAaron Bohy
Let's assume an action with 'create': 0 in the context, and a non inline subview in the form view. Before this rev., the 'create': 0 was applied to both the form view and the subview. This rev. applies the same logic as what the server does for inline subviews: the rule is applied to the subview iff its model is the same as the one of the form view (with key 'base_model_name' set in the context). Task 2035653 closes odoo/odoo#36109 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2019-09-02[FIX] web: remove unused swipe code in FormViewPierre Paridans
Remove code left behind after commit odoo/odoo@9f7e6bb798155 closes odoo/odoo#36333 Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>