Merge lp:~openerp-dev/openobject-client/6.0-bug-743890-xrg into lp:openobject-client/6.0

Proposed by xrg
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-client/6.0-bug-743890-xrg
Merge into: lp:openobject-client/6.0
Diff against target: 20 lines (+4/-3)
1 file modified
bin/widget/view/list.py (+4/-3)
To merge this branch: bzr merge lp:~openerp-dev/openobject-client/6.0-bug-743890-xrg
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+55563@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

1824. By xrg

view/list.py: handle missing record data at group trees

[Bug 743890] Triggered by: Dr. Ferdinand Gassauer (CampToCamp)

In an attempt to limit the view of (not in stock) products, Dr Gassauer
had overriden the read() method of product.product. Thus returning /less/
records than the ids requested. He did not implement the same logic for
the search() method, however.
This meant that the first level of the tree would indicate parent
categories, with empty children lists. This triggered a fatal crash of the
Gtk client:
  - if the on_iter_children() returns an empty list, we seem to end up in
    a corrupt C-wise stack (pyGtk issue). "None" seems to bail out with a
    modest Gtk error (console) message.
  - on_iter_has_child() has to look at the list of children, not only the
    'has_children' flag, to avoid the expander icon at all.

All this wouldn't have happened, in the first place, without the broken
module. But we'd better let the Gtk client survive in this case, too.
(cherry picked from commit 944766b835530be3e3e96150e044705639ab00ea)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/widget/view/list.py'
2--- bin/widget/view/list.py 2011-01-17 20:28:40 +0000
3+++ bin/widget/view/list.py 2011-03-30 15:03:12 +0000
4@@ -310,12 +310,13 @@
5 return None
6
7 def on_iter_has_child(self, node):
8- res = getattr(node,'has_children', False)
9- return res
10+ if not getattr(node,'has_children', False):
11+ return False
12+ return len(node.children) > 0
13
14 def on_iter_children(self, node):
15 res = getattr(node, 'children', [])
16- return res and res[0] or []
17+ return res and res[0] or None
18
19 def on_iter_n_children(self, node):
20 return len(getattr(node, 'children', []))