Reopening a record from a O2M removes previously set data
In a wizard record (A) I have a O2M that contains a record (B). This record contains two O2M on the same model, the first one is set using a list of ids, the second one is set using a list of values. On opening the B record, the value from the first O2M are fetched in order to be displayed.
I then cancel the window and reopen it. The values that have been fetched has been removed from the record.
What happens is that in https://foss.heptapod.net/tryton/tryton/-/blob/edb0c6830caf2969f53d7f1c82337841c374081b/tryton/tryton/gui/window/win_form.py#L440 we're resetting the record to the _initial_value
. This value is computed by getting, while the WinForm
initialization, the record's get_on_change_value
. For the O2M of B, it means the list of their record values. Thus for the O2M set by a list of ids, it will result in the list [{'id': an_id}]
.
Resetting the record to this value, will remove the data of all the other fields that we fetched earlier.
I still don't have a convincing way to solve this. Currently my best solution is to check that the case 'list values'
is not a degenerated case where the values are dicts with only an id
key. But it's not very satisfactory.