Commit Graph
1970 Commits
Author SHA1 Message Date
Julien Mougenot 669c2ebaec [IMP] web: improve eval context dates
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-14 09:10:32 +00:00
Aaron Bohy af85bb5e13 [IMP] web,*: do not deploy services in tests
*mail,point_of_sale,web_editor,website

In the tests, required services are deployed for each test
independently. There is no need to have, in additon, all services
deployed globally. Worse, it could conflict and lead to unexpected
results.

This commit ensures services are no longer deployed globally in
tests. It turns the module 'web.env' into a declarative module with
no side-effect, by moving the service deployment to main.js, which
isn't added to the tests page.

Task 2287397

closes odoo/odoo#53817

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2020-07-13 12:55:07 +00:00
Xavier Morel 350ed97c45 [FIX] web: async operations should not live in init
Support for the "allow exports" group was implemented by checking the
group in init(), which is sync. Move that check over to willStart
instead.

Also add a default mock for user_has_group (makes it so it always
replies that the user doesn't have the group), and override that
specifically for the group we're interested in in the export tests, so
those tests have access to the Export action / option.

closes odoo/odoo#54254

X-original-commit: 30968ac93373990338c23f49e678d272b8e60c6b
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-07-09 07:23:04 +00:00
Joseph Caburnay 259cf45346 [FIX] web: trying to create record based on name_create w/o _rec_name
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-07-09 12:43:36 +00:00
Aaron Bohy 9d99e75453 [FIX] web: list: don't squeeze button columns
Adjacent buttons are not displayed in a single column. When the
table overflows, we try to squeeze largest columns to make it fit
into its container (in this case, text may be clipped and an
ellipsis is displayed). Button columns didn't get away from this.

As a consequence, now that a cell may contain several buttons,
some of them may be clipped and replaced by the ellipsis, which
isn't what we want for buttons.

This commit removes the button columns from the list of columns
to squeeze, so we let the browser reduce them as much as it can,
and we keep them as they are.

Task 2282470

closes odoo/odoo#54258

X-original-commit: e00960daa3ed3d1fd3a7572b2acedd3d2fb0448e
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-07-09 08:54:28 +00:00
Aaron Bohy e55ee0bb1b [FIX] web: kanban: drag column with sample data
Before this commit, in a grouped kanban view with sample data (e.g.
crm.lead), one could toggle the 'settings' dropdown menu of a
group, and then drag&drop the group by clicking on the muted "Fold"
item in the dropdown.

After this commit, dragging a column is only possible by clicking
on the column title (but not on the 'config' or '+' icons, nor the
config dropdown).

Task 2290197

closes odoo/odoo#54179

X-original-commit: 58c38a024c96eba3469c142a8422b7bd0ab54ea4
Signed-off-by: Mathieu Duckerts-Antoine <Polymorphe57@users.noreply.github.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-07-07 10:14:54 +00:00
Julien Mougenot cd1d339763 [FIX] web: Make sample server tests deterministic
Before this commit, there were a few tests in the "sample server" suite
that asserted that every group resulting of a "read_group" would contain
at least one record, while there was actually a slight chance of it not
happening.

Now, the sample server used in the tests has been rendered deterministic
and these kind of issues are completely avoided.

closes odoo/odoo#54164

X-original-commit: a6d32ff46558b68ce3f19458f29c311ee5c658fd
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
2020-07-07 08:33:28 +00:00
Hardik Prajapati 8e91b0ad3b [FIX] web: properly display boolean fields in kanban
Before this commit, boolean fields (without widget="boolean") in
kanban views were displayed as [Object object], because when no
widget is specified, we display the (textual) formatted value of
the field. However, the boolean formatter returns by default a
string encoding an html checkbox.

This commit passes the correct option to force a string formatting,
so it now displays "True" or "False". Moreover, this commit
uniformizes formatter options for that purpose, as another option
had been recently introduced for monetary field.

Note that those options should not be necessary, as formatters
should always return text values (no html). But this is a larger
change, that we might do in the future.

Task 2280394

closes odoo/odoo#53937

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-07-07 09:17:37 +00:00
Xavier ALT 2479da0176 [FIX] web: do no try to render filters referencing access restricted fields
In case a field is limited to specific groups on the model, those fields
are discarded from `fields_view_get()` but can still be referenced by some
filters on the search view causing a traceback (see #53797)

Model:

```python

class MyModel(models.Model):

  my_field = fields.Char(groups='base.group_system')
```

Search views:

```xml
<search string="My Model">
    <filter name="group_myfield" context="{'group_by': 'my_field'}"/>
</search>
```

This commit ensure those filter are correctly discarded.

OPW-2284621

closes odoo/odoo#54112

X-original-commit: b3452a1863c36290b13e16161e2703d9a3737f0e
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-07-06 09:40:09 +00:00
Aaron Bohy 2e6ec66022 [FIX] web: editable list: correctly edit in readonly
Some widgets allow the edition in readonly (e.g. boolean_toggle,
priority...). In this case, the changed value is saved directly.
Before this commit, this didn't work in (main) list views: the
widget was updated with the new value, but it wasn't saved in db,
so the change was lost at reload.

This was due to the list controller not being correctly aware of
its mode ('edit' or 'readonly'), on which the basic controller
relies to determine whether a change must be saved directly or
not.

With this commit, a list is always in 'readonly', except when a
row is being edited, in which case it is in 'edit'.

Issue reported on task 2288963

closes odoo/odoo#54075

X-original-commit: 64e55cb42163643386740fbd23d710f64033b2ae
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-07-03 16:41:56 +00:00
Julien Mougenot ff6263dd3f [FIX] web: Support widgets in search view
Since the refactor of the control panel, support of "widgets" attributes
in the search view archs has been inadvertently dropped.

Now, they are once again supported.

Task 2061795

closes odoo/odoo#54066

X-original-commit: f33b0bc7a93e60bd0ed00b40d7459225ec0b749a
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
2020-07-03 15:48:42 +00:00
Mathieu Duckerts-Antoine c997700181 [FIX] web: correctly reload categories
In the search panel, the categories, i.e. fields select="one",
with attributes expand="0", and enable_counters="0" (defaults) were not
correctly updated when the domain outside of the search panel was
updated. This is no longer the case.

closes odoo/odoo#54040

X-original-commit: 99e9cac63f5034c1ba2154779fe82170dd656236
Related: odoo/enterprise#11642
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-07-03 10:27:40 +00:00
Mathieu Duckerts-Antoine 9aa3297b9d [FIX] web: reload search panel before view model
Problem:

Go to the application apps, select accounting in the search panel,
then filter on lunch in the search bar: the category all is displayed
as selected in the search panel (accounting is no more a valid value
since expand="0") but the application lunch does not appear in the
kanban view.

Root cause:

The kanban model is reloaded with the old domain using accounting
without waiting the search panel to be reloaded but it is only known
after the search panel has been reloaded that the accounting value is no
more valid and that all should be selected instead of accounting, thus
that the domain used by the kanban model should be updated.

Solution:

The solution to the problem is simple: first reload the search panel,
then reload the view model with the updated domain.

X-original-commit: 8589babcd0f2c15433fe1eb06d0d745e80d01c22
2020-07-03 10:27:39 +00:00
Aaron Bohy e17dc1a793 [IMP] web: form: labels of several occurrences of a field
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-07-02 13:57:37 +00:00
Benjamin Vrayandqsm-odoo 58179cebf1 [IMP] web, *: replace the bootstrap backdrop element with a bg on modals
*: web_editor

Do not display the backdrop element added by bootstrap in the body and
add a background on the modal to keep the same effect. The bootstrap
backdrop was probably useful for compatibility with <IE9 but is no
longer needed. This also avoids z-index issues because modals could be
opened in an element (e.g. the website #wrapwrap) whose stacking context
is different of the body one (where the backdrop is opened). This would
make the backdrop appears on top of the modal.

Part of https://github.com/odoo/odoo/pull/49142
Related to task-2229551

Co-authored-by: qsm-odoo <qsm@odoo.com>
2020-06-30 14:19:17 +00:00
qsm-odoo 4341a4d795 [IMP] web: better test modal backdrop behaviors
Part of https://github.com/odoo/odoo/pull/49142
task-2229551
2020-06-30 14:19:17 +00:00
Mathieu Duckerts-Antoine 141aaa2db1 [FIX] web: renderers with a pie chart can reload
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-30 09:12:11 +00:00
Julien Mougenot c96de07f85 [FIX] web: Allow default favorite filter over search default
Before this commit, when a search_default on a many2one field tried to
update its label after a name_get, the value was set on its initial
associated query element which could have been erased by a default
favorite.

Now, the model determines whether there is a default favorite before
processing default filters, preventing any unnecessary RPC.

closes odoo/odoo#53840

X-original-commit: ff834d0ba6f9b7eadc23c28dbbf892eba2058583
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-06-30 07:22:12 +00:00
Hardik PrajapatiandMohammed Shekha c3080e54ed [FIX] web: update action on archive/unarchive
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-29 18:51:47 +00:00
Julien Mougenot a5aa6f7e51 [FIX] web: qunit detects remaining body elements
After changing the organisation of the test bundles, some elements seem
to have disappeared from most of the tests, leaving free space for other
undesirable elements to remain on the DOM after tests unnoticed.

Now, any element not allowed in the body or qunit fixture will be
properly detected and removed.

X-original-commit: 65da01e5b96ff77d25e4421d654585bc08e09d75
2020-06-26 01:28:13 +00:00
Mohammed Shekha 01a8260622 [FIX] web: drag and drop onchange fail should reload kanban
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-25 15:46:46 +00:00
Xavier ALT 19033e804e [FIX] web: in search view, use modifiers to determine if filter is invisible
In search view, the "invisible" attribute can use complex expression,
and so we must rely on the "modifiers" attribute set by the ir.ui.view
post-processing to determine if a  filter should be invisible or not.

For example, considering the context {'hide_myfilter': False}, the
following view:

```xml
<search>
   ...
   <filter name="myfilter" string="My Filter" invisible="context.get('hide_myfilter')"/>
   ...
</search>
```

Will be returned as such by the server:

```xml
<search>
   ...
   <filter name="myfilter" string="My Filter" invisible="context.get('hide_myfilter')"
       modifiers="{&quot;invisible&quot;: false}"/>
   ...
</search>
```

After this commit, the filter "myfilter" will correctly be shown.

OPW-2243639

closes odoo/odoo#53690

X-original-commit: 00969326e24dadd9b3f6e026789a1e575dd1c8dc
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
Signed-off-by: Xavier ALT <xavieralt@users.noreply.github.com>
2020-06-25 15:01:29 +00:00
Priyanka KakadiyaandMohammed Shekha 3da19d2e74 [IMP] web: display comparison period first in pivot
When comparing time ranges in pivot, it makes more sense to display the
previous period before the one being compared. This commit allows that.

Task ID: 2269770

closes odoo/odoo#52746

Signed-off-by: Mathieu Duckerts-Antoine <Polymorphe57@users.noreply.github.com>
Co-authored-by: Priyanka Kakadiya <pka@odoo.com>
Co-authored-by: Mohammed Shekha <msh@odoo.com>
2020-06-25 08:23:32 +00:00
Nicolas Lempereur e961a2fe09 [FIX] web: action before field willStart end
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-24 15:48:27 +00:00
Aaron Bohy 61a3a4d52d [FIX] web: list: buttons with attrs column_invisible
Since commit 042b4060bd, attrs 'column_invisible' on button was
ignored. This commit makes this work alongside the adjacent button
grouping feature: if all adjacent buttons have their attrs
column_invisible evaluated to true, no column is rendered for this
group of adjacent buttons.

closes odoo/odoo#53489

X-original-commit: 3110e34ab8e5ec3bf7160655af21f72b4d2179db
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-06-23 09:03:34 +00:00
Julien Mougenot 6998452065 [IMP] web: disable keyboard navigation with sample data
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 13:04:01 +00:00
c7964657ec [IMP] web: add support of "sample" attribute in views
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-22 13:04:01 +00:00
Julien Mougenot 96fcefb6f1 [IMP] web: qunit: remove tooltips after each test
Leftover tooltips may make following tests fail, which isn't what
we want as a test shouldn't impact another one.

X-original-commit: 17a4c72b9a86186c7690bdba5e62ccd64ab2f77a
2020-06-22 13:04:01 +00:00
Julien Mougenot a6cd6d5a89 [IMP] web: utils: add groupBy function
This commit introduces a new utility function: 'groupBy'. It is
similar in API and result as the underscore method of the same
name.

X-original-commit: 834a1967161dc537cb2d5543314a062dbac08f9c
2020-06-22 13:04:00 +00:00
Victor FeyensandAaron Bohy 7f21258d39 [FIX] web: kanban: format monetary w/o widget
Before this commit, monetary fields occurring in kanban views
without widget="monetary" specified weren't correctly formatted:
the whitespace separating the value from the currency symbol was
formatted has $nbsp; (html) instead of a simple whitespace.

closes odoo/odoo#52521

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
2020-06-22 09:07:21 +00:00
Parth ChoksiandMohammed Shekha e6730c6e92 [IMP] web: better positionning of daterangepicker
Before this commit, the daterangepicker always opened below the input,
even when there was not enough space to display it. Moreover, when the
user scrolled while the picker was opened, it wasn't stucked to the
input, so the picker was displayed at a random position after the
scroll.

With this commit, we compute the available space above the picker
when opening it, and if there is enough space, we display it above,
otherwise, we display it below. Moreover, we automatically close
the picker when the user scrolls.

task-2117229

closes odoo/odoo#42161

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Mohammed Shekha <msh@odoo.com>
2020-02-27 07:51:43 +00:00
Laurent Stukkens (LTU) c27228d95e [FIX] web: place the notification close button to the right end
Prior to this commit the close button of the notification is wrongly
placed when no title is provided.

Applying this commit places the close button at the right end. This commit also
modifies the size of the buttons to btn-sm.

task-2277737
Fixes #52229

closes odoo/odoo#53219

X-original-commit: caa3f1107ddaa4cdf6878f4532632a41bc710862
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-06-18 09:35:41 +00:00
3fea5b2136 [REF] mail, *: refactor messaging with OWL
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-15 18:12:21 +00:00
4197ebfabc [IMP] web: add options to formatFloatTime
This commit adds noLeadingZeroHour option to formatFloatTime.
The noLeadingZeroHour option can be used to format the value
like 1:30 instead of 01:30

This format behaviour is wanted for fields in web_grid module.

Task 2261853

closes odoo/odoo#52217

Related: odoo/enterprise#10870
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Hardik Prajapati <hap@odoo.com>
Co-authored-by: Mohammed Shekha <msh@openerp.com>
2020-06-15 13:53:21 +00:00
Mathieu Duckerts-Antoine 7002bdb239 [FIX] web: always use filter_domain for search panel counters
The counters for categories were not updated when filter values were
selected. This commit fixes that situation.
This might impact the global performances of the search panel but
there is still room for improvement. Actually, it could be
possible to reload categories and filters less often by carefully
track the internal changes and the categories/filters attributes
(enable counters, expand,...).

closes odoo/odoo#49307

Related: odoo/enterprise#9795
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-06-12 13:34:04 +00:00
Mathieu Duckerts-AntoineandJulien Mougenot 46306b95d8 [IMP] web: expand domain != count domain
In the search panel, the domain used to compute the field image values
(when the attribute expand is false) was the same as the domain used
to compute counters (if enabled). The idea was that a value bringing an
empty domain is totally useless and should not displayed.
That being true, it turns out that if one does not allow them and
several fields are used, selecting a value in the search panel will very
often totally transform the search panel. From a UI perspective,
this turns out to be bad: the search panel 'moves'.
Let us give an example:
Let us start from a search panel that looks like to:

first_field
    A  1
    B  3
second_field
    C  1
    D  2 <--- mouse above D
    E  1

with first_field and second_field both with expand="0" and
enable_counters="1". Let us also assume that no record in the global
domain has both first_field=A and second_field=D.
Click on D would make the search panel look like to something like

first_field
    B  1
second_field
    C  1
    D  2
    E  1 <--- mouse here

(the selection of D does not impact the values for the second_field but
does for the other first_field values).

This has led us to use basically only the domain comming from
outside of the search panel to compute field image values.

This means that we might now have value with zero count even if expand
is false. In the above situation, a click on D would give us

first_field
    A
    B  1
second_field
    C  1
    D  2 <--- mouse still above D
    E  1

Task ID: 2154749

Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: Julien Mougenot <jum@odoo.com>
2020-06-12 13:34:04 +00:00
Mathieu Duckerts-Antoine 3306a0f414 [IMP] *: limit in search panel
This commit introduces a new attribute 'limit' for search panel fields
that allows to avoid performance issues. That integer attribute (with
default 200) allows to fix a maximal number of values to display for the
fields. When the number of field values to display reaches the limit,
no values will be displayed. Instead, a warning message will be shown
in the corresponding search panel section.
Note it is possible to have no limit using limit="0" on a field.
This commit reintroduces in a better way the principle brought by the
fix 8d57153b34c04952a85f6642951cb2697016da84.

Task ID: 2154749
2020-06-12 13:34:04 +00:00
Mathieu Duckerts-AntoineandJulien Mougenot e5585c078e [IMP] *: expand and hierarchize in search panel
The commit introduces two new attributes for search panel fields:

    - hierarchize: boolean attribute (default True) available for
      many2one fields with select="one". It allows to choose whether
      to hierarchize the field values using the _parent_name (if set)
      on the field comodel.
      Note that a sanitization of the parent hierarchy takes place.
      Basically, it ensures that parent chains are
      completely in the domain (on comodel) accessible by the user.
      See _search_panel_sanitized_parent_hierarchy documentation for
      more information.

    - expand: boolean attribute (default False) available for many2one
      and many2many fields. If set to true, all field values are fetched
      and displayed in the search panel. If set to false, only the
      values that have at least one corresponding value in the field
      model (and in some domain) are fetched.
      An exception in the case of an hierarchized field
      (hierarchize=True and _parent_name set): more/less values can be
      displayed in order to have a good representation of the parent
      hierarchy. That means we complete and sanitize the set of initial
      field image values.

Note that the fix 8d57153b34c04952a85f6642951cb2697016da84 bringing the
notion of limit in search panel has been reverted in the present commit.
An upcomming commit will reintroduce the limit principle in a better way.

Task ID: 2154749

Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: Julien Mougenot <jum@odoo.com>
2020-06-12 13:34:04 +00:00
Julien Mougenot f5f0ca843d [IMP] *: enable_counters with false as default
In the search panel, the attribute disable_counters with default False
has been changed to enable_counters with default False.
2020-06-12 13:34:04 +00:00
Aaron Bohy b4ba0fc340 [FIX] *: adapt tests to env rework
This commit adapts tests following recent changes on the helpers.
The main change is that addMockEnvironment (and all functions using
it) are now async, as they need to wait for services to be started.
2020-06-12 09:47:48 +00:00
Aaron Bohy dc260c3241 [IMP] web: tests: rework mock helpers
This commit reworks the test helpers, following recent changes on
services deployed in the Owl env.
2020-06-12 09:47:48 +00:00
Julien Mougenot c4786fccfd [IMP] *: update notifications to optional title
closes odoo/odoo#52826

Related: odoo/enterprise#11084
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-06-12 09:01:50 +00:00
Julien Mougenot d093fd4236 [IMP] web: close button on non-sticky notifications 2020-06-12 09:01:50 +00:00
Lucas Lefèvre 997d21a67e [IMP] web: Allow to use a custom control panel
The abilty to use a custom control panel for an action
seems to have been lost with 18e5416.

With this commit the action config can specify a custom
component to use as control panel.

Usefull for o-spreadsheet integration.

Task 2238915

closes odoo/odoo#52807

Signed-off-by: Vincent Schippefilt (vsc) <vsc@odoo.com>
2020-06-11 07:41:02 +00:00
Pierre Rousseau b906ba08b9 [IMP] web: allow to add buttons to pivot controller
This is useful for the integration of pivot views with spreadsheet

Task-ID: 2168016
2020-06-11 05:35:53 +00:00
eacbec1e03 [IMP] web,*: highlight quick create feature to user
Generally, Users are not necessarily aware that they can quick create a most
records by simply typing in their name+enter in the many2xxx field input.
The exact purpose of this commit is to make sure the user discovers the quick
create feature of our many2xxx fields.

For that, when the input is empty, display 'Start typing to create a record...'
at the bottom of the dropdown when can_create is set and no_create_edit option
not set. So the user can easily understand that by typing and pressing enter
will create the new record.
Also "Search and Create" options in the dropdown only been shown to the user
when it type anything in the input box as the same case in the "Create" option.

Task : 2266557

Co-authored-by: Mohammed Shekha <msh@openerp.com>
Co-authored-by: Julien Mougenot <jum@odoo.com>
2020-06-10 13:08:33 +00:00
Julien Mougenot a392da1601 [IMP] web: add 'Create and edit' test helper
Accessing the "Create and edit" option can be bothersome when testing:
- you must click on the m2o dropdown to open it
- input a value
- click on the "Create and edit" m2o item

Now, a helper exists to compile all these tasks into a single helper:
the many2one 'createAndEdit' function.

Usage:
`await testUtils.fields.many2one.createAndEdit('m2o_field', "ABC");`
2020-06-10 13:08:33 +00:00
Julien Mougenot a425c58d99 [IMP] web: mock server: enhance default get
Before this commit, the mock server "_mockDefaultGet" method was a bit
naive:
- it accepted any 'default_' field coming from the 'kwargs.context'
  regardless of the existence of the field
- it accepted any value for these fields

Now the method is looks a bit more like its original server-side
counterpart:
- the context keys are added if they correspond to actual fields
- a pseudo validation removes many2one fields values not corresponding
  to any record
2020-06-10 13:08:33 +00:00
Hardik Prajapati e1e9e8c780 [IMP] web: replace property field icon with tooltip
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-06-10 12:25:42 +00:00
Mathieu Duckerts-Antoine a758f8f307 [FIX] web: don't forget initial registry entries
The entries comming from the optional parameter 'mapping' passed at the
instantiation of a registry were never considered when returning the
registry keys or entries. This is no longer the case.

closes odoo/odoo#52768

X-original-commit: e094ddd0ffaf3357e64ca5941ffc2e0454c24ab7
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2020-06-10 11:57:54 +00:00