~bstanciu/openobject-client-web/bstanciu@openerp-web

Viewing all changes in revision 1505.

  • Committer: Xavier Morel
  • Date: 2011-11-17 16:14:26 UTC
  • Revision ID: xmo@openerp.com-20111117161426-72jzhvv3dm387uom
[FIX] synchronization of o2m widget saving, avoid race condition when clicking on button of unsaved record

After saving, the formview would both refresh the form and lauch the
action itself, which launches a refresh of its own.

Issue is that o2m's filling of themselves (a read) is async and
triggered by the set_value on the o2m field, so the second reload of
the form would be interspersed (between the first reload and the end
of the o2ms loading), resulting in corrupted state for the o2ms if the
button's action somehow changed the contents of the o2m (it would
remove the old records and return brand new ids during the refresh):
the set_value on the o2m would empty the o2m's dataset cache, and the
returning fetch request would try to find in cache values removed from
it, or something, blowing up everything.

Anyway, this was fixed by ensuring the button action is only executed
after the form is completely done doing its post-save reload (using
the new async set_value). This is a tiny bit brittle in that onchanges
are synchronous but call set_value, so a set_value on an o2m from an
onchange may have issues. It also increases the flicker of the view,
as the o2m is reloaded twice in quick succession.

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: