Commit Graph
1383 Commits
Author SHA1 Message Date
Géry Debongnie abf32b8b21 [REF] *: update js test suite to use helpers
This rev. introduces robust helpers to use in the JS tests suite to
interact with DOM and components, and starts using them (almost)
everywhere.

All the helpers are exposed though testUtils.js.

There are 2 kinds of helpers:

1. Assertions
-------------
 * assert.containsNone, containsN, containsOnce check that the DOM
   (or a specific part of the DOM) contains a `selector`. It
   generates a correct error message automatically.
    ex: assert.strictEqual(form.$('.o_form_editable'), 1, "msg");
        -> assert.containsOnce(form, '.o_form_editable');
 * assert.isVisible, isNotVisible check that the DOM has an element
   visible or not. They also check that the element is actually in
   the DOM (before most tests didn't verify this).
 * assert.hasClass, doesNotHaveClass, hasAttrVAlue, check specific
   properties of a DOM element, and also validate that it is
   applied on a single existing DOM element (before most tests
   didn't verify this).
    ex: assert.notOk(form.$('button').hasClass('btn-primary'));
       -> assert.doesNotHaveClass(form.$('button'), 'btn-primary');

2. Utilities
------------
The goal of the utilities is to centralize the definition of many
standard components and interactions, ensuring that when we
refactor the JS framework, we do not need to change all the tests.

Existing mock utilities (addMockEnvironment, intercept, path,
patchDate, unpatch and fieldsViewGet) are moved to
'testUtils.mock.*'.
Existing DOM utilities are moved to 'testUtils.dom.*'.
New dom utilities are created for opendDatePicker, click,
clickFirst and clickLast. Helper `click` verifies that there is
exactly 1 element visible in the DOM you click on, `clickFirst`
and `clickLast` verify that there are more than one element on the
DOM.
 ex: form.$('button').click();
     -> testUtils.dom.click(form.$('button'));

New Form utilities: (testUtils.form.*)
 clickEdit, clickSave, clickCreate, clickDiscard, all clicks on
 the control panel buttons of the form.
 `reload` reloads the form data.

New modal, graph, kanban and pivot utils (testUtils.pivot.*,
testUtils.kanban.*, etc.).

New fields utils: (testUtils.fields.*)
 * editInput, editSelect: allow to change the value of a field,
   using a selector to identify it. They validate that the input
   exists and trigger the change event automatically.
 * editAndTrigger: allow to modify a field and trigger specific
   events after the value change
 * many2one (testUtils.fields.many2one.*)
   clickOpenDropdown, clickHighlightedItem, clickItem,
   searchAndClickItem: use a field name instead of a selector and
   do all the complex mechanism to open, filter and highlight
   many2one fields.

Joint work with aab, dam, ged, mge, svs and vsc.
2018-11-19 11:24:28 +00:00
Aaron Bohy bcbb7ee3fe [REF] web: properly name relational fields test files 2018-11-19 11:24:28 +00:00
Christophe Simonis 6faad524cf [MERGE] forward port branch 12.0 up to bc744a1da4 2018-11-16 19:30:20 +01:00
Mohammed ShekhaandTejas Shahu f3f20653d3 [FIX] web: update renderer when _callButtonAction failed
Before this rev., the following scenario didn't work:

Open manufacturing order and click on Produce button (note that
bom product should have Serial number enabled) then add quantity
in Done field in o2m and press Record Production button in wizard,
it will produce UserError and after then if you change Lot number
field in wizard's o2m then the many2one value doesn't get selected.

This occured because the renderer wasn't updated after the RPC fail
and thus still got an outdated version of the state.

The issue raised after commit: 02eef78bbd which was done to remove
useless rpc call, it's OK to remove rpc call but let's keep
updating renderer.

Related to task ID: #1852715

Co-authored-by: Tejas Shahu <tsh@odoo.com>
2018-11-15 09:37:22 +01:00
Géry Debongnie c0c326f5ab [FIX] web: restore/remove skipped tests
Some tests were skipped these last months.  This is a slippery slope.
The best time to reactivate them is the moment they were skipped, the
next best time to reactivate them is now.  So, this is what this commit
does.

Three kinds of tests were skipped:
- 3 password tests
- 2 kanban progress bar tests
- one keyboard navigation test

Password tests
--------------
When the auth_password_policy addon was introduced, two tests in web/
were skipped, because they would fail when the auth_password_policy
addon is installed.

Since then, a commit was done to change the way the password field works
(commit 5bbbd25edf).  With this commit,
the password field is no longer an 'include', but a new field widget.
This means that the skipped tests no longer fails.

Kanban progress bar tests:
--------------------------
In saas 11.2, the 'archive all' feature was removed, but it was readded
in saas 11.4.  The tests had to be slightly adapted to make sure they
use the proper css selectors.

Keyboard navigation test:
-------------------------

It is now a functional decision not to allow moving from one cell to the
next by using left/right arrow, so this test is no longer valid.

closes odoo/odoo#28685
2018-11-14 14:44:48 +00:00
Géry Debongnie aa18aaa292 [FIX] web: restore formview mode when coming back (breadcrumbs)
Before this commit, when the user is in a form view (edit mode) and
click on a stat button, a new action is added to the action stack.  When
the user then comes back to the form view by clicking on the breadcrumb,
it is supposed to be in readonly mode.  Before this commit, this was not
the case.

This bug comes from the action manager refactoring, which removed the
view manager. With this commit, we add a new action lifecycle method
which is called when the action is restored.

Note that this commit implicitely changes the semantic of actions with
'target=inline'. As far as I can tell, this only applies to the settings
form view, which can easily be fixed by overriding the restore hook.

closes odoo/odoo#28663
2018-11-14 11:19:40 +00:00
Xavier Morel 58e0c88ece [ADD] web: server-side-rendered qweb templates as views 2019-01-29 10:22:18 +00:00
Xavier Morel 9db74611de [IMP] web: action links from bits & pieces
Before this, the action manager only supported auto-triggering actions
from (model, method) or (action_name).

This adds support for providing all the action details via data
attributes:

* model (defaults to current action's)
* resid (defaults to none)
* views (defaults to list, form, unless resid is specified then
  defaults to just form)
* domain (defaults to [])
* context (defaults to {active_id, active_ids, active_model} from
  current action if the model has not changed, empty otherwise)

The action's name/title is either the link's title (?) or its textual
content.
2019-01-29 10:22:17 +00:00
Christophe Simonis cf52a04979 [MERGE] forward port branch saas-12.1 up to d3b8422c9c
closes odoo/odoo#30614
2019-01-28 13:58:11 +00:00
Pierre Paridans 9f7e6bb798 [IMP] web: Deactivate swipe between form view in mobile
The swipe between the form view is taking too long to load, and the pager is a
more clean option to switch between form view.
Moreover, the swipe on tabs is not clear anymore.

- Deactivate swipe between form view
- Swipe should only be available on tabs when tabs are too long to fit in one screen.

Was originally introduced by https://github.com/odoo/odoo/commit/f4ee61f950dc1eeb7b3653ca96ea72721512b5e5

Related task: 1924764

closes odoo/odoo#30413
2019-01-25 13:02:46 +00:00
Antoine GuenetandGorash eb0ea8efbe [ADD] web_editor,*: Tests for new structure of web editor
The refactoring also had to be done in order to create a set of unit
tests.
Each behavior can be tested, including the behaviors performed as a
consequence of keyboard interactions (for instance: Enter, Tab...).
This commit also contains some changes to test_utils that were
necessary given the new structure of the wysiwyg editor.

Co-authored-by: Gorash <chm@odoo.com>
2019-01-17 08:40:21 +00:00
mgh-odoo 9ee9724a10 [Generic] unaccent search
- added unaccent search on POS customer/partner and product
- moved unaccent from "mail.utils" to "web.utils"
- added more character to make function accurate

We might use str.normalize(from ES6) but the problem is str.normalize method can not consider some double characters i.e. accented character when normalized it returns 2 normal characters and normalize method returns single character, so here custom unaccent method is used to normalize the string

What we can improve here: We can use str.normalize method and check if string is still have unaccented charaters that we can call our unaccent method but this unaccent method is also working and performing well

closes odoo/odoo#27671
2019-01-10 12:31:53 +00:00
Christophe Simonis d7c5bc02cc [MERGE] forward port branch saas-12.1 up to 8aa8548d8a 2019-01-09 19:59:27 +01:00
Martin Geubelle b4e9410f6a [IMP] web: use showSearchInput in model field selector
The option `showSearchInput`, which is used on the model field selector to display a search
input that filters the displayed fields, is not set by default.

This includes the model field selector instantiated in the `domain` field widget.

closes odoo/odoo#29986
2019-01-08 13:46:01 +00:00
Géry Debongnie 68eefe3cee [FIX] web: do not render invisible filters in search view
In some cases, the web client may receive a search view with invisible
filters.  This is due to the way field_view_get works.  For
example, if there is a group on a filter, then this will be transformed
into an invisible attribute.

In that case, the search view should simply ignore the filter and not
display it.  This was broken in the recent control panel refactoring
(note that the search view lacked the possibility of testing that kind
of situation).

closes odoo/odoo#29430
cherry-pick of 13aae100e2

closes odoo/odoo#29965
2019-01-06 16:54:29 +00:00
Aaron Bohy 4df0a1e31a [FIX] web: wrong tests
This commit fixes two tests that became meaningless after tweaks
in production code:

 - form_tests: use two char fields, as integer fields can't be
   unset since rev. c62a4edcb
 - pivot_tests: the button is disabled since rev. 4f4f111, but
   simulating a click with jQuery bypasses the disabled attribute

This commit also removes unecessary overrides of mockRPC. Those
overrides existed  because the attachments part of the sidebar
used to make a search_read RPC, but this has been removed at rev.
1dbb555.

closes odoo/odoo#28650
2018-11-13 19:56:55 +00:00
Lucas Perais (lpe) 3a0f9da0eb [FIX] web: load SubViews without previous' view _view_ref context keys
On a form view (of model A), define a many2one (model B) with a [form|tree]_view_ref context key
In that view, have a x2m field (model C) with a different [form|tree]_view_ref context key

Before this commit, the second load_views (i.e. on the model C) crashed because
the wrong context key was sent to the server, which returned the view to which the _view_ref points
i.e. the view of the model B

After this commit, we clean the context of subviews loading, because those keys are only useful for the python
and one shot. Hence, there is no crash

OPW 1903780

closes odoo/odoo#28260
2018-11-13 09:02:24 +00:00
Vincent Schippefilt fe7fd9c0d7 [FIX] web: fix qweb test that fails on windows
When the qunit tests runs they are expecting the new line to be the character 10,
but in windows the new line is 10+13.
The test has been updated to ignore the character 13.

closes odoo/odoo#28599
2018-11-13 08:14:07 +00:00
Aaron Bohy ce611ae439 [FIX] web: wrong tests
This commit fixes two tests that became meaningless after tweaks
in production code:

 - form_tests: use two char fields, as integer fields can't be
   unset since rev. c62a4edcb
 - pivot_tests: the button is disabled since rev. 4f4f111, but
   simulating a click with jQuery bypasses the disabled attribute

This commit also removes unecessary overrides of mockRPC. Those
overrides existed  because the attachments part of the sidebar
used to make a search_read RPC, but this has been removed at rev.
1dbb555.

closes odoo/odoo#28651
2018-11-13 20:00:17 +00:00
Vincent Schippefilt 98936f79a1 [REF] web: split relational fields tests into multiple files
The file relation_fields_tests.js was a huge 12K lines files for which some editors have a
hard time managing.

We have split it in 4 files to be more managable and removed remove unused data
and import.

closes odoo/odoo#28561
2018-11-12 12:36:53 +00:00
Christophe Simonis 99d0e1b80e [MERGE] forward port branch 12.0 up to a403155dec 2018-11-12 13:06:48 +01:00
Aaron Bohy 45bc7c92f8 [FIX] web: extend the fieldsInfo of a view with the origin view to evaluate extra fields
Suppose you are editing a SO to add a new line. Depending on the configuration,
a sale order line wizard may open (e.g. if packages are activated).
This wizard is a form view, opened from the tree view of the sale order lines.
We have commit 8e5156938a
that adds extra fields from the originating view.
(However it doesn't work if the other view is inlined, so we modify this part to
add the extra field even in this case.)
Then we need the field info from the origin view in the target view;
we do so by extending the former with the content of the latter.

opw 1904337

closes odoo/odoo#28441
2018-11-09 15:04:18 +00:00
Lucas Perais (lpe) 23313583b2 [FIX] web: progressbar updates on field reset
Have a form record with a progress bar
Modify the max_value of the progress, as well as the current_value bar through an onchange

Before this commit, the new max_value was not taken into account

After this commit, it is.

closes odoo/odoo#29056
2018-11-27 08:53:17 +00:00
Lucas Perais (lpe) ac5a1662f2 [FIX] web: propagate can_create into the search popup
When creating a SO line and clicking on search more for product_id

Before this commit, every user had the button "Create" to create a product.product

After this commit, only user in groups that actually can create a product have the button

OPW 1910371

closes odoo/odoo#28924
2018-11-26 14:54:21 +00:00
Lucas Perais (lpe) c9e32872c0 [FIX] web: list default_sort with multiple fields
Define a x2m tree view with a default_sort including more than 1 field to order the list against

Before this commit, the second field was never used

After this commit, it is used

OPW 1909785

closes odoo/odoo#28840
2018-11-26 09:28:55 +00:00
Christophe Simonis c6e7adfb95 [REV] web: revert f8b38f64 "keep col group by on 2nd reload"
It broke other pivot tests.

closes odoo/odoo#31630

Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-03-06 12:28:02 +00:00
Christophe Simonis afe0133302 [MERGE] forward port branch saas-11.3 up to 3e54704e66 2019-03-06 10:59:32 +01:00
Martin Geubelle e39bcae818 [FIX] web: avoid crash when clicking on colored m2m in list
With the BS4 update, a traceback occured when clicking on a m2m tag using colors
in a list view.

When using colors on m2m tags, the badge was wrapped inside a `dropdown-toggle`.
However, there is no `dropdown-menu` by default (it is only rendered in FormFieldMany2ManyTags
when clicking on the `.dropdown-toggle`, hence the traceback.

The `dropdown-toggle` class is now only set if necessary.

Task 1925313

closes odoo/odoo#31445
2019-02-27 11:39:52 +00:00
Lucas Perais (lpe) 6530f1253d [FIX] web: list editable create then escape
Have an editable list that begins with a date/time field
create a line.
The first field is focused and the datetimepicker is popped up

Now, stroke ESC key

Before this commit, there was a traceback because the datetimepicker received an erroneous
BLUR/INPUT event

After this commit, there is no traceback as we detroy the widgets of the line
(including the datetimepicker) before removing the row from the DOM

OPW 1932409

closes odoo/odoo#31342
2019-02-26 07:07:09 +00:00
Aaron Bohy 7ffe3ce5c6 [FIX] web: kanban: rendering of async widgets
This rev. fixes 3 issues with async (field) widgets in the kanban
view.

From rev. 5faec34a, widget'$el doesn't exist before start. This
means that for async widgets, one can't interact with the widget's
$el right after calling appentTo. In KanbanRecord, this is exactly
what we did for both field widgets (<field name=.../>) and widgets
(<widget name=.../>).

Moreover, when the kanban view was updated (e.g. when the user
refined the search using the search view), and the rendering was
async (because of the presence of an async widget), the renderer
didn't wait at all for the widget to be ready before updating the
view. This caused flickering, mostly, but also a crash in
accounting with the JournalDashboardGraph widget (because
on_attach_callabck was called before the widget was ready). To
reproduce this particular issue, go to accounting, add a filter
that doesn't match any record and save it as favorite (default),
press F5 (no record is displayed), remove the filter.

opw-1925079
opw-1925479

Fixes #30087
Closes #31254

closes odoo/odoo#31327
2019-02-21 13:54:47 +00:00
Christophe Simonis 21eb31d804 [MERGE] forward port branch 11.0 up to a587325ca7 2018-10-31 19:22:21 +01:00
Julien (juc) Castiaux 60d519b890 [FIX] web: format function missing in percentage widget
The format function was missing for the percentage widget type, so
`field_utils.parse[this.formatType]` (see [1]) resolved as
`undefined` which is not a function and so raised an error when
the user was trying to update the field.

This PR add that parsing function. Both `xx%` and `0.xx` are
understood by the parser and resolve to the correct float value.

opw-1895979

[1] https://github.com/odoo/odoo/blob/e220721a8ee80c02fe5aba5ed8c9f3f4ae54ea97/addons/web/static/src/js/fields/abstract_field.js#L399

closes odoo/odoo#28431
2018-11-08 09:51:38 +00:00
Christophe Simonis 3b3a65bef0 [MERGE] forward port branch saas-11.4 up to dc35de9d30 2018-11-06 14:12:51 +01:00
Géry Debongnie baeb1a1938 [FIX] web: accept field name as a groupby descriptor
In some cases, and for historical reasons, the groupby property can be
expressed as a string (for example, 'stage_id') instead of a list of
strings (for example, ['stage_id']).

However, the support was not complete. A crash could happen in some
cases. For example, if there is a group_by: 'stage_id' property in the
context of an action, it works in list view, but adding that view to the
dashboard would result in a crash, without this commit.
2018-11-06 08:53:21 +00:00
Mohammed ShekhaandPriyanka Kaakdiya 006c31b955 [FIX] web: re-evaluate column_invisible after onchange
Let's assume a form view with field A and B (a one2many list), with
a column with attrs column_invisible depending on A.

If the user sets A manually, everything works fine (the column is
hidden/shown directly). However, if A is updated by an onchange
(e.g. depending on the number of rows in B), it doesn't. This
rev. fixes that issue.

Related to Issue: 1851451

Co-authored-by: Priyanka Kaakdiya <pka@odoo.com>
2018-11-05 13:57:39 +01:00
Christophe Simonis f6ca72b3ce [MERGE] forward port branch saas-11.3 up to 21eb31d804 2018-10-31 20:43:03 +01:00
len-odoo 180f528528 [FIX] web: reload many2one data if the context has changed
When a view is loaded, it checks which fields it has to load.
In the case of a many2one, it could be the case that a context key is present in
one view and not in the other; if it happens, we should reload the data, as a
name_get result could vary.

opw 1891295

closes odoo/odoo#28298
2018-10-31 12:52:36 +00:00
Rémi Rahir a219bdb85e [FIX] web: consider correct viewtype when loading data
Before this commit, when loading the data and calling the prostprocess,
the viewType was not correctly passed which could lead to broken
behaviour. For example, if one was to load a record from a list view
embedded in a form view, the viewtype passed was the list which
prevented to load the data from the form view.

OPW 1891295

closes odoo/odoo#28279
2018-10-30 09:24:39 +00:00
Julien (juc) Castiaux 854208370c [FIX] web: creating a record in a grouped empty kanban view crash
When creating a record in a grouped kanban view, it tries to add
the record to the first column but if no column exist, it fails
to find the first one and raise an exception.

This PR correct that bevahior by checking it exists a column and
fallback to the view form when it does not.

opw-1902851

closes odoo/odoo#28262
2018-10-30 07:17:40 +00:00
Christophe Simonis b106b7ce0b [MERGE] forward port branch 12.0 up to dd70c68426 2018-11-06 16:40:07 +01:00
Christophe Simonis a299517f83 [MERGE] forward port branch saas-11.3 up to 6136f0c02e 2018-10-29 11:56:32 +01:00
svs-odoo e10fd34682 [IMP] web: load tags in kanban view in one batch
Add an 'enableRelationalFetch' option in _readGroup who force to make
only one rpc for x2m and reference fields.
Usefull to avoid useless (and blocking when too numerous) rpcs (tags
field in a kanban view for example).

Task #1878113 (2/2)

closes odoo/odoo#27731
2018-10-30 12:58:36 +00:00
Christophe Simonis cc8e8237bf [MERGE] forward port branch 11.0 up to 84500c27b1 2018-10-25 13:59:45 +02:00
Christophe Simonis 0fcb28c97b [MERGE] forward port branch saas-11.3 up to d82a907728 2018-10-19 14:32:09 +02:00
Aaron Bohy d82a907728 [FIX] web: kanban quick create when grouped by selection
Rev. 42e1efded5 aimed to disable the quick create feature when
grouped by date(time) fields, by only enabling it for char, boolean
and many2one fields. However, the selection case is quite important
and must be handled as well. This is what this rev. does.

Task 1878254
2018-10-19 13:15:31 +02:00
Aaron Bohy 120709f807 [FIX] web: kanban quick create with correct default values
When a kanban view is grouped by a char or a boolean field, and the
quick create option is enabled, the correct default value for the
grouped field (i.e. the value of the column in which the record is
created) should be given (either in the context if that field isn't
in the quick create form view, or as a default value in that form
view otherwise).

Before this rev., it wasn't the case, as it was only working when
grouped by a many2one field.

Task 1878254
2018-10-19 13:15:30 +02:00
Christophe Simonis f2ada1560e [MERGE] forward port branch 11.0 up to 22a13073f0 2018-10-19 12:25:17 +02:00
Aaron Bohy 22a13073f0 [FIX] web: kanban quick create properly disabled
when grouped on field types for which it isn't supported.

Rev. 42e1efd disabled the quick create feature when the view is
grouped by date(time) fields. However, it hasn't been correctly
forwardported to 11.0 (with the new views). Indeed, the check was
done only once, at the initilization of the view. So if the user
selected another field to group by afterwards, the quick create
feature wasn't enabled/disabled accordingly.

Moreover, we didn't check if it was available when the user clicked
on CREATE in the control panel. So even if it wasn't (and thus if
there were no '+' icon in the columns), when the user clicked on
CREATE, the quick create widget was inserted in the first column.

This rev. fixes both issues.

Task 1878254

closes odoo/odoo#27867
2018-10-19 06:56:40 +00:00
Christophe Simonis e744241d83 [FIX] web: trim tooltip text before comparison
The error is triggered at least on Chrome 69 on macOS.
2018-10-22 16:53:21 +02:00
Mathieu Duckerts-Antoine 7fb7522cfe [FIX] web: JournalDashboardGraph widgets appear at kanban views updates
closes odoo/odoo#27892
2018-10-17 13:01:56 +00:00