Commit Graph
1787 Commits
Author SHA1 Message Date
Mathieu Duckerts-AntoineandJason Van Malder 95f40530f3 [FIX] web: fix date filters
Issue

    If month - 1 or month - 2 are in the previous year, the filter is
    incorrect.

    ex: Date = Jan. 2020, Filter = Dec. 2019
        => last_year__last_month = 2018-12 instead 2019-12

Cause

    If date is 2020-01-20

    Selecting December => adding param "last_month"
    Selecting 2019 => adding param "last_year"

    Applying "last_month" => date become 2019-12-01
    Applying "last_year" => date become 2018-12-01

Solution

    Detect the right year to activate by default
    when a month is selected and no year is selected.
    With that solution it is not possible to get records in Jan. 2020
    or in Dec. 2019 only for instance but the global functioning
    of date filters stays the same as before.

OPW-2169528

closes odoo/odoo#44208

X-original-commit: 096fdc7d3fe0799aa761c6ad3597569a002c698e
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Co-authored-by: Jason Van Malder <jvm@odoo.com>
2020-02-03 13:57:17 +00:00
Lucas Perais (lpe) 6bdcf054fd [IMP] web: custom_hooks: dynamic inheritable event handling
This commit's intention is to bring class inheritance of event handlers
to components.
Use case:
A component class may want to set generic event handlers for all classes
inheriting from it, in order to set shared event behavior from the start
It is the case in many parts of Odoo, in particular in the cases of fields
which need at least to react on some keyboard event for navigation

The way to implement such a behavior is to make use of the
`useListener` OWL hook, by passing as arguments
event name and the handler function
2020-02-03 09:15:02 +00:00
Alexandre Kühn 7a691c8eb0 [FIX] web: update search view menu on click IME suggestion menu
Before this commit, when typing something in the search view in
Japanese, and then clicking on a suggestion from the IME dropdown
menu, the search view menu did not update with selection.

Steps to reproduce:

- Enable Japanese IME in hiragana mode;
- Type "test" in search view;
- Soft-select another suggestion item, e.g. "テスト";
- Double-click on suggestion item "test";

=> The search view menu still detects "テスト".

As a result, clicking on any of these search view suggested filters
picks "テスト" instead of "test".

This commit fixes the issue by updating search menu when clicking
in a suggestion in the IME menu.

opw-2061590

closes odoo/odoo#44318

X-original-commit: 0bca4c0883f2b58842da6a8c1a4e26bf2444d5f3
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2020-01-30 14:11:06 +00:00
Dhruv Patel d5d2c5524c [FIX] base,web: url widget: add protocol in href
With this commit, the url widget automatically prefixes the href
url by http:// if no protocol is specified, so that clicking on
the url will by default redirect to an external website.

To prevent this behavior, one can still specify the new option
'website_path: true' on the url field node in the view arch.

Thanks to this, we can remove a similar logic (only implemented on
res_partner model) which automatically altered the value saved in
database to force its 'http://' prefix.

task-2153184

closes odoo/odoo#42118

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-01-30 14:03:36 +00:00
Xavier Morel c4e075cf04 [IMP] core, web: test failure reporting
* remove misleading documentation about a "test failed" message, in
  13.0 any uncaught exception or console.error will cause the current
  test to be interpreted as failed
* fix tour manager to console.error its step and not add a second
  useless error message
* fix menu tester to try and display the failure cause on failure
* improve qunit's test reporter to print the number of tests failed in
  case of test suite failure

Should make test failures in tours a bit clearer.

closes odoo/odoo#44296

X-original-commit: 78121b68d099b16f2d775a7a8a963a2a0f474843
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-01-30 12:33:05 +00:00
Aaron Bohy b5d6080366 [IMP] web: sidebar actions: send 'select_all' info
In a list view, select some records (either by selecting them one
by one, or by clicking on the header to select all records), then
click on an action (except for the special case of 'Export') in the
sidebar. Some information about the selection is put into the
context:
 - active_ids: the ids of the selected records (only those of the
   current page)
 - active_domain: the current domain

However, before this commit, there were no way to determine whether
the user checked the header checkbox (i.e. all records), or some of
them individually.

This commit adds the information, with a 'select_all' key in the
context.

Note that this is a quick solution, as we need it right now for an
accounting usecase. A more elaborate solution, which will allow the
user to choose whether he wants to apply the action on the selected
ids or on the whole domain, will be developped soon.

Part of Task 2146469

closes odoo/odoo#44248

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2020-01-30 10:29:25 +00:00
Ankita Raval 0052222b54 [REF] web: calendar: allow disabling the delete button
In this commit, we add a new attribute "Delete" for user conveniency
if he don't want 'Delete' button on popover card they easily achive
by "delete=false" attribute and also add a testcase for it.

task-id:2088954
2020-01-29 09:57:23 +00:00
Julien Mougenot 5f6571a6fe [FIX] web,mail: only apply modal activity for Dialog modals
Before this commit, the CSS rule handling the "activity" of the modals
(their z-index compared to the one of their backdrop) was global and would
interfere with front-end or custom modals which do not use the static Dialog
methods giving them the "active" class.

Now, the rule has been inverted: the z-index of a modal is only changed when
it is given an "inactive" class, thus only impacting the modals instantiated
via Dialog or Owl Dialog classes.

closes odoo/odoo#44067

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-01-28 11:35:14 +00:00
Debauche Stéphane 75f7ab0608 [FIX] web: fix email and phone widgets with empty value
When the value is empty in a related field, string of the element was
displaying "false" instead of an empty string which is not what we expect.
This commit fixes that issue.

Task ID 2119333
PR #40949
2020-01-28 09:14:43 +00:00
Mohammed Shekha e5aa3109f5 [IMP] web: show measure row in xlsx file
before this commit: if only one measure is enabled then measure row not
displayed in downloaded xlsx file

after this commit: downloaded xlsx file will always have measure row
either single measure enabled or multiple measure enabled

task-2127388

closes odoo/odoo#40769

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-01-28 09:00:35 +00:00
Mohammed Shekha c40c11761d [IMP] web: change pivot download file from xls to xlsx
before this commit: file was downloaded in xls format, which supports
maximum 256 columns and 65536 rows.

after this commit: pivot returns xlsx file when table printed and
downloaded, we have support of xlsxwriter, xlsx file supports 16384
columns and 1048576 rows

task-2127388
2020-01-28 09:00:29 +00:00
mcm-odoo 5aa0822a9d [REF] mail: migrate activity renderer to owl
In order to prepare the future, we want to convert everything in Owl.
This commit converts the activity renderer.

closes odoo/odoo#42278

Task: 2149408
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-01-28 07:42:56 +00:00
jbm-odoo 00b2046460 [IMP] calendar: Adapt views and test for new color and filters
closes odoo/odoo#41573

Taskid: 2153249
Related: odoo/enterprise#7157
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-01-27 16:08:34 +00:00
jbm-odoo fa48e05f42 [IMP] calendar: Improve color and filters
Now in a calendar view, if we use the color, attribute, it will use
the same color as Gantt views and the color picker widget.

The attribute color isn't more set as default in filter because it make,
in most situation, no sense to filter by color.

Now, we can add new filters in the right panel. To do that, we must
add the attribute "filter='1'" in the corresponding field line.
And if the filter has no direct link with the color of the model,
we can specify an attribute 'color' for this filter line block.
(for example color='color', and the color of the related model
will be used)

TaskID: 2153249
2020-01-27 16:08:34 +00:00
Lucas Perais (lpe) d41d627569 [IMP] web: field phone widget deals with SMS by default
Task 2123526

Before this task, the phone widget on char fields was not
displaying the send sms button by default

After this task, the default behavior of the phone
widget is to display the send sms button
2020-01-27 09:31:52 +00:00
Aaron Bohy f2de55322e [FIX] web: ComponentAdapter: do not override render
In Owl, 'render' is a (async) function of Component. It should not
be overriden in Component specifications, especially to do
something else (in this case, rendering the sub widget), without
calling super.

closes odoo/odoo#43980

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2020-01-27 08:58:36 +00:00
Mohammed ShekhaandAaron Bohy 23878ee11a [IMP] web: always display statusbar widget
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-27 09:01:19 +00:00
Priyanka KakadiyaandMohammed Shekha 8e48ba3eb5 [IMP] web: show start time of regular event in calendar
With this commit, the start time of single day events is displayed
in the calendar view, in month mode. This only applies to non allday
events. This can be disabled by setting (already existing) option
'hide_time' to true on the calendar arch.

task-2058477

Co-authored-by: Mohammed Shekha <msh@odoo.com>
2020-01-24 12:38:47 +00:00
Aaron Bohy b980086d27 [FIX] web: MockServer: search_read: handle sort on many2one
Before this commit, if the records had to be sorted according a
many2one field, and there was a sequence field on the many2one
comodel, the sequence was ignored. Now, the sequence is taken into
account like the actual server does.

Linked to odoo/enterprise/pull/7407

closes odoo/odoo#43763

X-original-commit: 714e52f98eec5c64a224523cee4b1e14463ed191
Related: odoo/enterprise#7869
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-01-22 13:29:16 +00:00
jerome hanke (jhk) 513aab315c [FIX] web: typo in _mockSearchRead
https://github.com/odoo/enterprise/pull/7407#discussion_r362451701

opw-2128922

X-original-commit: cdfa00ecfdc988cb29b0d1f901db466b890940b1
2020-01-22 13:29:16 +00:00
370f53d8dc [IMP] web: conditional create/delete options on x2many fields
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-22 13:01:33 +00:00
Aaron Bohy 7ab364b627 [IMP] web: properly throw errors in MockServer
Otherwise, they could be catched (by a guardedCatch) and thus would
not make the test fail.
2020-01-21 11:59:22 +00:00
Aaron Bohy 50bf8309f8 [FIX] web,*: fix race condition with m2o quick create
*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-21 11:59:22 +00:00
mcm-odoo 01e3a5996f [REF] web: pivot: use owl_compatibility tools
This commit changes ControllerAdapter to a mixin that inherits
WidgetAdapterMixin and RendererWrapper now extends ComponentWrapper.

This commit also changes PivotController base class/mixin and uses
the Odoo legacy custom_events because of the adapter.

closes odoo/odoo#43256

Related: odoo/enterprise#7744
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2020-01-21 10:22:50 +00:00
mcm-odoo 083ba2a811 [IMP] web: WidgetAdapterMixin: add some tests 2020-01-21 10:22:50 +00:00
Aaron Bohy ed0b5c2638 [IMP] web: add a few WidgetAdapterMixin tests 2020-01-21 10:22:50 +00:00
Aaron Bohy 671a5471cd [IMP] web: Owl compatibility: add ComponentAdapter
This commit adds the ComponentAdapter, an Owl component meant to
be used as universal adapter for Owl components that embed Odoo
legacy widgets.

This component will be a precious tool during the transition phase
of converting our JS codebase from the legacy (widget) framework to
Owl.
2020-01-21 07:17:31 +00:00
51b36c3dbb [IMP] base: add default image for users + placeholder if unassigned
1/ When the new database is created without demo data, the admin has a
   'silhouette' as a default picture. When a new user is created without
   picture given by the current user, the new user will have a 'silhouette'
   as a default profile picture.

2/ web: image for fa-user-slash. This image will be used when a record is
   unassigned.

3/ web, *: Change placeholder by default when record is unassigned.
   We want to have a fa-user-slash icon when a record is unassigned instead
   of 'placeholder.png'. A method is created in the BaseModel to have a
   generic method to change easily the placeholder for other models.

4/ Adapt kanban test to keep the same behaviour. Attention the behaviour is
   a bit different. Because, now the default image is given by the server to
   change easily the default image when a record doesn't have an image.
   Thus, we don't say if it's the default placeholder, but we can say it's
   not the same image of the record (in this test, the record, it's the
   partner).

5/ misc: display 'Unassigned' in the hover on kanban cards if record is unassigned

closes odoo/odoo#41356

Taskid: 2060206
Related: odoo/enterprise#7758
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Co-authored-by: jdoutreloux <jud@odoo.com>
Co-authored-by: Yannick Tivisse <yti@odoo.com>
2020-01-21 09:22:46 +00:00
Nicolas Lempereur b048a6fc27 [FIX] web: widget noreset if rerendered for modifier
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-13 17:59:30 +00:00
Julien Mougenot dc716ea42b [ADD] web: add getCookie in test_env
Allow components to access a default empty function when calling getCookie.

closes odoo/odoo#43125

Related: odoo/enterprise#7643
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-01-15 11:31:17 +00:00
Julien Mougenot c146af8a6d [REF] web: home menu template event names to kebab
Changed the event names to comply to Owl standards.
2020-01-15 11:31:17 +00:00
Pierre Rousseau 1900abf233 [FIX] web: correctly manage attach-detach callback
d06e67e748 introduces tools to use owl renderer
for a view. However, on_attach_callback and on_detach_callback were not
called on super (AbstractController), so not applied to the controlPanel
and searchPanel.
This commit fixes this issue

Task-ID 2171436

closes odoo/odoo#43165

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-01-14 10:26:31 +00:00
Pierre Rousseau a44d7722bc [FIX] web: correctly destroy owl renderer
d06e67e748 introduces tools to use owl
renderer in a view. However, this owl renderer is never destroyed.
This commit fixes this issue.

Task-ID 2171436
2020-01-14 08:38:24 +00:00
Romain Estievenart a077985123 [MOV] web: move "kanban view" mobile related code
This code is not useful since https://github.com/odoo/odoo/commit/9831ed08fe
Note that this part of code will be refactored in web_enterprise.

Task ID: 2085899
2020-01-13 13:25:01 +00:00
Julien Mougenot 1d58b76032 [FIX] web: correctly handle display/hide of dialogs
Before this commit: all dialogs would go through the static method (OwlDialog.hide)
when destroyed, regardless of wether they had been opened or not.

Now, only dialogs having an 'el' property set (= having been opened) will use
the 'hide' method.

Task 2170705

closes odoo/odoo#43124

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2020-01-10 12:48:41 +00:00
Alexandre Kühn b58c649d72 [FIX] web:tests: remove promise constructor antipattern
Revision on https://github.com/odoo/odoo/commit/141b34f152f36d970d4ff78abe53f563555a8e69

Having async/await as a new promise constructor is an antipattern.

The reason is that it may lead to unnoticed errors: if an inner
promise is rejected, it won't propagate the error to another promise
that will handle the error. As a result, this error becomes unnoticed
and the initial promise is pending indefinitely, which also may lead
to more bugs [1].

[1] https://stackoverflow.com/a/25569299

Closes #43072
2020-01-13 10:13:10 +00:00
Andrea Grazioso (agr-odoo) bbe944c829 [FIX] web: avoid parsing value if already number
When accessing stock_barcode module to validate pickings, is not
possible to add floating point quantities for any localizaton which uses
',' as decimal separator.
The numeric field is now defined via browser tags <input="numeric"> to
make the numeric keyboard popup automatically on mobile devices
(commit 8f5840369b28962ab2be9edfce7331a836c3df22)
Adding the override to avoid further processing when the input
is already anumber

opw-2154657

closes odoo/odoo#42748

X-original-commit: 1ccc60deeb067f8d461d48cbf51719317c22cb90
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-01-06 12:16:10 +00:00
Julien Mougenot 3c5194a00b [ADD] web: Custom File Input
New component: the custom file input. Its purpose is to define a input of type file
with a custom trigger (button, link, etc.).

Its construction is the following:
- attributes: behaviour of the actual input (route to call, multifile, allowed
    extensions etc.)
- inner template: the trigger that will fire the upload prompt when clicked
Once a file has been uploaded, the component will emit a 'uploaded' custom event
containing the files.

closes odoo/odoo#38423

Related: odoo/enterprise#6031
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2020-01-06 14:37:16 +00:00
Julien Mougenot 34bbdd88c0 [ADD] web: Owl Dialog
New Owl component: Dialog. It does not rely on Bootstrap but behaves the same
and does not conflict with legacy dialogs.
To call this component, you need to define it in the XML parent template instead
of calling it in the JS file, and put a flag in the parent state to toggle the dialog.
Old dialog file has also been slightly updated to ensure compatibility between both
versions.

This commit also updates a list view test which did not wait for click events to
properly trigger and would cause the new dialog system to crash.
2020-01-06 14:37:16 +00:00
Julien Mougenot 3cf49e1913 [IMP] Owl: update to 1.0.0-beta5
Update of the Owl library.
Also added "_lt" to the default test environment properties.
2020-01-06 14:37:16 +00:00
Carlos MayoandAaron Bohy 9f49709ef3 [FIX] web: many2many_checkboxes: react to domain changes
Let's assume a many2many_checkboxes widget in a form view with a
dynamic domain (depending on another field in the view). At first
rendering, the widget contains a checkbox for each value matching
the domain.

Before this rev., if the user changed the value of the field used
in the domain, the many2many_checkboxes wasn't redrawn, so it still
displayed the values matching the previous version of the domain.

Closes #38509
Closes #40173

closes odoo/odoo#42867

X-original-commit: 1ace56f9a8cb56fb39235468dd13447bcbbee40a
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
2020-01-07 14:37:06 +00:00
Julien Mougenot 2e861cc8ee [FIX] web: boolean widgets in list views
Before this commit, pointer events were prevented on all checkboxes in readonly
list views. That meant that the boolean_toggle widget for instance could not be
properly toggled in a non-editable list (which was the purpose of such a widget).

Now, pointer events are enabled only if the checkbox :
- is in a selected row AND does not have a readonly modifier
    OR
- has a widget applied on the field.

Also ensured that the field widgets in the list view multi edition confirmation
modal are not interactive.

We cannot test the `pointer-events` property interactions as it does not affect
manual event triggering used in tests.

Task 2154055

closes odoo/odoo#42848

X-original-commit: c7ee164d572e01fcb565001fd5e62fe1278b5cd8
Signed-off-by: Julien Mougenot (JUM) <Arcasias@users.noreply.github.com>
2020-01-07 12:49:33 +00:00
Arnaud Joset c411bdfe4d [FIX] web: human readability of negative numbers.
Before this commit, negative numbers are never rendered as human readable (e.g. 34000 -> 34k).

closes odoo/odoo#42789

Taskid: 2160790
X-original-commit: b51877c4c4c9d8cd873dd0205954fd807d62ee01
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-01-06 15:46:28 +00:00
Tiffany Chang (tic) 3e37ec8844 [IMP] web: add 'create' attribute to calendar view
Previously it was always possible to create within the calendar view.
For some modules this did not make sense and lead to confusing behavior,
for example: a new model instance created in the calendar view that was
not viewable in the calendar view, but was viewable in other views. By
adding a 'create' attribute (to be used in view xml), we allow users to
choose whether or not they want a calendar view to be able to create.

Note that this change does not affect the edit ability of calendar views
for existing instances.

Part of
Task: 2126530
2020-01-03 10:34:54 +00:00
Laurent Mignon (ACSONE)andAaron Bohy ae7f574e54 [FIX] web: calendar: allow to use fields.Reference
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>
2020-01-03 15:46:17 +00:00
Damien BouvyandRaphael Collet 220eb4db39 [IMP] base, web: support x_active for archiving
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-12-20 11:16:01 +00:00
Alexandre Kühn 141b34f152 [FIX] web: tests: nextTick awaits render with requestAnimationFrame
Revision on [1].

Commit above made changes to test helper `nextTick()`, so that it
waits for `window.nextAnimationFrame()` (shorten, 'rAF'). This was
useful to wait for OWL rendering, since OWL renders on next animation
frame.

From a theoretical standpoint, the helper should wait at least as
much time as before, as it adds either no slowdown (rAF is readily
available), or a few milliseconds wait (rAF waits for next available
animation frame).

However, some old tests show non-deterministic behaviours, resulting
to crashes [2]. It suggested, for some reasons, that `nextTick()` did
not wait long enough for re-render... Which is surprising considering
explanation above!

Some of these tests have been fixed, assuming it was caused by un-
guaranteed order of successive `setTimeout(0)` [3]. Unfortunately,
this does not explain why it never crashed before the change on
`nextTick()`...

After investigation, we think that this behaviour comes from rAFs
having their own task queue, which no longer guarantees that queued
tasks happen after queued micro-tasks:

When the requested next animation frame is readily available, the
callback of `requestAnimationFrame()` is immediately called and waits
for `setTimeout(0)`. The `setTimeout(0)` await is resolved before any
other queued async micro-tasks, so that `nextTick()` is resolved
sooner than expected. This would explain how `nextTick()` does not
wait long enough for rendering from the loads of resolved Promises,
even though there is a promise resolution after `setTimeout(0)`.

This commit fixes the issue by moving the await `setTimeout(0)`
before the rAF call, so that it correctly waits render from chain of
resolved promises (since the `setTimeout(0)` is awaited in the same
main task queue).

[1] https://github.com/odoo/odoo/commit/b0941d19a07b08fabc64a284b58e57edc46203dd
[2] http://runbot.odoo.com/runbot/build/771505 and http://runbot.odoo.com/runbot/build/752855
[3] https://github.com/odoo/odoo/commit/6cbfdbce2d0f1b567b6a6d6f637fe2a476980acc

closes odoo/odoo#42123

Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
2019-12-20 09:53:26 +00:00
Mathieu Duckerts-Antoine 9d539cd8c5 [FIX] web: take care of "groups" attribute in search view arch
The attribute "groups" on filters and fields in a search view arch was not taken
into account anymore.
Now items that should be invisible are not anymore available for selection
in the interface (as expected) but are still activable as search defaults
(and the corresponding facets appear if needed).

Task ID: 2081450

closes odoo/odoo#42125

X-original-commit: ca2514a9fbcd693752367cb566d5c11165b40bd4
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2019-12-18 13:13:10 +00:00
Julien Mougenot 51483c3e7d [IMP] web/list: multi edition ux
This commit introcudes two changes to the multi edition in list views:
1. Editing one record does not require confirmation through a dialog
2. Successfully saving multiple records unselects all currently checked records

Task 2146429

closes odoo/odoo#41099

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2019-12-16 11:34:33 +00:00
David Monjoie bce6aa351b [IMP] web: rejected click handlers should not close the dialog
Prior to this commit, there was no clean way to have a button
triggering asynchronous work (like asking user for confirmaton
for example) and close or not close the modal according to the
user choice. Your options were:

1. Swallow the pill and just accept that the modal will close
   even if the user chose not to undertake the action.
2. Set the `close` parameter of the button to false and handle
   the conditional closing by yourself from outside the dialog.

This commit introduces a way to tell the form view dialog that
the action has not been processed correctly and that the modal
should not be closed by returning a rejected promise. Prior
behavior can still be obtained (close no matter the result)
by having the handler not returning a promise at all.

closes odoo/odoo#33837

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2019-12-17 07:21:39 +00:00