From e979565c682e46f8ea75b27cbf4a1bf6783511ae Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 29 Jun 2012 12:53:25 +0200 Subject: [PATCH] [FIX] action-type button from a list row being edited in an o2m Issue 575065 Flow for a button[@type=action] requires going through multiple RPC calls to execute action. Due to reloading behavior of o2m-list on actions (saves containing form then executes action then reloads row), internal form view gets removed while e.g. server action is being fetched (in Views#do_execute_action). Problem: there is guard on ``rpc`` call which drops response to stopped widget (Widget#rpc) => action/load call never returns successfully because linked form is dead. Solution: instead of calling View#do_execute_action via the formview, call it via the listview (do_execute_action was already partially overridden to change the ``on_close`` callback, override it further). => widget still lives, and rpc requests execute correctly leading to all actions being correctly called (mostly). bzr revid: xmo@openerp.com-20120629105325-vmwpyi7w3pc33sg9 --- addons/web/static/src/js/view_form.js | 14 +++++++++----- addons/web/static/src/js/views.js | 6 +++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index a702cd19b5b..694db7bf4e3 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2752,12 +2752,16 @@ openerp.web.form.One2ManyList = openerp.web.ListView.List.extend({ self.cancel_pending_edition(); }); - // Overload execute_action on the edition form to perform a simple - // reload_record after the action is done, rather than fully - // reload the parent view (or something) - var _execute_action = self.edition_form.do_execute_action; + // Replace form's do_execute_action by a call to listview's: + // because the form view is actually destroyed at one point, the + // RPC request to load&execute the action may get dropped on the + // floor in some cases (core.js:1173) leading to the flow not + // terminating for complex cases (a button of type action, which + // needs 2 or 3 RPC roundtrip to execute the action fully). + // => because do_execute_action really is on View, use the + // listview's self.edition_form.do_execute_action = function (action, dataset, record_id, _callback) { - return _execute_action.call(this, action, dataset, record_id, function () { + return self.view.do_execute_action(action, dataset, record_id, function () { self.view.reload_record( self.view.records.get(record_id)); }); diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index ac7163fa2a9..d5c777bf5a2 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -1166,7 +1166,11 @@ session.web.View = session.web.Widget.extend(/** @lends session.web.View# */{ args.push(context); return dataset.call_button(action_data.name, args, handler); } else if (action_data.type=="action") { - return this.rpc('/web/action/load', { action_id: parseInt(action_data.name, 10), context: context, do_not_eval: true}, handler); + return this.rpc('/web/action/load', { + action_id: parseInt(action_data.name, 10), + context: context, + do_not_eval: true + }).then(handler); } else { return dataset.exec_workflow(record_id, action_data.name, handler); }