From e83c3e2678500c9bf2c17b4d23ae9a294ebafaa7 Mon Sep 17 00:00:00 2001 From: Elkasitu Date: Mon, 17 Jul 2017 11:09:35 +0200 Subject: [FIX] web: Fix actions for widgets w/o controllers Execution of actions is usually done with trigger_up, which delegates the action execution to the widget's controller. This is troublesome for actions done on widgets that have no controllers, like widgets in Studio for example. The commit fixes this by adding a standalone option for AbstractFields, if the flag is true when instantiating a widget, the action will be called directly from within the widget object and will not be propagated upwards. A test to verify that this works properly has been added as well --- .../web/static/src/js/fields/relational_fields.js | 32 ++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'addons/web/static/src/js/fields/relational_fields.js') diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 14512c02912..7522bb3bc37 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -223,21 +223,25 @@ var FieldMany2One = AbstractField.extend({ _quickCreate: function (name) { var self = this; var slowCreate = this._searchCreatePopup.bind(this, "form", false, this._createContext(name)); + var action = function () { + return self._rpc({ + model: self.field.relation, + method: 'name_create', + args: [name], + context: self.record.getContext(self.recordParams), + }).then(function (result) { + if (self.mode === "edit") { + self.reinitialize({id: result[0], display_name: result[1]}); + } + }, slowCreate); + }; + if (this.nodeOptions.quick_create) { - this.trigger_up('mutexify', { - action: function () { - return self._rpc({ - model: self.field.relation, - method: 'name_create', - args: [name], - context: self.record.getContext(self.recordParams), - }).then(function (result) { - if (self.mode === "edit") { - self.reinitialize({id: result[0], display_name: result[1]}); - } - }, slowCreate); - }, - }); + if (this.standalone) { + action(); + } else { + this.trigger_up('mutexify', {action: action}); + } } else { slowCreate(); } -- cgit v1.2.3