Commit Graph
108790 Commits
Author SHA1 Message Date
Christophe Matthieu ce36786038 [FIX] web: _buildOnchangeSpecs must return only the present fields
Before: the method '_buildOnchangeSpecs' returned all fields, but some
models like 'res.users' have redefined the fields_get and add some fake
fields which cause a crash.
2017-04-11 19:44:38 +02:00
Christophe Matthieu 5e91027a86 [FIX] web: form view must load views for x2many without inline tree arch
* Load views before loading data.
* Load the view used by the mode (by default use kanban for mobile)
* Add attribute useSubview on the widget to load view of the related model
2017-04-11 19:44:38 +02:00
Aaron Bohy 6e6b6ab5f7 [FIX] web: FieldMany2one: focus() is public
The focus() method of the FieldMany2One was private (named
_focus()), but it is called by from outside by the
FieldMany2ManyTags (which called focus(), so it produced a
traceback).
2017-04-11 19:44:38 +02:00
Aaron Bohy 0111882af1 [FIX] web: BasicModel: recursively fetch x2manys
Before this commit, x2many fields embedded in x2many fields were
not fetched. This was for example the case for many2many_tags in
one2many fields.

This commit enables the recursive fetch of x2many fields.

There is still a missing piece, as the list of fields to fetch for
those embedded x2manys is still unknown. This will come in a
future commit.
2017-04-11 19:44:38 +02:00
qsm-odoo 942074557b [REF] web: remove useless resetOnAnyFieldChange option
AbstractField specializations were given an option that allowed them
to tell the system they need to be informed of any change which
occurs in the view (thanks to their reset method).
This is not useful anymore as the new _fetchSpecialData system does
the job a better way.
2017-04-11 19:44:38 +02:00
qsm-odoo 07c581975c [REF] web: use specialData system in domain field
The domain field needs two pieces of information that traditional
fields do not have without extra RPCs and computation: the value of
another field in the view to know the model to use and the number of
records matched in this model with the current field value. While the
first one can be retrieved synchronously by the field widget, the
second one required an extra RPC during the rendering phase.

The `_fetchSpecialData` system introduced in the `BasicModel`
implementation allows to stop doing this extra RPC during rendering.
As the RPC requires the model value to be done, the information
is also fetched by the `_fetchSpecialData` code and given directly
to the widget.

This also removes the utility of the `resetOnAnyFieldChange` option
used by this field widget.
2017-04-11 19:44:38 +02:00
qsm-odoo eb5d65cda7 [REF] web: factorize the special data cache saving code
The _fetchSpecialXXX methods all save values in the _specialDataCache
variable associated to a given record and fieldName. This code is
being regrouped in a private function now.
2017-04-11 19:44:38 +02:00
Aaron Bohy d4fdbad99a [REF] web: kanban: adapt code to new style
This commit adapts some kanban files to the new style and
guidelines.
2017-04-11 19:44:38 +02:00
Aaron Bohy c369b6ec2c [REF] web: kanban: split function _render_ungrouped
This function has to be split, so its behavior can be modified b
the kanban editor (in studio).
2017-04-11 19:44:38 +02:00
qsm-odoo 9636e05bf0 [FIX] web: use correct domain when fetching status values
The m2o choices that a status field works with are determined using the
associated domain. If the current value is not matched by this domain,
the current value should still be visible so the domain is
automatically extended to match this current value. The problem is that
the current value in edit mode or in create mode is not given by the
`data` attribute of the associated datapoint. Indeed, user changes and
default get are stored in the `_changes` key and it is those values
that must be used if they exist.
2017-04-11 19:44:38 +02:00
qsm-odoo 26f91c429c [FIX] web: cannot debounce prototype function of Widget
The `_onClickStage` method of the `FieldStatus` was debounced. This can
be done but not directly on prototype functions because they are shared
between each instances (just called with different `this`). This does
not produced any bug because there never are two instances of this
class which are used at the same time in the web client. The problem is
however present when trying to make tests as clicks on different
statusbar buttons in two different tests were filtered by the
debouncing.
2017-04-11 19:44:38 +02:00
Géry Debongnie aa371a3eff [IMP] web: various small improvements to mock server
* args are json stringified, so we can see in the log what exactly is
  going in the mock server
* better handling of unset fields.  Before this commit, if a field was
  missing in a record, and no default value was set, it was undefined.
  With this commit, it is set to false.  It is important, when we are
  working with domains such as ['some_many2one', '=', false]
* improve read_group so it can group data by day/month
2017-04-11 19:44:38 +02:00
Aaron Bohy 2b61c108dd [FIX] sale: adapt tour to new views
Community and enterprise now share the same codebase for the
statusbar, so the additional selector can be removed.

Moreover, the value of each button in the statusbar is now encoded
in 'data-value' instead of 'data-id'.
2017-04-11 19:44:38 +02:00
qsm-odoo c1256d1453 [FIX] web: record with field status with domain
If a m2o field status has an associated domain, it is used to match
the records to display as status choices. This domain is extended so
that it always matches the current status value. The code which was
in charge of that was buggy when the status had no value (in that
case the domain should not be extended).
2017-04-11 19:44:38 +02:00
Christophe Matthieu fc8cfc5762 [FIX] web: fix crash in one2many in one2many
Before this fix we can not use a one2many field in a list view one2many
field, because the one2many and many2many were not converted to datapoint.
2017-04-11 19:44:38 +02:00
Aaron Bohy d2f6e705a0 [IMP] base_import,web: enable 'Import' feature in Kanban
Applies commit odoo/odoo@dba53fb117 in the new views.

The import feature was only available in List views before this
commit.
2017-04-11 19:44:38 +02:00
Aaron Bohy e7e60331cf [REF] web: test_utils: export removeSrcAttribute()
So that it can be used in every tests, not only those using
createView.

Note: it would be nice to automatically call this function in
addMockEnvironment().
2017-04-11 19:44:38 +02:00
qsm-odoo 29cd7154e6 [FIX] web: restore FieldStatus behavior
FieldStatus was broken:
- With a selection, the statusbar_visible attribute forces the choices
  to display, the discarded ones do not appear at all (even folded)
- With a m2o, the fold_field option tells the field to check in the
  relation to know if the choice has to be folded or not, this was not
  properly supported
- Changing a m2o value was broken as the parseMany2one function did
  not exist
- The status were misordered
- ...

* Also refactor the way the rendering is handled.
* Also modify all statusbar tests so that the statusbar widget is
  placed in the form header tag (as it is the common use case).
2017-04-11 19:44:38 +02:00
qsm-odoo b5b649e5b2 [FIX] web: fetching special data in field widgets
Some field widgets need additional data to render themself. These data
should ideally be fetched in the data fetching phase. In 10.0, these
data were fetched during field rendering which implied that the data
fetching was done sequentially. To limit this effect, before this
commit, these special fields were flagged by the basic view according
to some field properties and the basic model flagged the fields with
the required data. Now, the system has been improved. The field widget
classes can define a key "specialData" which refers to a BasicModel
method. These methods will be used to fetch the required data at the
right time and these data will be available at
`this.record.specialData[this.name]` in the AbstractField instance.

The new system also fixes a bug: the required data was fetched only
at record loading but should in fact be re-fetched at each view
change.
2017-04-11 19:44:38 +02:00
qsm-odoo ba1a2d7145 [FIX] web: DataModel _postprocess was called at a wrong time
The _postprocess method should always be called after _parseServerData,
otherwise the localData between each call is inconsistent for the
relational fields (Array or key pointing to another localData).
2017-04-11 19:44:38 +02:00
qsm-odoo a52690c26c [FIX] web: mock server was replacing "falsy" values with default ones
When setting a field value to "0", the mock server was replacing it
with the field default value as "0" is a falsy value. Now it only
adds the default values where there is no value at all, as expected.
2017-04-11 19:44:38 +02:00
qsm-odoo c24d1f615c [REF] web: make getContext and getDomain part of dataPoints
Before this commit, the getContext and getDomain functions of a
dataPoint were only available from a BasicModel "get" call result.
As the code is moving towards the creation of a DataPoint class,
these two functions should be a part of the dataPoint itself.
2017-04-11 19:44:38 +02:00
qsm-odoo 49f7a9f657 [REF] web, mail: use field registry in views, not renderers
Before this commit, the AbstractField specialization to use to
instantiate a field was determined in the renderers. Now this is
regrouped in BasicView.

Note: renderers are still left free to not use the determined
Class (like Kanban and not editable List which instantiate widgets
only if the "widget" attribute is present).
2017-04-11 19:44:38 +02:00
qsm-odoo 228e18e81a [REF] web, mail: include evaled field options in datapoint
Field options do not depend on any context/data. They can so be
"computed" once and for all in the BasicView implementation instead
of in the AbstractField's one.

Also, remove the flag __always_reload and leave it be in the
options object (always_reload).
2017-04-11 19:44:38 +02:00
Christophe Matthieu 61b09bbe47 [IMP] web: handle required attributes and modifiers in form view 2017-04-11 19:44:38 +02:00
Christophe Matthieu 513dca4726 [FIX] sale: test depend of another module
It may crash when we install only the sale module
2017-04-11 19:44:38 +02:00
Christophe Matthieu f0cfe7c174 [FIX] web: load missing fields when opening form view dialogs
Problem was that sub form field has usually more fields than the list view in
one2many, so we have to load missing fields
2017-04-11 19:44:38 +02:00
Christophe Matthieu 454b215389 [FIX] web: properly transfer field properties
Before this commit, the field properties (attrs, fieldNames, fields)
were not correctly given to sub views in many case

expected:
* use widget many2many on one2many field
* create record when click on save in formDialog
* do not send create command to the server
* use the fields defined in the field node (instead of tree view fields)
* use the fieldNames instead of the record to get field values
2017-04-11 19:44:38 +02:00
Aaron Bohy 53d8d38f93 [IMP] web: test readonly attr on list field's node
This works since a recent commit, which wasn't designed to solve
this issue, as we weren't aware of it.
2017-04-11 19:44:38 +02:00
Aaron Bohy 3f147cbfa0 [FIX] web: list editable: no flicker when editing
The test checking that the cells width remains the same when
entering the edition mode was broken, because we didn't hardcode
the width for readonly cells.

This commit ensures that we force the width of all the cells of
the edited row.
2017-04-11 19:44:38 +02:00
Géry Debongnie 9fb1228b6c [FIX] web: don't display nocontent helper if no help message
Without help message, it looks silly
2017-04-11 19:44:38 +02:00
Aaron Bohy 2d2e9c93c3 [FIX] web_editor: various fixes and new tests
- use 'nodeOptions' instead of 'options' in FieldTextHTML as
  'options' doesn't exist, it has been renamed into nodeOptions
  in AbstractField.
- mock iframe route in test to prevent the test framework from
  displaying an error (unimplemented route), and so the test from
  being red.
- test that the url given in the node options is correctly used.
- remove useless and broken code introduced by last rebase.
2017-04-11 19:44:38 +02:00
Aaron Bohy 7c04deef5e [IMP] web: test_utils: catch iframe src
Trigger an RPC with the corresponding route so that the arguments
specified into the route can be tested.
2017-04-11 19:44:38 +02:00
qsm-odoo 825cd69dc0 [FIX] web: allow to build a domain from a number
Some views were trying to make fields invisible thanks to
`attrs="{'invisible': 1}"`.
This is not supposed to be valid as an attrs value is supposed to be
a domain and not a number. To make the fields always invisible, use
the "invisible" *attribute*. This also allows the client to make the
fields invisible without any domain computation.

However, to keep supporting those kind of attrs and to be more generic,
the Domain class is adapted by this commit to consider numeric domains
to be valid (numbers different than 0 are considered "true" domains and
0 is considered a "false" domain).
2017-04-11 19:44:38 +02:00
qsm-odoo 6da2e588b1 [REF] web: some linting and documentation 2017-04-11 19:44:38 +02:00
qsm-odoo 0a3012cd79 [FIX] web: ace editor field was not properly saving changes
Two changes were ignored:
- The first change
- The last done undo

This commit refactores the field so that:
- The ace setValue function is called only if the value really changed
  (prevent losing focus / undo stack / retrigger "change" event / ...)
- As the ace setValue triggers multiple "change" events, only consider
  the last one
- Same rendering function for edit/readonly modes
- Only listen to "change" events in edit mode
2017-04-11 19:44:38 +02:00
Aaron Bohy 6cf0273427 [FIX] website: formats has been replaced by field_utils 2017-04-11 19:44:38 +02:00
Aaron Bohy f35a44f265 [IMP] web: re-enable commented tests
That code actually works now...
2017-04-11 19:44:38 +02:00
Christophe Matthieu 23f3d95248 [REF] web: factorise some code in BasicModel
Each data information coming from the server was serialized, and need to
be deserialized in the proper format.  This was done in 3 different
places.
2017-04-11 19:44:38 +02:00
Christophe Matthieu cac00211fe [FIX] web: properly transfer options to SelectCreateDialog
The fields_view option was not transferred, resulting in the wrong form
view opened when trying to create a sub record.
2017-04-11 19:44:38 +02:00
Christophe Matthieu 7a1d7cb241 [FIX] web: allow edition of one2many with widget many2many
It is quite rare, but it happens that a one2many field has to be edited
with a many2many widget: it allows the fact that records are directly
created, and only later linked to the main record.  But the BasicModel
only used the field type to determine which commands it had to send.

In this commit, we introduce a magic flag _forceM2MLink, which, if set
to true, tells the BasicModel to treat the field as a many2many.
2017-04-11 19:44:38 +02:00
Géry Debongnie 86a87aa8b0 [REF] *: use _rpc method for all rpcs
The _rpc method is now the preferred method to do a rpc, so we need to
update all calls.
2017-04-11 19:44:38 +02:00
Géry Debongnie 78c97e6cc4 [IMP] web: remove perform(Model)RPC
and replace them with a new, private, _rpc method.  Also, extends the
rpc builder to be able to send arbitrary parameters.
2017-04-11 19:44:38 +02:00
Géry Debongnie 1ec265eb92 [REF] web: move ServicesMixin out of mixins.js 2017-04-11 19:44:38 +02:00
Géry Debongnie 6cc324513e [REF] *: remove mixins from web.core
It is better to directly import web.mixins
2017-04-11 19:44:38 +02:00
Aaron Bohy aa5700bb7c [REF] account_asset: convert widget to new API
Also change the view template as according to the doc, the widget
attribute is only available for field tagnames.
2017-04-11 19:44:38 +02:00
Aaron Bohy 6448568954 [FIX] web: x2many list/kanban views: action buttons
There is no list (resp. kanban) controller for x2many list (resp.
kanban) renderers embedded in form views. So the action buttons
events need to be handled by the form controller. To do so, we
uniformize the event API of 'button_clicked', but the handler
remains specific in each type of controller.
2017-04-11 19:44:38 +02:00
Aaron Bohy cbfdc36ad0 [REF] account_asset,sale: invisible attr in form view
When the invisible attr doesn't need to be evaluated (e.g. = "1"),
it is better not to specify it within the attrs as they are
automacally re-evaluted at each field changed.

We directly write "invisible=1" instead.

The JS framework supports both, but we encourage the later one.
2017-04-11 19:44:38 +02:00
Christophe Matthieu 53e4765765 [FIX] web: catch image in unit test and convert into performRPC
avoid image not found error in console
2017-04-11 19:44:38 +02:00
Christophe Matthieu 04f1e50ff3 [FIX] web: date value must be parsed to moment object 2017-04-11 19:44:38 +02:00