From 3b87df079e74f9b84d984596a67d6a325a29dbb0 Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Mon, 5 Nov 2012 14:02:32 +0100 Subject: [ADD] Added new widget, Many2OneButton, to view_form.js and view_list.js. bzr revid: vta@openerp.com-20121105130232-rpde2k1ihbquznmg --- addons/web/static/src/js/view_form.js | 50 +++++++++++++++++++++++++++++++++++ addons/web/static/src/js/view_list.js | 11 ++++++++ addons/web/static/src/xml/base.xml | 7 +++++ 3 files changed, 68 insertions(+) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 9dd6e34c161..f50f9297072 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3148,6 +3148,54 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc }, }); +instance.web.form.Many2OneButton = instance.web.form.AbstractField.extend({ + template: 'Many2OneButton', + init: function(field_manager, node) { + this._super.apply(this, arguments); + }, + start: function() { + this._super.apply(this, arguments); + this.set_button(); + }, + set_button: function() { + var self = this; + if (this.$button) { + this.$button.remove(); + } + this.string = this.get('value') ? _t('Edit') : _t('Create'); + this.node.attrs.icon = this.get('value') ? '/web/static/src/img/icons/gtk-yes.png' : '/web/static/src/img/icons/gtk-no.png'; + this.$button = $(QWeb.render('WidgetButton', {'widget': this})); + this.$el.append(this.$button); + this.$button.on('click', self.on_click); + }, + on_click: function(ev) { + var self = this; + ev.stopPropagation(); + var popup = new instance.web.form.FormOpenPopup(this); + popup.show_element( + this.field.relation, + this.get('value'), + this.build_context(), + {title: this.string + ' ' +_t("Voucher: ")} + ); + popup.on('create_completed write_completed', self, function(r){ + self.set_value(r); + }); + }, + set_value: function(value_) { + var self = this; + if (value_ instanceof Array) { + value_ = value_[0]; + } + value_ = value_ || false; + this.set('value', value_); + this.set_button(); + if (this.is_started) { + this.render_value(); + } + }, +}); + /* # Values: (0, 0, { fields }) create # (1, ID, { fields }) update @@ -4332,6 +4380,7 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({ this.dataset.create_function = function(data, sup) { var fct = self.options.create_function || sup; return fct.call(this, data).then(function(r) { + self.trigger('create_completed'); self.created_elements.push(r); }); }; @@ -5130,6 +5179,7 @@ instance.web.form.widgets = new instance.web.Registry({ 'datetime' : 'instance.web.form.FieldDatetime', 'selection' : 'instance.web.form.FieldSelection', 'many2one' : 'instance.web.form.FieldMany2One', + 'many2onebutton' : 'instance.web.form.Many2OneButton', 'many2many' : 'instance.web.form.FieldMany2Many', 'many2many_tags' : 'instance.web.form.FieldMany2ManyTags', 'many2many_kanban' : 'instance.web.form.FieldMany2ManyKanban', diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index fd74fd8922b..216ad7ded6c 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -2010,6 +2010,7 @@ instance.web.list.columns = new instance.web.Registry({ 'field.progressbar': 'instance.web.list.ProgressBar', 'field.handle': 'instance.web.list.Handle', 'button': 'instance.web.list.Button', + 'field.many2onebutton': 'instance.web.list.Many2OneButton', }); instance.web.list.columns.for_ = function (id, field, node) { var description = _.extend({tag: node.tag}, field, node.attrs); @@ -2197,5 +2198,15 @@ instance.web.list.Handle = instance.web.list.Column.extend({ return '
'; } }); +instance.web.list.Many2OneButton = instance.web.list.Column.extend({ + _format: function (row_data, options) { + if (row_data.voucher_id.value) { + this.icon = '/web/static/src/img/icons/gtk-yes.png'; + } else { + this.icon = '/web/static/src/img/icons/gtk-no.png'; + } + return QWeb.render('Many2OneButton.cell', {'widget': this}); + }, +}); }; // vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 275d31a9fde..fe64c1c0efa 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1029,6 +1029,13 @@ + + + + + +
-- cgit v1.2.3 From 492379e6c4155108c226d973a3268d0d5a7c8994 Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Mon, 5 Nov 2012 15:54:31 +0100 Subject: [FIX] Added parameters to trigger. bzr revid: vta@openerp.com-20121105145431-qk01mspfvldusa13 --- addons/web/static/src/js/view_form.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index f50f9297072..0b9b5d99b9e 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -4380,14 +4380,14 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({ this.dataset.create_function = function(data, sup) { var fct = self.options.create_function || sup; return fct.call(this, data).then(function(r) { - self.trigger('create_completed'); + self.trigger('create_completed', r); self.created_elements.push(r); }); }; this.dataset.write_function = function(id, data, options, sup) { var fct = self.options.write_function || sup; - return fct.call(this, id, data, options).then(function() { - self.trigger('write_completed'); + return fct.call(this, id, data, options).then(function(r) { + self.trigger('write_completed', r); }); }; this.dataset.parent_view = this.options.parent_view; -- cgit v1.2.3 From 83a264ff2b5d62fd25bba9873fdd08c0b5bf8df3 Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Tue, 6 Nov 2012 11:33:20 +0100 Subject: [FIX] Fixed list view widget as per xmo review. bzr revid: vta@openerp.com-20121106103320-zyon6mzsy9jaafj0 --- addons/web/static/src/js/view_form.js | 4 ---- addons/web/static/src/js/view_list.js | 6 +----- addons/web/static/src/xml/base.xml | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 0b9b5d99b9e..9a8f734d2da 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3170,7 +3170,6 @@ instance.web.form.Many2OneButton = instance.web.form.AbstractField.extend({ }, on_click: function(ev) { var self = this; - ev.stopPropagation(); var popup = new instance.web.form.FormOpenPopup(this); popup.show_element( this.field.relation, @@ -3190,9 +3189,6 @@ instance.web.form.Many2OneButton = instance.web.form.AbstractField.extend({ value_ = value_ || false; this.set('value', value_); this.set_button(); - if (this.is_started) { - this.render_value(); - } }, }); diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 216ad7ded6c..871d2bc856f 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -2200,11 +2200,7 @@ instance.web.list.Handle = instance.web.list.Column.extend({ }); instance.web.list.Many2OneButton = instance.web.list.Column.extend({ _format: function (row_data, options) { - if (row_data.voucher_id.value) { - this.icon = '/web/static/src/img/icons/gtk-yes.png'; - } else { - this.icon = '/web/static/src/img/icons/gtk-no.png'; - } + this.has_value = !!row_data[this.id].value; return QWeb.render('Many2OneButton.cell', {'widget': this}); }, }); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index fe64c1c0efa..b3c09b0359b 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1034,7 +1034,7 @@ + >
-- cgit v1.2.3 From c2753639215fb7e52098b918fc8f9d9d7481203f Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Tue, 6 Nov 2012 16:41:41 +0100 Subject: [FIX] Text conflicts. bzr revid: vta@openerp.com-20121106154141-03nnje0th7cjtlqf --- addons/web/static/src/js/view_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 9a8f734d2da..9d68ef3516f 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3177,7 +3177,7 @@ instance.web.form.Many2OneButton = instance.web.form.AbstractField.extend({ this.build_context(), {title: this.string + ' ' +_t("Voucher: ")} ); - popup.on('create_completed write_completed', self, function(r){ + popup.on('create_completed write_completed', self, function(r) { self.set_value(r); }); }, -- cgit v1.2.3 From 83405dba45143d521ecffccc4d44493dd0de84c6 Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Wed, 7 Nov 2012 09:17:38 +0100 Subject: [IMP] Make the popup accessible. bzr revid: vta@openerp.com-20121107081738-kortakwtjj7s9k80 --- addons/web/static/src/js/view_form.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 9d68ef3516f..20024c076f5 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3170,14 +3170,14 @@ instance.web.form.Many2OneButton = instance.web.form.AbstractField.extend({ }, on_click: function(ev) { var self = this; - var popup = new instance.web.form.FormOpenPopup(this); - popup.show_element( + this.popup = new instance.web.form.FormOpenPopup(this); + this.popup.show_element( this.field.relation, this.get('value'), this.build_context(), {title: this.string + ' ' +_t("Voucher: ")} ); - popup.on('create_completed write_completed', self, function(r) { + this.popup.on('create_completed write_completed', self, function(r) { self.set_value(r); }); }, -- cgit v1.2.3 From 4b0d99d6c861b171d84d816bafffb35ada699a82 Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Wed, 7 Nov 2012 11:34:26 +0100 Subject: [IMP] Now the Many2OneButton accepts an option (label) containing a dict to set the string displayed in the button ({'create':String, 'edit':String}). If no label, the string is empty. bzr revid: vta@openerp.com-20121107103426-u6dfd1vcfu8fwap3 --- addons/web/static/src/js/view_form.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 20024c076f5..1b5ca8de730 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3162,7 +3162,12 @@ instance.web.form.Many2OneButton = instance.web.form.AbstractField.extend({ if (this.$button) { this.$button.remove(); } - this.string = this.get('value') ? _t('Edit') : _t('Create'); + var options =py.eval(this.node.attrs.options); + if (options.label) { + this.string = this.get('value') ? _t(options.label.edit) : _t(options.label.create); + } else { + this.string = ''; + } this.node.attrs.icon = this.get('value') ? '/web/static/src/img/icons/gtk-yes.png' : '/web/static/src/img/icons/gtk-no.png'; this.$button = $(QWeb.render('WidgetButton', {'widget': this})); this.$el.append(this.$button); -- cgit v1.2.3 From 064003797eb9f1cbd428d3ed416515a655708fc7 Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Wed, 7 Nov 2012 11:49:33 +0100 Subject: [FIX] Issue with py.eval if no options passed. bzr revid: vta@openerp.com-20121107104933-a60t27t1hjyu368f --- addons/web/static/src/js/view_form.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 1b5ca8de730..da53113f9a2 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3162,7 +3162,10 @@ instance.web.form.Many2OneButton = instance.web.form.AbstractField.extend({ if (this.$button) { this.$button.remove(); } - var options =py.eval(this.node.attrs.options); + var options = {}; + try { + options = py.eval(this.node.attrs.options); + } catch (e) {} if (options.label) { this.string = this.get('value') ? _t(options.label.edit) : _t(options.label.create); } else { -- cgit v1.2.3 From 8b18d999bdf3f0aa8ae5be88a9b6df0b79472d12 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 7 Nov 2012 12:12:47 +0100 Subject: [FIX] BinaryImage field triggers render_value() two times on file change bzr revid: fme@openerp.com-20121107111247-ge1oi0oxbr7k5dhf --- addons/web/static/src/js/view_form.js | 4 ---- 1 file changed, 4 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index bbb2234e3bd..a3b9f5fae7d 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -4858,10 +4858,6 @@ instance.web.form.FieldBinaryImage = instance.web.form.FieldBinary.extend({ instance.webclient.notification.warn(_t("Image"), _t("Could not display the selected image.")); }); }, - on_file_change: function() { - this.render_value(); - this._super.apply(this, arguments); - }, on_file_uploaded_and_valid: function(size, name, content_type, file_base64) { this.internal_set_value(file_base64); this.binary_value = true; -- cgit v1.2.3 From bfad5ad032e68b4e753249ff14523d5156ce8cef Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 7 Nov 2012 14:21:52 +0100 Subject: [ADD] custom dimensioning of a bunch of form widget for better editable listview compat/styling bzr revid: xmo@openerp.com-20121107132152-9s6s1n4fn4bwjdm2 --- addons/web/static/src/css/base.css | 6 ++++-- addons/web/static/src/css/base.sass | 10 ++++++---- addons/web/static/src/js/view_form.js | 20 +++++++++++++++++++- 3 files changed, 29 insertions(+), 7 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 30fe4d415cf..94d02758ad0 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -25,7 +25,6 @@ display: none !important; } } - .openerp.openerp_webclient_container { height: 100%; } @@ -2566,7 +2565,7 @@ background-color: #eeeeee; } .openerp .oe_list_editable .oe_list_content td.oe_list_field_cell { - padding: 4px 6px 3px 6px; + padding: 4px 6px 3px; } .openerp .oe_list.oe_list_editable.oe_editing .oe_edition .oe_list_field_cell:not(.oe_readonly) { color: transparent; @@ -2647,6 +2646,9 @@ margin: 0 !important; padding: 0; } +.openerp .oe_list .oe_form .oe_form_field_boolean { + padding: 1px 6px 3px; +} .openerp .oe_list .oe_list_content .oe_group_header { background-color: #fcfcfc; background-image: -webkit-gradient(linear, left top, left bottom, from(#fcfcfc), to(#dedede)); diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index e388ad16727..f911929e159 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -2030,10 +2030,8 @@ $sheet-padding: 16px background-color: #eee $row-height: 27px - .oe_list_editable - .oe_list_content - td.oe_list_field_cell - padding: 4px 6px 3px 6px + .oe_list_editable .oe_list_content td.oe_list_field_cell + padding: 4px 6px 3px .oe_list.oe_list_editable.oe_editing .oe_edition .oe_list_field_cell:not(.oe_readonly) * @@ -2106,6 +2104,10 @@ $sheet-padding: 16px position: absolute margin: 0 !important // dammit padding: 0 + .oe_form_field_boolean + // use padding similar to actual cell to correctly position the + // checkbox + padding: 1px 6px 3px .oe_list_content .oe_group_header @include vertical-gradient(#fcfcfc, #dedede) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index a3b9f5fae7d..07850d0ecaa 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2216,6 +2216,13 @@ instance.web.form.FieldChar = instance.web.form.AbstractField.extend(instance.we }, focus: function() { this.$('input:first').focus(); + }, + set_dimensions: function (height, width) { + this._super(height, width); + this.$('input').css({ + height: height, + width: width + }); } }); @@ -2502,7 +2509,7 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we this.$textarea.focus(); }, set_dimensions: function (height, width) { - this._super(); + this._super(height, width); this.$textarea.css({ width: width, minHeight: height @@ -2664,6 +2671,13 @@ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instan }, focus: function() { this.$el.find('select:first').focus(); + }, + set_dimensions: function (height, width) { + this._super(height, width); + this.$('select').css({ + height: height, + width: width + }); } }); @@ -3146,6 +3160,10 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc this.ed_def.reject(); return instance.web.form.CompletionFieldMixin._search_create_popup.apply(this, arguments); }, + set_dimensions: function (height, width) { + this._super(height, width); + this.$input.css('height', height); + } }); /* -- cgit v1.2.3 From 1b8a0e66eee009946caa8afeadc809cf1a7583bf Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 7 Nov 2012 15:37:40 +0100 Subject: [REV] nicolas.vanhoren@openerp.com-20120712074237-xugmbw19wjjoes9l eagerly loaded treeviews, making heavily loaded charts of accounts completely unusable bzr revid: xmo@openerp.com-20121107143740-31i16933dfg4t6xk --- addons/web/static/src/js/view_tree.js | 105 ++++++++++++++-------------------- addons/web/static/src/xml/base.xml | 16 +++--- 2 files changed, 51 insertions(+), 70 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_tree.js b/addons/web/static/src/js/view_tree.js index 05760420ba8..3f1dfabe80a 100644 --- a/addons/web/static/src/js/view_tree.js +++ b/addons/web/static/src/js/view_tree.js @@ -45,7 +45,7 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie view_type: "tree", toolbar: this.view_manager ? !!this.view_manager.sidebar : false, context: this.dataset.get_context() - }).then(this.on_loaded); + }, this.on_loaded); }, /** * Returns the list of fields needed to correctly read objects. @@ -63,12 +63,6 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie } return fields; }, - store_record:function(records){ - var self = this; - _(records).each(function (record) { - self.records[record.id] = record; - }); - }, on_loaded: function (fields_view) { var self = this; var has_toolbar = !!fields_view.arch.attrs.toolbar; @@ -93,19 +87,17 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie this.$el.addClass(this.fields_view.arch.attrs['class']); this.dataset.read_slice(this.fields_list()).then(function(records) { - self.store_record(records); if (!has_toolbar) { // WARNING: will do a second read on the same ids, but only on // first load so not very important - self.render_data({'null':records}) - self.getdata(_.pluck(records,"id")); + self.getdata(null, _(records).pluck('id')); return; } var $select = self.$el.find('select') .change(function () { var $option = $(this).find(':selected'); - self.getdata($option.val()); + self.getdata($option.val(), $option.data('children')); }); _(records).each(function (record) { self.records[record.id] = record; @@ -120,12 +112,7 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie $select.change(); } }); - this.$el.find("#tree_view_expand").click(function(){ - self.expand_all(); - }); - this.$el.find("#tree_view_collapse").click(function(){ - self.collpase_all(); - }); + // TODO store open nodes in url ?... this.do_push_state({}); @@ -141,22 +128,6 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie return [color, py.parse(py.tokenize(expr)), expr]; }).value(); }, - expand_all: function(){ - var self = this; - var tr = this.$el.find(".oe-treeview-table tbody tr[id^='treerow_']"); - _.each(tr,function(rec){ - self.showcontent($(rec).attr('data-id'),true); - }); - }, - collpase_all: function(){ - var self = this; - var root_tr = this.$el.find(".oe-treeview-table tbody tr[data-level='"+1+"']"); - _.each(root_tr,function(rec){ - if($(rec).hasClass('oe_open')){ - self.showcontent($(rec).attr('data-id'),false); - } - }); - }, /** * Returns the color for the provided record in the current view (from the * ``@colors`` attribute) @@ -193,44 +164,50 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie }); this.$el.delegate('.treeview-tr', 'click', function () { - var $this = $(this), + var is_loaded = 0, + $this = $(this), record_id = $this.data('id'), - bool = $this.parent().hasClass('oe_open'); - self.showcontent(record_id, !bool); + record = self.records[record_id], + children_ids = record[self.children_field]; + + _(children_ids).each(function(childid) { + if (self.$el.find('#treerow_' + childid).length) { + if (self.$el.find('#treerow_' + childid).is(':hidden')) { + is_loaded = -1; + } else { + is_loaded++; + } + } + }); + if (is_loaded === 0) { + if (!$this.parent().hasClass('oe_open')) { + self.getdata(record_id, children_ids); + } + } else { + self.showcontent(record_id, is_loaded < 0); + } }); }, // get child data of selected value - getdata: function (id) { + getdata: function (id, children_ids) { var self = this; - var parent_child ={}; - id = _.isArray(id)?id:parseInt(id); - var ir_model_data = new instance.web.Model(this.model,self.dataset.get_context() || {},[['id','child_of',id]]).query(); - ir_model_data._execute().then(function(records){ - self.store_record(records); - _.each(records,function(rec){ - if(rec[self.children_field].length === 0)return; - parent_child[rec.id] = []; - _.each(rec[self.children_field],function(key){ - parent_child[rec.id].push(self.records[key]); - }); - }) - self.render_data(parent_child); - }); - }, - render_data: function(groupby){ - var self = this; - _.each(_.keys(groupby),function(key){ - var $curr_node = self.$el.find('#treerow_' + key); - var record = groupby[key]; + + self.dataset.read_ids(children_ids, this.fields_list()).then(function(records) { + _(records).each(function (record) { + self.records[record.id] = record; + }); + + var $curr_node = self.$el.find('#treerow_' + id); var children_rows = QWeb.render('TreeView.rows', { - 'records': record, + 'records': records, 'children_field': self.children_field, 'fields_view': self.fields_view.arch.children, 'fields': self.fields, - 'level': ($curr_node.data('level') || 0) + 1, + 'level': $curr_node.data('level') || 0, 'render': instance.web.format_value, 'color_for': self.color_for }); + if ($curr_node.length) { $curr_node.addClass('oe_open'); $curr_node.after(children_rows); @@ -238,10 +215,8 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie self.$el.find('tbody').html(children_rows); } }); - self.collpase_all(); }, - // Get details in listview activate: function(id) { var self = this; @@ -284,5 +259,13 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie }, this); }, + do_show: function () { + this.$el.show(); + }, + + do_hide: function () { + this.$el.hide(); + this.hidden = true; + } }); }; diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 275d31a9fde..4118d3fc363 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -567,16 +567,14 @@ -
- - - -
- + +
@@ -588,11 +586,11 @@ + t-att-data-id="record.id" t-att-data-level="level + 1"> - +
+ t-if="!field.attrs.modifiers.tree_invisible" + class="treeview-header">