From 0bef90bfd347afaf9285a66bb91c4d3d4419084c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 7 Oct 2015 18:05:12 +0200 Subject: [PATCH] Get ids for button later As save is called by the button, the record id could change if the save is a creation so the list of ids must be constructed later. --- src/screen.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/screen.js b/src/screen.js index 8ff384986e..ae95a7f82a 100644 --- a/src/screen.js +++ b/src/screen.js @@ -1255,6 +1255,7 @@ return buttons; }, button: function(attributes) { + var ids; var process_action = function(action) { this.reload(ids, true); if (typeof action == 'string') { @@ -1270,10 +1271,6 @@ }; var selected_records = this.current_view.selected_records(); - var ids = selected_records.map( - function(record) { - return record.id; - }); this.current_view.set_value(); var fields = this.current_view.get_fields(); @@ -1326,6 +1323,10 @@ jQuery.extend(context, record.get_timestamp()); } record.save(false).done(function() { + ids = selected_records.map( + function(record) { + return record.id; + }); record.model.execute(attributes.name, [ids], context).then(process_action.bind(this)); }.bind(this));