Issue 9719

Title
Lack of data in _init_values result in an inconsistent behaviour in the client
Priority
bug
Status
resolved
Superseder
Clients fail to apply changes on not loaded xxx2Many (issue 9730)
Nosy list
ced, nicoe, reviewbot, roundup-bot
Assigned to
ced
Keywords
review

Created on 2020-10-14.20:07:44 by nicoe, last changed 4 days ago by roundup-bot.

Files

File name Uploaded Type Details
m2m_changed.tgz nicoe, 2020-10-15.23:59:49 application/x-gtar-compressed view

Messages

New changeset aa009504cd6b by Cédric Krier in branch 'default':
Fallback to stored values to compute changed xxx2Many
https://hg.tryton.org/tryton-env/rev/aa009504cd6b
New changeset b307bd41f89d by Cédric Krier in branch 'default':
Fallback to stored values to compute changed xxx2Many
https://hg.tryton.org/trytond/rev/b307bd41f89d
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2020-10-16.17:39:24
And here is the issue9730 for applying changes on non loaded field.
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2020-10-16.17:34:56
For me we must use the stored data to compute the changed values when the client did not send any values. Here is review308391002 which only change the ModelView._changed_values.
Author: [hidden] (nicoe) Tryton committer
Date: 2020-10-15.23:59:49
Here's a module displaying the behaviour
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2020-10-15.12:58:05
I think we have two issues here. This one which is the bad computation of the on_change result. And a second one (which should not be related) which is the application of the on_change value on a One2Many that the client has not yet loaded (this case could happen also on non-nested models). I would prefer to have a separate issue for the second case.
Author: [hidden] (nicoe) Tryton committer
Date: 2020-10-14.20:07:44
This one is a bit tricky to explain (the patch might be an easier way to grasp the issue than this description).

We have three models: A contains a o2m to B which contains a m2m to C.
A field of A has an on_change setting in the m2m of B some new value.
The result of the call to the on_change is something like {'b': {'update': {'c': {'add': values}}}.

In the case B has never been opened in A's form this is the correct value. But if B has already been opened then its C m2m will have been fetch and the on_change call will result in only addition of records (while there might be substraction of some).

The way I found to fix this is that we should fill _init_values as soon as we have the chance to do so. That way when computing the changed_values it will send the right modifications to the client.

Unfortunately in order to apply those modifications the C value must be loaded on the client side before applying the on_change value received (hence the impact on tryton and sao).

(Moreover it's a bit tricky to find the right place where to define the test for this behaviour as it's both a mix of ModelStorage and ModelView).
History
Date User Action Args
2020-10-21 23:28:43roundup-botsetmessages: + msg61137
2020-10-21 23:28:39roundup-botsetmessages: + msg61136
nosy: + roundup-bot
status: testing -> resolved
2020-10-16 19:39:27reviewbotsetmessages: + msg61013
2020-10-16 18:36:13reviewbotsetnosy: + reviewbot
messages: + msg61007
2020-10-16 18:36:13reviewbotsetreviews: 316191030 -> 316191030, 308391002
2020-10-16 17:39:24cedsetreviews: 316191030, 308391002 -> 316191030
nosy: - reviewbot
superseder: + Clients fail to apply changes on not loaded xxx2Many
messages: + msg61002
2020-10-16 17:38:04reviewbotsetnosy: + reviewbot
messages: + msg61000
2020-10-16 17:38:03reviewbotsetreviews: 316191030 -> 316191030, 308391002
2020-10-16 17:34:56cedsetstatus: chatting -> testing
assignedto: nicoe -> ced
messages: + msg60999
2020-10-15 23:59:49nicoesetfiles: + m2m_changed.tgz
messages: + msg60979

Showing 10 items. Show all history (warning: this could be VERY long)