From d51c9a85903fc26bdc305cd9dce2f7cb2bc684ec Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 9 Jul 2012 11:24:01 +0200 Subject: [PATCH] [FIX] double-include of ids in the dataset, and double-save in some cases ~/projects/tiny/web/current on [change] of a listview record, if there was no id on the record (id=false) we need to add one. But depending how the creation/addition of the record was done, the id may already have been inserted e.g. by the formview. So first check if the record's id is already in the dataset, and add it if it's not. bzr revid: xmo@openerp.com-20120709092401-p1in6bvs5e2ptp5p --- addons/web/static/src/js/view_list.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 936af4de5e1..f25164d56e5 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -919,9 +919,12 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web. throw new Error("Setting 'id' attribute on existing record " + JSON.stringify(record.attributes)); } - // add record to dataset - self.dataset.ids.splice( - self.records.indexOf(record), 0, value); + if (!_.contains(self.dataset.ids, value)) { + // add record to dataset if not already in (added by + // the form view?) + self.dataset.ids.splice( + self.records.indexOf(record), 0, value); + } // Set id on new record $row = self.$current.children('[data-id=false]'); } else {