Merge lp:~openerp-dev/openerp-web/7.0-bug-1183156-bth into lp:openerp-web/7.0

Proposed by Bhumi Thakkar (Open ERP)
Status: Merged
Merged at revision: 4018
Proposed branch: lp:~openerp-dev/openerp-web/7.0-bug-1183156-bth
Merge into: lp:openerp-web/7.0
Diff against target: 74 lines (+13/-12)
2 files modified
addons/web/static/src/js/view_tree.js (+11/-11)
addons/web/static/src/xml/base.xml (+2/-1)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/7.0-bug-1183156-bth
Reviewer Review Type Date Requested Status
Martin Trigaux (OpenERP) (community) Approve
Review via email: mp+173194@code.launchpad.net

Description of the change

Hello,

    In any tree view, the descendants are not unique, e.g. with multi-level BOMs that have the same components. At that time treeview behaved wrong. It does not show/hide selected parent's children.

Thanks.

To post a comment you must log in.
Revision history for this message
Martin Trigaux (OpenERP) (mat-openerp) wrote :

LGTM, thanks for the patch

revno: 4018 [merge]
revision-id: <email address hidden>

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/web/static/src/js/view_tree.js'
2--- addons/web/static/src/js/view_tree.js 2012-12-13 14:09:14 +0000
3+++ addons/web/static/src/js/view_tree.js 2013-07-05 12:22:27 +0000
4@@ -163,12 +163,13 @@
5 var is_loaded = 0,
6 $this = $(this),
7 record_id = $this.data('id'),
8+ parent_id = $this.data('parent-id'),
9 record = self.records[record_id],
10 children_ids = record[self.children_field];
11
12 _(children_ids).each(function(childid) {
13- if (self.$el.find('#treerow_' + childid).length) {
14- if (self.$el.find('#treerow_' + childid).is(':hidden')) {
15+ if (self.$el.find('[id=treerow_' + childid + '][data-parent-id='+ record_id +']').length ) {
16+ if (self.$el.find('[id=treerow_' + childid + '][data-parent-id='+ record_id +']').is(':hidden')) {
17 is_loaded = -1;
18 } else {
19 is_loaded++;
20@@ -180,7 +181,7 @@
21 self.getdata(record_id, children_ids);
22 }
23 } else {
24- self.showcontent(record_id, is_loaded < 0);
25+ self.showcontent($this, record_id, is_loaded < 0);
26 }
27 });
28 },
29@@ -201,9 +202,9 @@
30 'fields': self.fields,
31 'level': $curr_node.data('level') || 0,
32 'render': instance.web.format_value,
33- 'color_for': self.color_for
34+ 'color_for': self.color_for,
35+ 'parent_id': id
36 });
37-
38 if ($curr_node.length) {
39 $curr_node.addClass('oe_open');
40 $curr_node.after(children_rows);
41@@ -243,14 +244,13 @@
42 },
43
44 // show & hide the contents
45- showcontent: function (record_id, show) {
46- this.$el.find('#treerow_' + record_id)
47- .toggleClass('oe_open', show);
48-
49+ showcontent: function (curnode,record_id, show) {
50+ curnode.parent('tr').toggleClass('oe_open', show);
51 _(this.records[record_id][this.children_field]).each(function (child_id) {
52- var $child_row = this.$el.find('#treerow_' + child_id);
53+ var $child_row = this.$el.find('[id=treerow_' + child_id + '][data-parent-id='+ curnode.data('id') +']');
54 if ($child_row.hasClass('oe_open')) {
55- this.showcontent(child_id, false);
56+ $child_row.toggleClass('oe_open',show);
57+ this.showcontent($child_row, child_id, false);
58 }
59 $child_row.toggle(show);
60 }, this);
61
62=== modified file 'addons/web/static/src/xml/base.xml'
63--- addons/web/static/src/xml/base.xml 2013-06-07 16:37:02 +0000
64+++ addons/web/static/src/xml/base.xml 2013-07-05 12:22:27 +0000
65@@ -684,7 +684,8 @@
66 <tr t-name="TreeView.rows"
67 t-foreach="records" t-as="record"
68 t-att-id="'treerow_' + record.id"
69- t-att-data-id="record.id" t-att-data-level="level + 1">
70+ t-att-data-id="record.id" t-att-data-level="level + 1"
71+ t-att-data-parent-id="parent_id">
72 <t t-set="children" t-value="record[children_field]"/>
73 <t t-set="class" t-value="children and children.length ? 'treeview-tr' : 'treeview-td'"/>
74 <t t-set="rank" t-value="'oe-treeview-first'"/>