Crash on display of One2Many with current record removed by on_change
For example on production when clicking on "Reset to BOM", if the input or output moves are not yet saved, the on_change result remove them. And if the one of the removed move was the current record, the display of the list can not compute the path to select it again. Here is the traceback:
ERROR:tryton.common.common: File "/home/ced/Projects/tryton/tryton/tryton/gui/window/view_form/view/form.py", line 610, in button_clicked
self.screen.button(widget.attrs)
File "/home/ced/Projects/tryton/tryton/tryton/gui/window/view_form/screen/screen.py", line 1260, in button
self._button_instance(button)
File "/home/ced/Projects/tryton/tryton/tryton/gui/window/view_form/screen/screen.py", line 1272, in _button_instance
record.set_on_change(changes)
File "/home/ced/Projects/tryton/tryton/tryton/gui/window/view_form/model/record.py", line 547, in set_on_change
self[fieldname].set_on_change(self, value)
File "/home/ced/Projects/tryton/tryton/tryton/gui/window/view_form/model/field.py", line 849, in set_on_change
group.record_modified()
File "/home/ced/Projects/tryton/tryton/tryton/gui/window/view_form/model/group.py", line 530, in record_modified
self.parent.group.record_modified()
File "/home/ced/Projects/tryton/tryton/tryton/gui/window/view_form/model/group.py", line 525, in record_modified
screen.record_modified()
File "/home/ced/Projects/tryton/tryton/tryton/gui/window/view_form/screen/screen.py", line 450, in record_modified
self.display()
File "/home/ced/Projects/tryton/tryton/tryton/gui/window/view_form/screen/screen.py", line 986, in display
view.display()
File "/home/ced/Projects/tryton/tryton/tryton/gui/window/view_form/view/form.py", line 560, in display
widget.display()
File "/home/ced/Projects/tryton/tryton/tryton/gui/window/view_form/view/form_gtk/one2many.py", line 587, in display
self.screen.display()
File "/home/ced/Projects/tryton/tryton/tryton/gui/window/view_form/screen/screen.py", line 986, in display
view.display()
File "/home/ced/Projects/tryton/tryton/tryton/gui/window/view_form/view/list.py", line 1160, in display
path = Gtk.TreePath(current_record.get_index_path(model.group))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ced/Projects/tryton/tryton/tryton/gui/window/view_form/model/record.py", line 264, in get_index_path
path.append(record.group.index(record))
^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: <Record -9@stock.move at 139867361008176> is not in list