From 72b852c2c669b92297d75b8adac6a42e3a1ecf6d Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 4 Oct 2011 17:42:46 +0200 Subject: [PATCH] [FIX] insertion position of new lines (in editable lists) in case of lists padded to 5 (empty) lines bzr revid: xmo@openerp.com-20111004154246-7o1cw016cf9ygem3 --- addons/web/static/src/js/view_list.js | 4 +++- addons/web/static/src/js/view_list_editable.js | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 719c7117d65..8b7f0fbd3f8 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -815,7 +815,9 @@ openerp.web.ListView.List = openerp.web.Class.extend( /** @lends openerp.web.Lis cells.push(''); var row = cells.join(''); - this.$current.append(new Array(count - this.records.length + 1).join(row)); + this.$current + .find('> tr:not([data-id])').remove().end() + .append(new Array(count - this.records.length + 1).join(row)); this.refresh_zebra(this.records.length); }, /** diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index 30a12af0828..7daf2bd0685 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -120,6 +120,7 @@ openerp.web.list_editable = function (openerp) { delete self.edition_id; delete self.edition; }); + this.pad_table_to(5); return cancelled.promise(); }, /** @@ -173,10 +174,18 @@ openerp.web.list_editable = function (openerp) { }); if (row) { $new_row.replaceAll(row); - } else if (self.options.editable === 'top') { - self.$current.prepend($new_row); } else if (self.options.editable) { - self.$current.append($new_row); + if (self.options.editable === 'top') { + $new_row.insertBefore( + self.$current.find('> [data-id]:first')); + } else { + $new_row.insertAfter( + self.$current.find('> [data-id]:last')); + } + var $last_child = self.$current.find('> tr:last'); + if ($last_child.is(':not([data-id])')) { + $last_child.remove(); + } } self.edition = true; self.edition_id = record_id;