Commit Graph
108920 Commits
Author SHA1 Message Date
Géry Debongnie 3ff7ff3e94 [FIX] web: properly evaluate unset numeric values in domain
Before this commit, when a numeric value was not set (for example, a new
record with no default_get value), then it was not properly evaluated as
0 in a domain.

We also slightly refactored the code so we always use the same method to
compute the evaluation context.
2017-04-11 19:44:38 +02:00
Géry Debongnie a529a928b4 [REF] web: prevent useless rerender in some cases
When clicking on a form button, the saveRecord method is called, which
will then call the toReadonlymode method, which will rerender the form
view, even if it was already in readonly mode.
2017-04-11 19:44:38 +02:00
Aaron Bohy 2bca653584 [FIX] web: BasicModel: correctly generate x2many commands
This commit fixes two problems. First, the commands weren't
correctly generated for relational fields inside relational fields.
For example, if a form view contained a one2many containing itself
a many2many, the commands weren't generated for the many2many
inside the one2many. Thus, it's value couldn't be saved.

Second, when doing an onchange RPC, all record data should be sent
to the server, not only what have changed. Before this rev., for
x2many fields, commands were sent only if the field had changed.
2017-04-11 19:44:38 +02:00
Aaron Bohy 2932aa64bc [IMP] web: relational_fields: re-enable assert in a test
This didn't work when the test has been written, but it does now.
2017-04-11 19:44:38 +02:00
qsm-odoo a3271fa663 [FIX] web: formview button context should be given to actions
When clicking on a stat button in a form view, an action is executed.
The button might also be given a context which have to be used when
running the action. This context was ignored since the context
refactoring made with commit 26a7fe7de1b6258989bc63335321f8f8e83435af.
2017-04-11 19:44:38 +02:00
Géry Debongnie 8ad523a865 [FIX] web: fix focus issue in fields x2many
Before this fix, when the user dared press 'TAB', the move_next event
was propagated from the sub one2many to the outer form renderer, and
caused the form view to try to focus another totally unrelated field.
Also, the event was sent twice, because we are in a case where a field
widget is contained in another field widget.
2017-04-11 19:44:38 +02:00
fwi-odoo c7cd6fdd41 [FIX] web: wrong reference to this 2017-04-11 19:44:38 +02:00
Géry Debongnie 0ef53d742c [FIX] web: fix two small crashes in debug manager
- remove edit workflow link in debug manager. The workflow feature was
    removed, but there was still a link in the debug manager.  Clicking on
    that link was a crash.
- the rpc to fetch a view was wrongly updated, so the return value was
  not properly used.
2017-04-11 19:44:38 +02:00
Adrien Dieudonne eed432519e [FIX] web: digits precision
- Remove unnecessary "round_decimals". Will be process by format_value
- Fix json format value for digits attribute
2017-04-11 19:44:38 +02:00
Géry Debongnie dbc6f21321 [FIX] web: properly evaluate domains in kanban views
We still did not properly evaluate domains in kanban view.  The proper
eval context is quite tricky to get right, because we need to perform
some computations.  With this commit, we simply use the code that was
already in the basic model.
2017-04-11 19:44:38 +02:00
qsm-odoo f68462198e [REF] web: don't debounce DebouncedField._onInput directly
The `DebouncedField` class has a `_onInput` method which is called when
the user is typing text and which is debounced so that its action
(setting the field's value) is not recalled too quickly.

The problem is that if we have to do other actions which should not wait
for the debouncing (or wait for another debouncing) when the user is
typing text, this would imply to namespace the "input" event to add
another handler, which is not very elegant.
Instead, this commit changes the `DebouncedField` so that the
`_onInput` handler is not debounced but instead calls a private method
which is debounced (`_doDebouncedAction`).
2017-04-11 19:44:38 +02:00
qsm-odoo b9d9c6e3bc [FIX] web: monetary should reset on currency change
This reverts commit 839a07fbed4720fc71c070507c591295722df350.
Indeed, the system will need the `resetOnAnyFieldChange` option as the
`FieldMonetary` will need to be re-rendered if the currency changes.
This does not use the `_fetchSpecialData` system as it will be
refactored later and the currency can be fetched without RPC.
2017-04-11 19:44:38 +02:00
qsm-odoo c5d5d7a0ff [FIX] web: monetary field was adding DOM at each rendering
Before this commit, the `render` method of the monetary field added
the <input/> and currency elements without removing the previous
ones. As this was called on each related `onchange`, the DOM was
growing at each of these changes.
2017-04-11 19:44:38 +02:00
qsm-odoo d6d7923c67 [FIX] web: format monetary field value as a float in edit mode
Before this commit, if a field was declared as a "Monetary" field in
the model, the `FieldMonetary` was adding the currency symbol in the
<input/> in edit mode.
2017-04-11 19:44:38 +02:00
qsm-odoo c35e0f132f [REF] web: remove useless use of empty() in field rendering
The jQuery `html` and `text` functions already empty the element, so
no need to call `empty` before.

+ Lint the basic_fields.js file
2017-04-11 19:44:38 +02:00
Géry Debongnie 5e3c4dd434 [FIX] web: calendar: prevent crash when loading data with avatar 2017-04-11 19:44:38 +02:00
Géry Debongnie f3d7b7e420 [FIX] web: properly transfer lazy=false option to rpc
The lazy option in read_group is by default true, so when we want to
override it with false, it needs some special care.
2017-04-11 19:44:38 +02:00
Géry Debongnie 6bc75b61be [FIX] web: better error handling in view and action manager
Before this commit, it could happen that a crash at the wrong time (for
example, while loading a view) cause the web client to crash for various
reasons.  For example, it assumes that the active view always has a
valid controller.  Or the action manager could not detach the previous
view, so we had the 'double view' rendering in the web client.

With this commit, we add some protections at various points.  Those
safety measures should help the user keep working even if a specific
view did crash.
2017-04-11 19:44:38 +02:00
Géry Debongnie 9100e675df [FIX] web: add support for discarding lines in o2m
This is not a complete work, but it introduces the basic infrastructure
to properly edit various more sophisticated editing behaviours.

The main focus of this commit is to handle discarding invalid lines in
one2many, potentially asking the user for confirmation.  So, the
relevant methods have to be modified to return some deferred, because
the operation is now asynchronous.
2017-04-11 19:44:38 +02:00
Géry Debongnie 0f96189b7f [FIX] web: update all fields in onchange in one2many
Before this commit, we did not properly update all fields in a one2many.
I assume that it was because the list renderer crashed if it tried to
display a field that did not exist in the list view, but in that case,
we simply can ignore these fields.
2017-04-11 19:44:38 +02:00
Géry Debongnie cef1b273c0 [FIX] web: prevent issue where changes where done to real data
Before this commit, the basic model used the real data array as changes
in the method _applyX2ManyChange, which means that each change was also
done to the data array.
2017-04-11 19:44:38 +02:00
Géry Debongnie 3662c7246f [FIX] web: unselect current row on one2many before doing something else
In a one2many, when we click on 'Add an item', we need to unselect the
current row.  Otherwise, its changes will not be committed and it will
be in practice discarded.
2017-04-11 19:44:38 +02:00
Géry Debongnie 7056ec1ac6 [FIX] web: various bugs with pivot view and no data
The pivot view had various small issues causing a crash when
transitioning from and to a 'no data' state.
2017-04-11 19:44:38 +02:00
Géry Debongnie 21324ded09 [FIX] web: do not create new line if onchange has warning in o2m
In a one2many field, when the user clicks on the 'Add a line' button, we
need to create a new record.  This means that we call the default_get
route, then call the onchanges.  The onchange can return a 'warning'
key, which is displayed to the user.  But in the specific case of a
one2many, we don't want to actually create the record.  So, we reject the
deferred to prevent that from happening.
2017-04-11 19:44:38 +02:00
Géry Debongnie 28e1620731 [FIX] web: list view did not discard properly
To add a record to a list, the list controller called the
addDefaultRecord method.  But that method did not made the changes to
the _changes key, it edited in place the data key.

So, this means that it was not possible to discard the add a line.
2017-04-11 19:44:38 +02:00
Géry Debongnie 03fabb0c4a [REF] base_import: split import button code out of action 2017-04-11 19:44:38 +02:00
Aaron Bohy 1fadf4a793 [FIX] web: o2m: save updates of one2many records
With this commit, updates of existing o2m records are now
correctly saved in DB when clicking on 'Save' in the main
form view.
2017-04-11 19:44:38 +02:00
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