Merge lp:~numerigraphe/openobject-client/6.x-o2m-focus-reset into lp:openobject-client

Proposed by Numérigraphe
Status: Needs review
Proposed branch: lp:~numerigraphe/openobject-client/6.x-o2m-focus-reset
Merge into: lp:openobject-client
Diff against target: 68 lines (+19/-3)
4 files modified
bin/widget/model/record.py (+1/-1)
bin/widget/screen/screen.py (+2/-2)
bin/widget/view/form_gtk/one2many_list.py (+1/-0)
bin/widget/view/list.py (+15/-0)
To merge this branch: bzr merge lp:~numerigraphe/openobject-client/6.x-o2m-focus-reset
Reviewer Review Type Date Requested Status
OpenERP sa GTK client R&D Pending
Review via email: mp+138148@code.launchpad.net

Description of the change

If you perform an action on a form requiring it to reload (for example click a button), every o2m widget is reset to its first record.
This branch fixes this by setting the focus back to the previously selected record after reloading.
The patches were developed in private as part of our paid support agreement, but we're willing to have them publicly available.
Lionel Sausin.

To post a comment you must log in.

Unmerged revisions

1792. By Chris Biersbach (OpenERP)

[FIX] Fix latest improvement in cases where the o2m field has more lines than can be displayed at once

1791. By Chris Biersbach (OpenERP)

[IMP] Keep the current selection in o2m tree views when parent record is reloaded

1790. By Chris Biersbach (OpenERP)

[IMP] Keep the current selection in o2m forms when parent record is reloaded

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/widget/model/record.py'
2--- bin/widget/model/record.py 2012-02-28 09:14:42 +0000
3+++ bin/widget/model/record.py 2012-12-05 13:42:22 +0000
4@@ -400,7 +400,7 @@
5 else:
6 raise Exception, 'Unallowed button type'
7 if screen.current_model and screen.current_view.view_type != 'tree':
8- screen.reload()
9+ screen.reload(res_id=id)
10
11 del screen
12
13
14=== modified file 'bin/widget/screen/screen.py'
15--- bin/widget/screen/screen.py 2012-05-18 10:11:32 +0000
16+++ bin/widget/screen/screen.py 2012-12-05 13:42:22 +0000
17@@ -754,11 +754,11 @@
18 return True
19 return False
20
21- def reload(self):
22+ def reload(self, res_id=None):
23 self.current_model.reload()
24 if self.parent:
25 self.parent.reload()
26- self.display()
27+ self.display(res_id=res_id)
28
29 def remove(self, unlink = False):
30 id = False
31
32=== modified file 'bin/widget/view/form_gtk/one2many_list.py'
33--- bin/widget/view/form_gtk/one2many_list.py 2011-12-12 07:10:21 +0000
34+++ bin/widget/view/form_gtk/one2many_list.py 2012-12-05 13:42:22 +0000
35@@ -407,6 +407,7 @@
36 name = str(signal_data[0] + 1)
37 line = '(%s/%s of %s)' % (name, signal_data[1], signal_data[2])
38 self.label.set_text(line)
39+ self.pager.set_sensitivity()
40
41 def _sig_refresh(self, *args):
42 pass
43
44=== modified file 'bin/widget/view/list.py'
45--- bin/widget/view/list.py 2011-11-29 09:00:41 +0000
46+++ bin/widget/view/list.py 2012-12-05 13:42:22 +0000
47@@ -592,6 +592,21 @@
48 if self.screen.parent and isinstance(self.screen.parent, ModelRecord):
49 self.screen.parent.reload()
50 current_active_model.reload()
51+ # we force setting current_model here to avoid tree view blinking
52+ # (cause by view selecting the 1st record, then re-displaying itself,
53+ # then selecting real active record)
54+ self.screen.current_model = current_active_model
55+ if selection.get_mode() == gtk.SELECTION_MULTIPLE:
56+ path_active_model = self.store.on_get_path(current_active_model)
57+ if path_active_model not in paths:
58+ # clicked row is not in active selection,
59+ # select only the current row
60+ selection.select_path(path_active_model)
61+ else:
62+ # keep current rows selected
63+ for path in paths:
64+ selection.select_path(path)
65+ self.widget_tree.scroll_to_cell(path_active_model)
66
67 else:
68 # Here it goes for right click