Commit Graph
201 Commits
Author SHA1 Message Date
Christophe Simonis e00a447e2c [MERGE] forward port branch saas-11.1 up to 7e469eb77a 2018-02-01 18:20:28 +01:00
Christophe Simonis 7e469eb77a [MERGE] forward port branch 11.0 up to f5e7b86686 2018-02-01 18:15:21 +01:00
Lucas Perais (lpe) 9fa597c7ec [FIX] web: sequence handlers on modal's one2many list
From a form view (say Bill of materials)
Edit the form
Click on a bom line
Click on the external button that makes the product form pop up
change the order of suppliers on that product

Before this commit, a JS traceback was raised
This was because the changing object was not present in the localData that the Model object holds
or more accurately, it was not the **right** model object that was targetted
and this was due to the propagation of the resequence event

After this commit, no error is thrown, and the resequencing works as expected

OPW 807196
2018-02-01 13:53:52 +01:00
Christophe Simonis 88a87240a6 [MERGE] forward port branch saas-11.1 up to 8613724bfc 2018-01-25 17:38:41 +01:00
Christophe Simonis cb50970f3f [MERGE] forward port branch 11.0 up to eefe879a37 2018-01-25 15:41:45 +01:00
Martin Geubelle 2d3ecf29b3 [FIX] web: handle nested x2m default values
A `default_get` for a x2many field can return a new list of commands for one of
its x2many field, like

[[0, 0, {
    'groups_id': [[6, 0, [1, 2, 3]]],
}]]

where [1, 2, 3] is a list of existing ids.

This use case was not correctly handled by the BasicModel because
`_makeDefaultRecord` was not recursive.

Closes #22401
2018-01-24 10:59:45 +01:00
Christophe Simonis 1d394bbee3 [FIX] web: adapt test 2018-01-22 19:19:59 +01:00
Christophe Simonis a98b46b8f5 [MERGE] forward port branch saas-11.1 up to fa1f2132e7 2018-01-22 18:44:05 +01:00
Christophe Simonis fa1f2132e7 [MERGE] forward port branch 11.0 up to 950d9b2369 2018-01-22 17:47:32 +01:00
Géry Debongnie 1bb6887bb6 [FIX] web: fix crash when creating record with too many default values
When creating a record with many default values, it could happen that
the number of ids returned by the default get (or onchange) exceeds the
limit for the form view.

For example, we can see the issue in the expenses list view.  We can
increase the limit in the pager, to a value higher than 40.  Then,
clicking on select all, then on 'Submit to manager' in the action menu
will result in a traceback.

The Submit to manager action will trigger a new action with a context key
'active_ids' with a large number of ids.  After that, the web client
will execute the server actions, which will return a new action with a
context key 'default_expense_line_ids' with a bunch of ids.  Then, it
will attempt to create a form view.  This will call the
makeDefaultRecord method in the basic model.  This method will generate
the commands for the one2many, for all ids, but will only load the 40
first sub records.  After, it will attempt to apply the onchanges, with
some code that assumes that all operations of type 'ADD' correspond to a
local datapoint.

In this commit, we fix the code to properly work with operations of type
ADD with a res_id, but with no id. In that case, we simply generate a
command 'LINK_TO', since the value has not been changed.

opw 804370
2018-01-18 14:13:34 +01:00
Géry Debongnie ca2060048e [FIX] web: fix issue with multiple pages and relational fields
When fetching x2manys in a x2many, the basic model did not properly sort
the internal data structure before fetching the data.  This is usually
not an issue, except when we have an order which is different from the
order of the res_ids.  In that case, it can cause crash in some
conditions, because the results from the fetchx2manybatched were applied
to the wrong datapoint.

To reproduce this issue, some specific conditions needs to be met. I
think that it is easier to refer to the test, instead of trying to
explain that.

In this commit, we properly sort the data at the correct place. Note
that this probably solves a bunch of other related issues, caused by the
fact that the internal structure was corrupted.
2018-01-17 14:26:37 +01:00
Alexandre Kühn 290e247e82 [FIX] web: remove dead code
Cleaning dead code from these commits that have been reverted:

41fe7f9d1113d026b226b136b4477aaaf9f1f638#diff-54fd886cc58f994ad518ee72df4d3edeR50
2a5488619da22cfd901963dd141e722b195e82ab#diff-f96b339a9374f74489f1f98755e9787bL9253
41fe7f9d1113d026b226b136b4477aaaf9f1f638#diff-86d6d41b5bb7499bf055258d05549d59R3111

With these final changes, we hope to stop the many issues that have occured with
binary fields, from these commits:

255e8ca3d9
7813a8e714
41fe7f9d11
2a5488619d

What remains is the format of binary fields in list views without widgets,
which shows the bin_size instead of the base64 string representation...

... Rest assured, the computation is in JS, so there are no 'bin_size'
shenaningans!
2018-01-17 11:23:23 +01:00
Christophe Simonis b3f44032c1 [FIX] web: adapt test to new dom structure 2018-01-15 15:48:45 +01:00
Alexandre Kühn 2a5488619d [FIX] web: disable {bin_size: true} on binary fields
Revision on 41fe7f9d11

This commit intended to reduce the network load when reading records with
binary fields. This was made possible by enforcing the contextual key
`bin_size` to be set for records with binary fields.

However, it is causing some issues (see #22222, #22231) which are:
    - write with bin_size:true generates a traceback
    - read/search_read with bin_size:true breaks some images
      on some views (e.g. base.view_partner_form)

Since the problems outweight the gain of these changes, we revert them.
2018-01-15 10:03:14 +01:00
Christophe Simonis 03a36a9bba [MERGE] forward port branch saas-11.1 up to 56974322f8 2018-01-12 19:13:10 +01:00
Christophe Simonis 56974322f8 [MERGE] forward port branch 11.0 up to 3b80a059ff 2018-01-12 19:03:00 +01:00
Alexandre Kühn 41fe7f9d11 [FIX] web: contexts on field widgets + enforce bin_size for binary
Field widgets now have a key 'context' that let them
extend the context of the dataPoint (e.g. list).

In particular, widgets on binary fields enforce the contextual
item {bin_size: True}, so that the server gives the size of the
binary field as its value, instead of its content.

This change on binary fields reduces network load when accessing
a view with binary fields.
2018-01-12 16:12:49 +01:00
Géry Debongnie 27dd19c0b9 [FIX] web: prevent crash in some rare cases
When we have a form view with a one2many with an onchange, and with
lines which contains a x2many, and more lines that the limit (so more
than one page), and the read is not in the same order as what is
displayed because we have a widget=handle, then we might have a problem
when we delete one of the lines, if the onchanges tries to change the
x2many.

This is due to the fact that the order of the basicmodel datapoint is
not preserved by the various operations going around.  I think that we
may still have a few other issues of this type, but it is actually quite
difficult to establish.

In any case, this situation is now properly handled.

opw 804530
2018-01-11 16:30:34 +01:00
Christophe Simonis 782154da11 [MERGE] forward port branch saas-11.1 up to f6ef0c7760 2018-01-10 20:35:53 +01:00
Christophe Simonis 228ecdbe28 [MERGE] forward port branch 11.0 up to ff0abd214c 2018-01-10 11:41:35 +01:00
Christophe Simonis a7c2a22310 [FIX] web: adapt new test introduced by previous forward-port 2018-01-09 17:58:06 +01:00
Christophe Simonis 6e25eb9b05 [MERGE] forward port branch saas-16 up to 4c410ee6a1 2018-01-09 17:03:07 +01:00
Christophe Matthieu d4982394bc [FIX] web: speed resequence up in x2m
Resequencing a x2m is very slow because the view is reloaded after each
change instead of only once after all the changes.
2018-01-05 17:34:26 +01:00
Christophe Matthieu 73e2ba991c [FIX] web: add a stableSort method for sorting x2m
Issue: create 60 lines in ordered x2many with the same value (0) for the order
field and make a change ; the displayed records will be switched.

The problem appears because the sorting function is not stable and the
records with the same values can change place (hence change page), which is
quite disturbing for the user.
2018-01-05 17:34:25 +01:00
Christophe Matthieu b7ee1aa4b1 [FIX] web: sort and onchange in tabbed editable x2m
Two attempts of dealing with sorting (and resequencing) in tabbed (multi-pages)
x2many editable lists (see odoo/odoo@c2563db and odoo/odoo@983c7ae) have been
previously done, using a static attribute (`keepChangesUnsorted`) on the
datapoint.

This solution sadly only covers both cases separately, not if they are combined.
Morever, onchanges were not correctly managed in neither of these two cases.

A new approach is used here, by "freezing" and "unfreezing" the datapoint when
needed, which is more flexible.

Some modifications have been introduced:
 - when ordering a x2many, all records are now considered (and not only the
   records on the current page) ; an additional read is thus done on the sorted
   field for all records in the x2many relation
 - `setSort` is now asynchronous as a `read` might be needed
2018-01-05 17:34:25 +01:00
Géry Debongnie 1efc9d0b5e [FIX] web: transfer attributes to subnodes in list views
In many cases, we allow class and style attributes in the arch of a
view.  However, it did not work in a list view, and there is not really
a good reason for that (only cost is a few runtime checks).

So, with this commit, we allow those attributes in list views (and
x2manys obviously).

However, note that there is a subtle (maybe slightly confusing)
behavior: when a list renderer is in 'readonly' mode, it does not
actually instantiate any field widgets.  In that case, it optimizes the
rendering by putting only the formatted value inside a cell:

<td>some value</td>

So, in that case, the only valid target for the attributes is the td:

<td class="hello">some value</td>

But when we are in edit mode, we actually have a field widget inside a
td:

<td><input>some value</input></td>

And in that case, the natural home for the attributes is the field
widget.  This is quite important, because this is the way attributes are
done in the form view, and we do not want different behaviour.

<td><input class="hello">some value</input></td>
2018-01-05 14:42:55 +01:00
Christophe Simonis 55b810dc70 [MERGE] forward port branch saas-11.1 up to 726b91b9fb 2018-01-03 14:05:48 +01:00
Stéphane Bidoul (ACSONE) bb10cd50c2 [FIX] web: issue with id field in x2m form
When the 'id' field is present in a x2m form, the x2m actions generated
on create of the parent object are incorrect.
2018-01-03 13:22:09 +01:00
Christophe Simonis 362f0489d0 [MERGE] forward port branch 11.0 up to fe22a0f9ca 2018-01-03 12:28:52 +01:00
Alexandre Kühn 8bc7cebd9c [IMP] web: many2many editable list with X remove icon (#20978)
In many2many lists, the remove record from the widget is a trash bin.
It is confusing, as people feel they are deleting it when they are
only unlinking it.

So in many2many, we propose to change the trash icon by a 'X'.

This icon appears in many2many relations and in many2many widgets:
even though hr.expense.sheet defines the expense lines as a one2many,
it uses a many2many widget, so we use a 'X' instead of the trash bin.

To avoid ambiguity, we decided to rename 'delete' to 'remove'.
2018-01-03 11:42:39 +01:00
Sanjay Jamod a8527a16b6 [FIX] web: Fix column_invisible issue (#21693)
[FIX] web: Fix column_invisible issue

This commit fixes an issue with the column_invisible attribute.

When we choose product variant for BOM for any particular product, 
at that time from the BOM Lines column "Apply on Variants" is hidden,
but when we unset product variant from BOM Form, 
at that time the column 'Variants" set to visible. but in this case, it is set to hidden always.

PR 21693, OPW 779555
2018-01-02 16:37:35 +01:00
Sanjay Jamod 0c1fc0b911 [FIX] web: Fix column_invisible issue (#21693)
[FIX] web: Fix column_invisible issue

This commit fixes an issue with the column_invisible attribute.

When we choose product variant for BOM for any particular product, 
at that time from the BOM Lines column "Apply on Variants" is hidden,
but when we unset product variant from BOM Form, 
at that time the column 'Variants" set to visible. but in this case, it is set to hidden always.

PR 21693, OPW 779555
2018-01-02 16:33:45 +01:00
Christophe Matthieu 091c86c21b [FIX] web: unselect row before resequencing in editable list
If a row is being edited, this row will be refocused when performing changes
(i.e. resequencing records). It can cause an issue if an onchange modifies the
record being focused.

To avoid this issue, the row is unselected before resequencing records. The row
isn't selected anymore but this behaviour wasn't expected anyway.
2017-12-28 12:08:12 +01:00
Christophe Matthieu 1c7e0df5a5 [FIX] web: deal with same sequence in editable list
Resequencing records with the same sequence wasn't correctly working in the
editable list because we only care about the range between the swapped ids. In
some cases, this isn't good enough.

For example, if we have the records 1,2,3 with sequence field = 10,10,10, then,
swapping records 1 and 2 should lead to resequencing 3 with the sequence values
11,10,12 (to guarantee that the third item is after the previous 2).

Resequence now checks if the list increases or decreases without interruption
to create the subset that must be changed ; otherwise the whole list is changed.
2017-12-28 12:05:25 +01:00
Géry Debongnie dbdd742d20 [FIX] web: better mode handling, prevent useless work in some cases
Before this commit, the way mode was handled was not optimal.  The end
result was correct (the widget were properly created/displayed in
edit/readonly as required), but useless work was done.  In particular,
if we have list/x2manys with widgets and modifiers, it could happen that
widgets were created in edit mode, then destroyed and recreated in
readonly mode.

This could happen in some important views, for example, any view with a
field many2many_tags with a readonly modifiers (pretty much all views
handling taxes)

In this commit, we add a 'editable' attribute to list renderer.  This is
necessary, because the list renderer is not actually editable when it is
in a x2many in a form view which is in readonly mode.  Also, we need to
manage the distinction between the fact that a list view is editable,
and the fact that some widgets are created in edit and other in readonly
mode, depending on modifiers, and on which line is being edited.

We also add a benchmark (courtesy of CHM) to be able to measure the
performance impact of edit/readonly/onchange in a larger form view.
Before this commit, running this form benchmark on my machine gave a
number of 0.4 op/sec, and after, it increases to 1.26 op/sec, so a
pretty large improvement.
2017-12-18 17:29:14 +01:00
Géry Debongnie fa9f58d6ce [IMP] web: tests: add a way to properly mock Widgets
This rev. introduces two helper functions for the tests: patch
and unpatch. Those function allow patching an Odoo Widget (e.g.
AbstractField), and unpatch it at the end of the test with the
guarantee that the Widget's prototype is exactly the same as it
was before the test.

This was necessary because the way it was done before was a little
bit too naive, and could lead to unexpected behavior. Indeed, doing

 var someFunction = AbstractField.prototype.someFunction;
 // test content
 AbstractField.prototype.someFunction = someFunction;

is correct if someFunction is actually define (or overriden) in
AbstractField, as in that case, it really exists on its prototype.
Otherwise, it isn't correct if it is not directly defined on the
prototype before the test, as it will be after..
2017-12-18 17:29:13 +01:00
Géry Debongnie 377705aada [IMP] web: tests: add a way to properly mock Widgets
This rev. introduces two helper functions for the tests: patch
and unpatch. Those function allow patching an Odoo Widget (e.g.
AbstractField), and unpatch it at the end of the test with the
guarantee that the Widget's prototype is exactly the same as it
was before the test.

This was necessary because the way it was done before was a little
bit too naive, and could lead to unexpected behavior. Indeed, doing

 var someFunction = AbstractField.prototype.someFunction;
 // test content
 AbstractField.prototype.someFunction = someFunction;

is correct if someFunction is actually define (or overriden) in
AbstractField, as in that case, it really exists on its prototype.
Otherwise, it isn't correct if it is not directly defined on the
prototype before the test, as it will be after..
2017-12-15 13:07:34 +01:00
Christophe Simonis 4708812b6c [MERGE] forward port branch 11.0 up to b37cc1f9b7 2017-12-12 18:50:59 +01:00
Christophe Simonis b37cc1f9b7 [MERGE] forward port branch saas-16 up to a2ea4ba095 2017-12-12 18:39:43 +01:00
Adrien Dieudonne 35c4057422 [FIX] web: FieldMany2One: don't re-render if dirty
The 'main_flow_tour' noticed an error that we
had already corrected for the input fields.
See here: @a71f2237

In fact the same error can occur in the many2one fields
for the exact same reason.
It's why the 'main_flow_tour' crashed at the following step:
".ui-menu-item > a:contains('the_flow.customer')"
2017-12-11 10:17:15 +01:00
Lucas Perais (lpe) 6c024d1ef0 [FIX] web: give context to fetch x2m batched
Before this commit M2Mtags widget did not translate.
This was because no context was given to the rpc that fetched the fields
Hence, the lang was not passed.

After this commit, M2Mtags translate well

OPW 784396
2017-12-11 08:32:04 +01:00
Géry Debongnie 3b3f68030d [FIX] web: send proper context when fetching m2o namegets
When fetching batched namegets (typically after a default_get), we need
to evaluate the context that we send to the server.  This may be
important for models with a custom name_get method. (note: overriding
namegets should be avoided if possible)

With the new views refactoring, this was not done properly and the
'view' context was sent instead.  This is not really critical, the proof
is that it took a few months before getting some complaints, but this is
definitely a bug.

To reproduce, simply add a context attribute to a m2o field in a form
view, with a non empty value in a default get, and look at the context
sent to the server.
2017-12-07 16:20:46 +01:00
Christophe Simonis 2b957f8d01 [FIX] web: correct test 2017-11-28 18:58:09 +01:00
Christophe Simonis 29590a61cd [MERGE] forward port branch 11.0 up to 8fb25e185b 2017-11-28 16:57:58 +01:00
Christophe Simonis 5851a69aa3 [MERGE] forward port branch saas-16 up to 3f66814a0d 2017-11-28 15:12:31 +01:00
Aaron Bohy baae272ffd [REF] web: tests: make load_views RPCs go through mockRPC
This allows to inspect those RPCs and the given arguments as well.
2017-11-23 11:00:53 +01:00
Géry Debongnie 6cd17d575c [FIX] web: properly refetch x2manys in some cases
Consider the following situation: a form view with a one2many which
contains sub x2many fields (for example a m2m_tags). Suppose that the
one2many has more than 40 records.  Before this commit, trying to delete
one of these records caused a crash.

The reason is that when we delete a record, we need to reload the
missing records in the one2many field.  We actually do that with a
_readUngroupedList.  However, the _readUngroupedList method did not
process x2many fields, so the information stored in the datapoints was
'raw', and the rest of the web client expected it to be a datapoint.

To reproduce the issue in the testing environment, i had to use
onchanges and a readonly attrs, to reach a situation where a crash could
occur.  This shows that, while the issue is critical, it was not totally
trivial to be impacted by it.
2017-11-20 11:05:46 +01:00
Géry Debongnie 5d1640edff [FIX] web: add support for limit attr in arch in sub tree view
Before this commit, the 'limit' attribtue worked properly for list views
(but was not documented), and was ignored for inline tree views.  There
was no good reason for that limitation, so we fix this issue.
2017-11-20 11:05:41 +01:00
Alexandre Kühn 23e6dd36d7 [IMP] web: hide in kanban tag's color (#20815)
New feature:

   - New Transparent tag visual (grey border & text, white bg),
   - By default, newly created kanban tags are transparent,
   - Tag's colorpicker has now a 'Hide in Kanban' checkbox,
     to select the transparent color.

Toggling off 'Hide in Kanban' sets the color of the tag as follow:

   - Previous color, if 'Hide in Kanban' was toggled on on the
     same formview session.
   - Color 1 (dark orange), otherwise.
2017-11-20 10:47:43 +01:00
Christophe Simonis a094f6318b [MERGE] forward port branch saas-16 up to 745d00362a 2017-11-16 12:40:36 +01:00