Commit Graph
108893 Commits
Author SHA1 Message Date
Aaron Bohy 97b4da489d [FIX] test_new_api: adapt tour to new onchange semantics
Onchanges triggered in a relational fields are now directly
triggered on the main form view as well. This was not the case
before and there were some steps (or parts of steps) checking
that.
2017-04-11 19:44:38 +02:00
Aaron Bohy 3d959382fd [FIX] web,mail: one2many records: multiple views
A record of the basic model may need to be displayed in different
views (e.g. a o2m record is displayed in the, e.g., Kanban view
inside the main form view, and if clicked, it is also displayed
in the form view opened in a dialog). However, the fields present
in those views may differ.

The previous implementation of fieldsInfo in the record didn't
handle that, as it was a dict whose keys were field names. With
this commit, the fieldsInfo is dict whose keys are view types, and
the values are dicts whose keys are field names (the fields of
the corresponding views, with they attrs in the view).

This allows to create multiple o2m records in a row in a form view.
2017-04-11 19:44:38 +02:00
Martin Geubelle 2d449f8f1a [REF] web: make clicking on create button overridable in kanban 2017-04-11 19:44:38 +02:00
Géry Debongnie 3f4b422148 [FIX] web: don't ask twice confirmation to discard
Before this commit, the web client displayed a confirm dialog when
opening the app switcher (enterprise version) if a record is dirty, then
again when doing the next action.  With this commit, we make sure that
the second time we ask confirmation to discard changes, no dialog will
be opened.
2017-04-11 19:44:38 +02:00
David Monjoie 83b9be825c [ADD] web: add percentpie widget tests and documentation 2017-04-11 19:44:38 +02:00
David Monjoie 53726d093f [ADD] web: add statinfo widget tests and documentation 2017-04-11 19:44:38 +02:00
David Monjoie 1b08fa43ab [ADD] web: add label_selection widget tests and documentation 2017-04-11 19:44:38 +02:00
David Monjoie fbb0450d51 [ADD] web: add state_selection widget tests and documentation
This commit also adds the special_click property which is used to mark
a DOM element such that clicks on it will not be intercepted by the
list view.

Basically, we need this on elements which rely on bootstrap events,
since those need to bubble all the way up. If we catch them in
the list view, to open a cell or a record, then they never get to
bootstrap's level and so the widgets relying on these elements
cannot work.

We plan to remove it at some point, when we have more time to figure
out a way for the click event to reach bootstrap from inside the list
view without breaking the list view behavior itself.
2017-04-11 19:44:38 +02:00
David Monjoie 8b2c091313 [ADD] web: add priority widget tests and documentation 2017-04-11 19:44:38 +02:00
David Monjoie 83dab2d0dc [REM] web: remove id widget
The original reason why this widget was created is because sometimes,
the id is a virtual one, represented by string in the webclient. As
such, the integer widget could not render it properly since it could
not parse the integer from the string. This led to the following bug,
which in turn led to the creation of the id widget:
https://bugs.launchpad.net/openerp-web/+bug/919184

Now, virtual ids are not handled within the record data itself anymore,
making it a non-issue to render the id field in the webclient since
it is not given a value until a proper id is created. The virtual id
management is completely out of the view scope now, rendering this
widget useless.
2017-04-11 19:44:38 +02:00
David Monjoie acbbdd1a73 [FIX] web: fix default values for x2many fields in mock_server 2017-04-11 19:44:38 +02:00
David Monjoie a0b31e7df5 [ADD] web: add boolean button documentation 2017-04-11 19:44:38 +02:00
David Monjoie b9a2a3e320 [ADD] web: add url widget tests and documentation 2017-04-11 19:44:38 +02:00
Géry Debongnie b889e4b3e6 [IMP] web: form support for tab navigation
The new form view does not really work well with the TAB key.  This is
partly caused by the fact that the tab event is preventdefaulted.

With this commit, we reintroduce a basic navigation with TAB and
shift+TAB.
2017-04-11 19:44:38 +02:00
Aaron Bohy 11a17f7bb9 [FIX] mail: activity feedback: port odoo/odoo@63167fc5
to the new views
2017-04-11 19:44:38 +02:00
Aaron Bohy 2169a585dd [FIX] web: debounce field changes for FieldText
like done previously for input fields.
2017-04-11 19:44:38 +02:00
Aaron Bohy 4a9ca16369 [FIX] web: pyeval_tests: adapt test after forward-port 2017-04-11 19:44:38 +02:00
Aaron Bohy 68eeb849c4 [FIX] web: FieldMany2One: correctly return deferred
This function is overriden in studio and the overrides needs to
know when the RPC is done.
2017-04-11 19:44:38 +02:00
Géry Debongnie cbc63ca869 [FIX] web: properly handle onchanges after discard
When an onchange is resolved after a discard, it caused a traceback. We
now make sure that it does not happen.  Note: I think that the test is
quite neat.
2017-04-11 19:44:38 +02:00
Géry Debongnie e3f84e592e [REF] web: use a mutex to serialize all operations in basic model 2017-04-11 19:44:38 +02:00
qsm-odoo ef52914ea2 [REF] web: properly confirm value change of debounced input field
Input fields notify their changes when the user is typing text at a
rate of max 1 per second (by default) and when a change is confirmed.
This last case was handled by listening to the "focusout" event. The
"change" event is however more suited to handle that.

This commit also solves a problem with the related test. Before this
commit, the test triggered some "input" events on an <input/>, then
waited some time so that the debounced action is executed, then
restarted triggering events... the problem is that this "some time" was
long enough to trigger the onchange but not necessarily long enough
to be sure another onchange can be started. Indeed, the mockserver get
rid of RPC delays but not of CPU delay. As two subsequent onchange
cannot be done at the same time (the second one is done after the first
one is finished (see Mutex)) and that this test simulates a 3ms delay
for the onchange, there is no guarantee that waiting x ms (even > 3ms)
will be enough, indeed sometimes we had this sequence:

1) trigger "input" event
2) trigger "input" event
3) start delay of 75ms
4) debouncing time (3ms) is finished: call `_setValue`
5) basic model mutex (already resolved)
6) start async onchange RPC
7) (1) -> (6) took more than 75ms CPU time, the delay started in (3)
   is finished: trigger "change" event
8) call `_setValue` (no debouncing of "change" events)
9) basic model mutex... NOT resolved as the async onchange RPC
   started in (6) did not had the opportunity to continue its
   call sequence (no matter the time it would take)

To solve this problem, the 75ms delay had to be replaced by a non
arbitrary waiting: the mutex resolution. As the test does not know
about this mutex, the only way to be sure it is finished is to wait
for the `mockRPC` to be finished thanks to a deferred and then wait
for another callstack to be completed thanks to a 0ms delay.
2017-04-11 19:44:38 +02:00
qsm-odoo c60743428d [FIX] web: typo in function name (FieldBoolean._onKeydown)
When focusing a checkbox field and hitting the "enter" key, the
checkbox should change its status. Before this commit, this produced
a traceback instead as it was trying to call the `_onKeyDown`
function while it was defined as `_onKeydown`.

Also the `_onKeydown` method is in fact declared in the `AbstractField`
parent implementation, so there is no point in declaring the event
binding twice. Also, part of the `FieldBoolean._onKeydown` code was in
common with its parent `AbstractField._onKeydown` code so remove it as
there is no point in duplicating it.
Note: this `_onKeydown` method has to be refactored as it is breaking
form view navigation anyway.

Also modify an existing test to check the checkbox keyboard navigation.
2017-04-11 19:44:38 +02:00
qsm-odoo c74ab1a146 [IMP] web: domain & field selector usability (+ design)
+ Document and refactor the files using the new guidelines

* Now only non-technical names are used when building field chains and
  domains (technical names can be used in debug mode).
* Better warnings are displayed when using the field and/or domain
  selector widgets (also checks domain validity in both domain field
  AND domain selector widget).

Also improve design (thanks to original work of @stefanorigano):
- Hovering 'remove' highlights the element that will be removed
- Hovering 'add node' btns shows where the new node will be created
- Restyle debug domain input field (make it similar to a text editor)
- Improve design and layout
- Resize inner fields
2017-04-11 19:44:38 +02:00
Martin Geubelle 043384d72f [REF] web: make _render functions overridable
As `_renderInnerGroupRow` is returning the row, appended to the
previous result, and not only the row, it was not possible to
override the method to add, for example, another row.

This commit doesn't change the behaviour, only the return of
private functions.
2017-04-11 19:44:38 +02:00
Martin Geubelle caf0ec37a6 [FIX] web: do not call method on undefined controller
As `create_view` is asynchronous, it is possible that there is an
active view without any associated controller.

We thus test here if there is a controller before calling its method.
2017-04-11 19:44:38 +02:00
Aaron Bohy 8f8e8b6e0e [FIX] web: Domain: don't return frozen domain
In a recent commit, the fields object describing all fields of a
model is (deeply) frozen by the data_manager. As a consequence, if
a field has a domain (represented by an Array), this domain is
frozen as well.

Moreover, when the function getDomain is called on a dataPoint,
the returned domain is the one in fields, not a copy.

Problem is that the Many2One field updates this domain to add the
blacklisted ids, which produces an error if the domain is frozen.
2017-04-11 19:44:38 +02:00
Géry Debongnie c43a3a5045 [FIX] web: debounce field changes for input fields
Before this commit, every field changes were sent upstream and triggered
a notifyChange, potentially causing multiple (onchanges) RPCS in rapid
succession.

It is useful to have a feedback of the new values of the fields even
without needing to lose the focus, but it should not be done for each
keystroke.

With this commit, we debounce the onInput handler, so the method
setValue is in practice debounced as well.  We need to add a handler on
the focusout event to make sure that if the user changes input, the
setValue is immediately called.

Note that we had to add support for that in the test utils environment
(and not only in the createView method: field widgets can be
instantiated in other environment, such as the reconciliation widget)
2017-04-11 19:44:38 +02:00
Martin Geubelle 07f5ac3dab [REF] web: use many2many tag widget in kanban
Some commits haven't been correctly forward-ported, like
https://github.com/odoo/enterprise/commit/2a3494a005f38baf2fd3db2c23844129e969e464 or
https://github.com/odoo/enterprise/commit/5664a19045abed0cf900ef255bd3c96e16e8886c

There purpose is to use the many2many tag widget in the
kanban renderer instead of custom manipulation.

The tests have also been adapted to correspond to the new tags.
2017-04-11 19:44:38 +02:00
Martin Geubelle 7f4e552e3f [FIX] web: mockRead all fields if no field specified
When mocking a `read`, the mock server should return all fields if no
field are specified in the `read` parameters.
2017-04-11 19:44:38 +02:00
Martin Geubelle 5fe3c86165 [REF] web: split _processFields in kanban record
This split was done pre new views to allow to override in Studio.
2017-04-11 19:44:38 +02:00
Martin Geubelle 580a909d77 [FIX] web: set modifiers on invisible elements
Modifiers were not set on the node if it is invisible. However
one could want to evaluate these modifiers on invisible nodes.
2017-04-11 19:44:38 +02:00
stefanorigano 083f20d0cd [IMP] web: domain selector, simplify operators text 2017-04-11 19:44:38 +02:00
qsm-odoo 5398354316 [FIX] web: parsing and formatting values in domain selector
With the new `field_utils` parsing functions, many field types were
not able to be used with the domain selector anymore.
* a m2o value is now parsed to an object with an `id` key and a
    `display_name` key. This object cannot be placed in the `<input/>`
    holding a `DomainLeaf` value in the domain selector widget (right
    now, it is showing [Object object] because of this parsing). If
    the value is an object, display its `id` key or nothing if this
    key does not exist.
* a date(time) value is now parsed to a moment object. Adaptation had
    to be made so that it is correctly displayed for the user and
    properly converted to its server format when building the char
    domain.
* an array of char is formatted to an empty string... obviously the
    selector implementation is wrong here and should format array
    values individually. However, as the widget only support arrays
    for char values, the formatting is useless so it can simply be
    disabled in that case while waiting for better implementation.

Note: the parsing and formatting code in domain selector should be
improved to be more accurate and understandable. This will be done
in a future update.
2017-04-11 19:44:38 +02:00
Christophe Matthieu cd78695126 [FIX] web: with begin date is readonly event can be created but not modified 2017-04-11 19:44:38 +02:00
Géry Debongnie 7bb12de1c6 [REF] web: remove old commented code
Also, add some docstring tags.
2017-04-11 19:44:38 +02:00
Christophe Matthieu 7df1ef5305 [FIX] web: graph view should properly format data
A big problem is that the read_group method has a variable API: it
sometimes returns values in a __count key, sometimes in a
[somefield]__count key.

Before this commit, the graph view was not using the correct value in
some cases.
2017-04-11 19:44:38 +02:00
Géry Debongnie 3deac18485 [REF] board: update dashboards to new js framework
With the new views, we totally broke the dashboard.  This commit
rewrites all the code to comply with our new coding guidelines, and make
sure it works, with some tests.

Note that a big change is that we don't instantiate an action manager
and a view manager, we directly instantiate the views.

Also, this is not the best way to organize the dashboard.  I think that
it should be a client action, not a form view, so we don't have to
overload all the form view classes and we don't depend on form view
behaviour/view caches/...
2017-04-11 19:44:38 +02:00
Géry Debongnie 6016369b30 [FIX] web: view manager should properly handle wrong ids
In some cases, the view manager do_load_state method can receive an
empty string as id.  This was the case when we refresh the dashboard for
example.

This is not a perfect fix (the do_load_state and the url mechanisms
should be improved), but it makes things more robust.
2017-04-11 19:44:38 +02:00
Christophe Matthieu 07f91476aa [REF] account: make reconciliation code more extensible
account_batch_deposit need this change
* create module for test datas
* split addProposition into addProposition and _addProposition
2017-04-11 19:44:38 +02:00
Aaron Bohy c94b4b3b5f [FIX] web: o2m: reset fieldsInfo after edition
One2Many fields edition (creation of new related records or
edition of existing ones) needs a specific handling, because the
related records aren't saved when the user clicks on 'Save' in
the dialog, but when he clicks on 'Save' in the main form view.

To make this work, the model (instance of BasicModel) and the
representation of the edited record in the model must be given to
the form in the dialog.

Problem is that the fields to display in the kanban or list view
and the form view in the dialog may be different, so when opening
the dialog, the list of fields in the record is updated, and this
list must be reset to its original value when the user closes the
dialog. This last part wasn't done correctly before this commit,
which causes tracebacks when the kanban/list view contained fields
that weren't in the form view.
2017-04-11 19:44:38 +02:00
Aaron Bohy 9591992469 [REF] web: views: refactor $buttons handler unbinding 2017-04-11 19:44:38 +02:00
Géry Debongnie 1c7fa2e72d [FIX] web: pivot view should not crash when sorting 2017-04-11 19:44:38 +02:00
Géry Debongnie 556ee204d0 [FIX] web: pivot view should respect the groupbys from the search view
Before this commit, groupbys from the search view were totally ignored.
2017-04-11 19:44:38 +02:00
Géry Debongnie 00cd7052cb [FIX] web: better handling of isDirty state
When the view is saved (either directly or via a widget in readonly
mode), the flag isDirty was not reset to false.

also, use the $ function on widgets insted of $el.find and remove some
unused imports
2017-04-11 19:44:38 +02:00
Géry Debongnie 47bb855c7e [REF] web: add documentation to form view 2017-04-11 19:44:38 +02:00
Géry Debongnie 0250e60dd2 [FIX] web: check if changes can be discarded before leaving view
Before this commit, we did not check if the changes can be discarded
when opening the app switcher.  This is now done.  Note that this check
was formerly done in the form view, and we moved this to the view
manager.  This now means that all views have the power to decide if they
can be discarded.
2017-04-11 19:44:38 +02:00
Géry Debongnie 6a8e7acc67 [IMP] web: update qunit to last version (2.2.1)
It has an Abort button!!!
2017-04-11 19:44:38 +02:00
Géry Debongnie ca8b7779d4 [REF] web: update form_view to new style 2017-04-11 19:44:38 +02:00
Aaron Bohy 0d41d60bb7 [FIX] web: MockServer: better mock loadViews()
Before this rev. parts of the processing of the fields_views and
fields returned by the server done in data_manager were
duplicated in the MockServer and test_utils, and other parts
were missing, so the test environment didn't reproduce well
the tested one.

This rev. refactors the code s.t. it can call the method of the
data_manager that postprocesses the result of a loadViews(). It
also moves the logic to the fieldsViewGet() method so that this
works in every test scenario, not only when a view is created
(e.g. Studio).
2017-04-11 19:44:38 +02:00
Aaron Bohy 348a44855d [IMP] web: data_manager: make field description self-contained
The fields are represented as an Object whose keys are the field
names and values their description. By adding the name inside the
description, this commit makes it fully self-contained.

This commit also moves the processing of fields_views s.t. they
are stored processed in the cache, instead of processing them each
time they were requested.
2017-04-11 19:44:38 +02:00