Commit Graph
108844 Commits
Author SHA1 Message Date
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
David Monjoie c8fd0e4507 [FIX] web: fix phone widget tests with crm_voip 2017-04-11 19:44:38 +02:00
Géry Debongnie 2106e3dd2e [REF] web, *: simplify our RPC system (in JS)
The RPC system was not completely satisfactory, we decided to prepare
the future and do it properly.  This commit introduces the new rpc
system, which replace the previous new one.  We now simply have a
method, this._rpc, which takes a dictionary of parameters.  The idea is
that depending on the parameters, it is able to add correct default
value when necessary.

For situations where we don't have the this._rpc method, we can use the
rpc.query method, which takes the same arguments, but directly calls
ajax.rpc instead of triggering up some events.
2017-04-11 19:44:38 +02:00
Christophe Matthieu 749d10e8b5 [FIX] web: avoid memory leak
Methods are bound on button but never release.
2017-04-11 19:44:38 +02:00
Christophe Matthieu dacb326695 [FIX] web: apply modifiers on group tag 2017-04-11 19:44:38 +02:00
Christophe Matthieu 60f35364d7 [FIX] web: don't overwrite the mode if existing in attributes 2017-04-11 19:44:38 +02:00
Aaron Bohy 41ea55c272 [FIX] web: KanbanModel: resequence
There were several issues with the resequence method.

First the lookup in the model's fields to determine if there is a
'sequence' field (to know whether or not an RPC should be done)
was incorrect when resequencing columns as the lookup was done for
the wrong model. Actually, we don't have the list of fields of the
related model, so this lookup shouldn't exist at all, and the RPC
should be done in all cases (the controller correctly handles the
absence of 'sequence' field).

Second, the JS sort of the data didn't work either as we didn't
manipulate the dataPoints but only their ids (the internal
representation of the dataPoints is flat, so the data of elements
of type 'list' only contains the id of its dataPoints).
2017-04-11 19:44:38 +02:00
Aaron Bohy 21dffd53df [FIX] web: kanban_tests: throw error to simulate RPC fail
Returning a rejected deferred isn't the correct way to notify the
MockServer that something went wrong, throwing an error is. This
error is then catched, and the RPC deferred is rejected with two
arguments: an object describing the error and a JQuery event.
2017-04-11 19:44:38 +02:00
Aaron Bohy 04bc03ced2 [IMP] web: Kanban grouped: don't allow to sort column
... if not grouped by m2o, as it won't save anything in database
anyway, so at the next refresh of the view the new order will
be lost.
2017-04-11 19:44:38 +02:00
Aaron Bohy cbf0e30af3 [FIX] web: KanbanController: this.fields_view is undefined
The fields are now available on the state. It produced a traceback
when the user tried to resequence columns.
2017-04-11 19:44:38 +02:00
Aaron Bohy 145e89604d [FIX] web: Kanban: record quickcreate: fail handler
When the user quick creates a record in a grouped kanban view, a
name_create RPC is done. This RPC may fail, and there were
several issues with the fail handler.

First, those fail handlers take 2 params: an object describing
the error, and a JQuery event. The event was the first argument
in the handler, so it crashes on event.preventDefault().

Second, when the name_create fails, a FormViewDialog in edit
should be open. Former code opened a SelectCreateDialog.

This commit also ensures that the default values are correctly
given to the form in the dialog, through the context.
2017-04-11 19:44:38 +02:00
Aaron Bohy 6bad524bb3 [FIX] web: grouped Kanban: don't display nocontent helper
When the kanban is grouped and its groups contain no record, the
nocontent helper shouldn't be displayed. This wasn't the case
before this rev.
2017-04-11 19:44:38 +02:00
Aaron Bohy b3015960c1 [FIX] web: BasicModel: read_group: empty groups
When reloading a grouped Kanban view (e.g. after specifying a new
domain), the internal state of the (sub-)groups is kept so that
it can be restored (like which are the open groups and the limit
and offset inside the groups).

However, for models and fields whose read_group returns empty
groups (e.g. project.task grouped by stade_id) this was wrong if
the specified domain filtered out all records of an open group,
because as its data wasn't reloaded (because there is no record),
the old data were still in place, so the filtered out records still
appeared in the Kanban.
2017-04-11 19:44:38 +02:00
qsm-odoo 3f8569a057 [FIX] web: send array domains to the server in domain field
The `FieldDomain` was sending string domains instead of array domains
to the server (by its associated `BasicModel._fetchSpecialDomain`
function). The server does not do the conversion string -> array for
domains, so the RPC broke everytime.

This commit also modifies the `MockServer` so that tests also break
when sending string domains.
It also improves the way failed rpc are handled. Indeed when an rpc
fails, its deferred is rejected with two arguments: the error object,
and a JQuery event (that will display the error if not
preventDefaulted). The mockRPC didn't pass the second one and thus
there was a crash when reaching code that e.g. calls preventDefault
on that event. Note: this also removes the stringify/parse of the
error object as it is not a correct simulation of a server error
object anyway.
2017-04-11 19:44:38 +02:00
Christophe Matthieu eaa66d1156 [REF] web: change internal representation of fields and view meta datas
* Data manager load_view returns a viewInfo object
* ViewInfo contains: the arch, fields and fieldsInfo objects, and some extra informations
* The fields come from the server and are frozen, without any view attributes (depend of the model).
* The fieldsInfo contains every view attributes and informations.
2017-04-11 19:44:38 +02:00
Christophe Matthieu e1eea38f2f [FIX] web: attributes is not reseted by setFieldProps 2017-04-11 19:44:38 +02:00
Christophe Matthieu 8f7a445a03 [IMP] web: simplification use loadViews instead of loadFieldView
Don't need to create a dataset to call loadViews
2017-04-11 19:44:38 +02:00
Aaron Bohy 64dd7d5443 [IMP] web: rpc: more permissive API for read_group
This rev. allows to specify some kwargs of read_group directly in
an Object given to kwargs(), instead of explicitly specify them
using the corresponding method (e.g. to specify the context in the
kwargs instead of by calling .withContext().
2017-04-11 19:44:38 +02:00
Aaron Bohy f7a8c1b276 [FIX] web: rpc: call route: don't override given params
When calling a route using the new RPC query builder (e.g. by
doing "this._rpc('/a/route').params({a: 'a'}).exec()"), if one of
the route kwargs was 'model', 'method', 'args' or 'kwargs', the
given value was overriden by undefined.
2017-04-11 19:44:38 +02:00
Aaron Bohy d75a7b850a [FIX] web: Kanban: allow cancelling a quick create 2017-04-11 19:44:38 +02:00
Aaron Bohy fc08507fdb [REF] web,*: convert Kanban widgets to new style
The remaining widgets were KanbanRecord and the two quick create
widgets. Now, all kanban files have been converted and refactored.
2017-04-11 19:44:38 +02:00
Aaron Bohy 8986428709 [FIX] web: test_utils: get_session fallback
The session can me mocked in the test environment (if a session
is given in the params). However, when it is not, it crashed
if one of the instantiated widgets requests the session with
getSession().

This rev. adds a fallback so that when this happens, the real
session (web.session) is given.
2017-04-11 19:44:38 +02:00
Aaron Bohy 9a3a402f5e [REM] hr_recruitement: remove useless files
The sass/css rules didn't apply (.openerp).
The JS redirects the kanban record clicks to a click on an element
that doesn't exist anymore.
2017-04-11 19:44:38 +02:00
Aaron Bohy 740a2b1265 [FIX] web: BasicModel: keep state of groups on reload
The 'isOpen' state of groups was already kept when reloading a
(e.g.) list view. The limit and offset should be kept as well.
2017-04-11 19:44:38 +02:00
Aaron Bohy 9ba78dfcce [FIX] web: reload view with correct params
When reloading a view by clicking on its icon in the view switcher,
some params of the view (e.g. limit) were reset to their original
value. So if the user previously updated that param (e.g. by
editing the pager), these changes were lost.

This rev. ensures that those original params are only given to the
view at its initialization, but not on reload.
2017-04-11 19:44:38 +02:00
Aaron Bohy d7fdff572f [FIX] web: grouped list view: group's pager
Before this rev., there was no pager rendered in groups that
contain more than 'limit' records.
2017-04-11 19:44:38 +02:00
Aaron Bohy 5fb2d32ef2 [IMP] web: MockServer: handle limit and offset
in _mockSearchRead
2017-04-11 19:44:38 +02:00
Aaron Bohy b2006c9940 [IMP] web: pager: disable edition if pager is disabled
When the pager is disabled, the user can't go to the next or
previous page. It shouldn't be able to manually edit the pager's
values neither.

Also
  - converts pager.js to the new JS coding guidelines
  - adds two tests
2017-04-11 19:44:38 +02:00
Aaron Bohy 357090428b [FIX] web: rpc: handle offset arg
Even if specified when building the rpc query, the offset wasn't
given in the arguments of the performed RPC.
2017-04-11 19:44:38 +02:00
David Monjoie 82bb35cf79 [ADD] web: add monetary widget tests 2017-04-11 19:44:38 +02:00
David Monjoie 859f11c740 [REF] web: extract _prepareInput from _renderEdit of InputField.
One might need all the preparation stuff that InputField does on
its input but might need something else as its tagName and handle
the input differently.

This commit gets the input preparation code out from the rendering
part of the widget so one can render a widget the way he likes and
call _prepareInput on his input.

This is used in monetary field which requires all the feature of
InputField but with the input actually being one level deeper in
the DOM than the standard InputField.
2017-04-11 19:44:38 +02:00
David Monjoie e17dd719cf [ADD] web: add monetary field documentation 2017-04-11 19:44:38 +02:00
David Monjoie 4eb2245c5d [ADD] web: add phone widget tests and documentation 2017-04-11 19:44:38 +02:00
David Monjoie d218902af5 [ADD] web: add email widget tests and documentation 2017-04-11 19:44:38 +02:00
David Monjoie 90a9a32a91 [ADD] web: add handle widget documentation 2017-04-11 19:44:38 +02:00
David Monjoie 868bcc90ba [ADD] web: add text field documentation 2017-04-11 19:44:38 +02:00
David Monjoie a47c342b9e [ADD] web: add float_time field tests and documentation
The functions for parsing and formatting float_time were completely
duplicated between field_utils and basic_fields.
2017-04-11 19:44:38 +02:00
David Monjoie c22b85dd73 [ADD] web: add float field tests and documentation 2017-04-11 19:44:38 +02:00
David Monjoie 93d09397af [ADD] web: add integer field tests and documentation 2017-04-11 19:44:38 +02:00
David Monjoie 8992b7751c [ADD] web: add boolean field tests and documentation 2017-04-11 19:44:38 +02:00
David Monjoie c7e4ffad4f [ADD] web: add date and datetime fields tests and documentation 2017-04-11 19:44:38 +02:00
David Monjoie 4126c31fda [ADD] web: add char field tests 2017-04-11 19:44:38 +02:00
David Monjoie 86963b5844 [ADD] web: add input field documentation 2017-04-11 19:44:38 +02:00
David Monjoie ef2d5c06ca [IMP] web: mock web.config in place like session
Some fields react differently depending on the values in web.config.
For example, the phone field will display a clickable phone link if
it detects a small screen (e.g. a smartphone) but won't do it on a
bigger screen.

To be able to test fields which react differently depending on the
values in web.config, we need a way to mock it. To do that, we
modify web.config in place with the value given for the test, and
we put back the original config when the field widget is destroyed.
2017-04-11 19:44:38 +02:00
David Monjoie 38300a9bb8 [FIX] web: prevent onchanges from re-rendering the current field
Input fields should not be re-rendered by the onchange mechanism
as they might exhibit formatting that you do not want to have when
typing.

The list view was not propagating the original event to the lower
functions like the form view does, so I added it there.
2017-04-11 19:44:38 +02:00
David Monjoie 160dd6a7e6 [FIX] web: apply digits option from view on float fields
Previously, only the value in the python description of the field
could be used.
2017-04-11 19:44:38 +02:00
Aaron Bohy 6e1875ac7e [FIX] web: MockServer: read_group __domain
read_group returns a __domain for each group, which is the
conjunction of the domain given for the read_group with the domain
matching the given group.

The MockServer didn't reproduce that behavior.

Moreover, the BasicModel did again that conjunction, leading to
domains with redundant subdomains.
2017-04-11 19:44:38 +02:00
qsm-odoo e1b68dae50 [FIX] web, *: fix domain building without CompoundDomain
* board, google_spreadsheet

Commit 8e0c7ccc77f358601b0701536fcb33842ca324a6 got rid of the
CompoundDomain class but did not adapt the code correctly.

- Domains have to be concatened, not regrouped in a big array
- String domains have to be converted to array
- "OR" joining must normalize subdomains first (add explicit "AND"s)
2017-04-11 19:44:38 +02:00
Aaron Bohy f738edb1d6 [FIX] web: list view: right align integer cells 2017-04-11 19:44:38 +02:00
Aaron Bohy b1cb25353b [FIX] web: BasicModel: list count when grouped
Before this rev., the count attribute of list dataPoints was
basically the length of the data Array. It means that for an
ungrouped list, it was the number of records in the list, and for
a list containing groups, it was the number of groups.

This caused a problem in the list view with nested groups, as the
counter in the group header is supposed to display the number of
records in the group, whether or not the group contains other
subgroups or directly records.

This commit changes a bit the semantics of the count attribute,
such that it always represents the number of records inside the
list (i.e. the sums of records inside subgroups if the list is
grouped).
2017-04-11 19:44:38 +02:00