[FIX] correctly handle insertion in empty editable list

bzr revid: xmo@openerp.com-20111004154650-hx56g1lmefhzgf21
This commit is contained in:
Xavier Morel 2011-10-04 17:46:50 +02:00
parent 72b852c2c6
commit 74db7dd027
1 changed files with 9 additions and 5 deletions

View File

@ -175,12 +175,16 @@ openerp.web.list_editable = function (openerp) {
if (row) {
$new_row.replaceAll(row);
} else if (self.options.editable) {
if (self.options.editable === 'top') {
$new_row.insertBefore(
self.$current.find('> [data-id]:first'));
if (self.records.length) {
if (self.options.editable === 'top') {
$new_row.insertBefore(
self.$current.find('> [data-id]:first'));
} else {
$new_row.insertAfter(
self.$current.find('> [data-id]:last'));
}
} else {
$new_row.insertAfter(
self.$current.find('> [data-id]:last'));
$new_row.prependTo(self.$current);
}
var $last_child = self.$current.find('> tr:last');
if ($last_child.is(':not([data-id])')) {