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
=== modified file 'addons/web/static/src/js/view_tree.js'
--- addons/web/static/src/js/view_tree.js 2012-12-13 14:09:14 +0000
+++ addons/web/static/src/js/view_tree.js 2013-07-05 12:22:27 +0000
@@ -163,12 +163,13 @@
163 var is_loaded = 0,163 var is_loaded = 0,
164 $this = $(this),164 $this = $(this),
165 record_id = $this.data('id'),165 record_id = $this.data('id'),
166 parent_id = $this.data('parent-id'),
166 record = self.records[record_id],167 record = self.records[record_id],
167 children_ids = record[self.children_field];168 children_ids = record[self.children_field];
168169
169 _(children_ids).each(function(childid) {170 _(children_ids).each(function(childid) {
170 if (self.$el.find('#treerow_' + childid).length) {171 if (self.$el.find('[id=treerow_' + childid + '][data-parent-id='+ record_id +']').length ) {
171 if (self.$el.find('#treerow_' + childid).is(':hidden')) {172 if (self.$el.find('[id=treerow_' + childid + '][data-parent-id='+ record_id +']').is(':hidden')) {
172 is_loaded = -1;173 is_loaded = -1;
173 } else {174 } else {
174 is_loaded++;175 is_loaded++;
@@ -180,7 +181,7 @@
180 self.getdata(record_id, children_ids);181 self.getdata(record_id, children_ids);
181 }182 }
182 } else {183 } else {
183 self.showcontent(record_id, is_loaded < 0);184 self.showcontent($this, record_id, is_loaded < 0);
184 }185 }
185 });186 });
186 },187 },
@@ -201,9 +202,9 @@
201 'fields': self.fields,202 'fields': self.fields,
202 'level': $curr_node.data('level') || 0,203 'level': $curr_node.data('level') || 0,
203 'render': instance.web.format_value,204 'render': instance.web.format_value,
204 'color_for': self.color_for205 'color_for': self.color_for,
206 'parent_id': id
205 });207 });
206
207 if ($curr_node.length) {208 if ($curr_node.length) {
208 $curr_node.addClass('oe_open');209 $curr_node.addClass('oe_open');
209 $curr_node.after(children_rows);210 $curr_node.after(children_rows);
@@ -243,14 +244,13 @@
243 },244 },
244245
245 // show & hide the contents246 // show & hide the contents
246 showcontent: function (record_id, show) {247 showcontent: function (curnode,record_id, show) {
247 this.$el.find('#treerow_' + record_id)248 curnode.parent('tr').toggleClass('oe_open', show);
248 .toggleClass('oe_open', show);
249
250 _(this.records[record_id][this.children_field]).each(function (child_id) {249 _(this.records[record_id][this.children_field]).each(function (child_id) {
251 var $child_row = this.$el.find('#treerow_' + child_id);250 var $child_row = this.$el.find('[id=treerow_' + child_id + '][data-parent-id='+ curnode.data('id') +']');
252 if ($child_row.hasClass('oe_open')) {251 if ($child_row.hasClass('oe_open')) {
253 this.showcontent(child_id, false);252 $child_row.toggleClass('oe_open',show);
253 this.showcontent($child_row, child_id, false);
254 }254 }
255 $child_row.toggle(show);255 $child_row.toggle(show);
256 }, this);256 }, this);
257257
=== modified file 'addons/web/static/src/xml/base.xml'
--- addons/web/static/src/xml/base.xml 2013-06-07 16:37:02 +0000
+++ addons/web/static/src/xml/base.xml 2013-07-05 12:22:27 +0000
@@ -684,7 +684,8 @@
684<tr t-name="TreeView.rows"684<tr t-name="TreeView.rows"
685 t-foreach="records" t-as="record"685 t-foreach="records" t-as="record"
686 t-att-id="'treerow_' + record.id"686 t-att-id="'treerow_' + record.id"
687 t-att-data-id="record.id" t-att-data-level="level + 1">687 t-att-data-id="record.id" t-att-data-level="level + 1"
688 t-att-data-parent-id="parent_id">
688 <t t-set="children" t-value="record[children_field]"/>689 <t t-set="children" t-value="record[children_field]"/>
689 <t t-set="class" t-value="children and children.length ? 'treeview-tr' : 'treeview-td'"/>690 <t t-set="class" t-value="children and children.length ? 'treeview-tr' : 'treeview-td'"/>
690 <t t-set="rank" t-value="'oe-treeview-first'"/>691 <t t-set="rank" t-value="'oe-treeview-first'"/>