diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-08-02 12:18:41 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-08-02 12:18:41 +0200 |
| commit | a445548f07fbf8d883f4b02e18a35f4b324c6961 (patch) | |
| tree | 9873211f96ded4f06311315bec7b438f3e537bab /addons/web/static/src | |
| parent | 04c5aa31259b9e2d8d52f21f9ccde1d0b93d24e8 (diff) | |
| parent | 211961c3747b5948e80ad8eb6f097636bc61b46d (diff) | |
[MERGE] forward port branch saas-16 up to 211961c3747
Diffstat (limited to 'addons/web/static/src')
4 files changed, 27 insertions, 37 deletions
diff --git a/addons/web/static/src/js/fields/abstract_field.js b/addons/web/static/src/js/fields/abstract_field.js index 426d42d664b..9b484354544 100644 --- a/addons/web/static/src/js/fields/abstract_field.js +++ b/addons/web/static/src/js/fields/abstract_field.js @@ -65,12 +65,10 @@ var AbstractField = Widget.extend({ * @constructor * @param {Widget} parent * @param {string} name The field name defined in the model - * @param {Object} record A record object (result of the get method of + * @param {Object} record A record object (result of the get method of * a basic model) * @param {Object} [options] * @param {string} [options.mode=readonly] should be 'readonly' or 'edit' - * @param {string} [options.standalone=false] this flag indicates that the - * field does not have a controller to delegate to */ init: function (parent, name, record, options) { this._super(parent); @@ -160,10 +158,6 @@ var AbstractField = Widget.extend({ // calls to the format (resp. parse) function. this.formatOptions = {}; this.parseOptions = {}; - - // standalone is a flag indicating that the field does not have a - // controller to delegate actions to - this.standalone = options.standalone; }, /** * When a field widget is appended to the DOM, its start method is called, diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 1935e5804dd..64049d8b1ec 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -223,25 +223,21 @@ 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) { - if (this.standalone) { - action(); - } else { - this.trigger_up('mutexify', {action: action}); - } + 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); + }, + }); } else { slowCreate(); } diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js index 39e596db5b8..3a47f65ab03 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -8,7 +8,6 @@ odoo.define('web.BasicController', function (require) { */ var AbstractController = require('web.AbstractController'); -var concurrency = require('web.concurrency'); var core = require('web.core'); var Dialog = require('web.Dialog'); var FieldManagerMixin = require('web.FieldManagerMixin'); @@ -19,7 +18,6 @@ var _t = core._t; var BasicController = AbstractController.extend(FieldManagerMixin, { custom_events: _.extend({}, AbstractController.prototype.custom_events, FieldManagerMixin.custom_events, { discard_changes: '_onDiscardChanges', - mutexify: '_onMutexify', reload: '_onReload', sidebar_data_asked: '_onSidebarDataAsked', translate: '_onTranslate', @@ -39,7 +37,6 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { FieldManagerMixin.init.call(this, this.model); this.handle = params.initialState.id; this.mode = params.mode || 'readonly'; - this.mutex = new concurrency.Mutex(); }, /** * @override @@ -527,15 +524,6 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { FieldManagerMixin._onFieldChanged.apply(this, arguments); }, /** - * @private - * @param {OdooEvent} ev - * @param {function} ev.data.action the function to execute in the mutex - */ - _onMutexify: function (ev) { - ev.stopPropagation(); // prevent other controllers from handling this request - this.mutex.exec(ev.data.action); - }, - /** * When a reload event triggers up, we need to reload the full view. * For example, after a form view dialog saved some data. * diff --git a/addons/web/static/src/js/views/field_manager_mixin.js b/addons/web/static/src/js/views/field_manager_mixin.js index b4bf1ddbf94..1ee7bf4a501 100644 --- a/addons/web/static/src/js/views/field_manager_mixin.js +++ b/addons/web/static/src/js/views/field_manager_mixin.js @@ -9,11 +9,13 @@ odoo.define('web.FieldManagerMixin', function (require) { */ var BasicModel = require('web.BasicModel'); +var concurrency = require('web.concurrency'); var FieldManagerMixin = { custom_events: { field_changed: '_onFieldChanged', load: '_onLoad', + mutexify: '_onMutexify', }, /** * A FieldManagerMixin can be initialized with an instance of a basicModel. @@ -23,6 +25,7 @@ var FieldManagerMixin = { */ init: function (model) { this.model = model || new BasicModel(this); + this.mutex = new concurrency.Mutex(); }, //-------------------------------------------------------------------------- @@ -130,6 +133,15 @@ var FieldManagerMixin = { data.on_success(self.model.get(db_id)); }); }, + /** + * @private + * @param {OdooEvent} ev + * @param {function} ev.data.action the function to execute in the mutex + */ + _onMutexify: function (ev) { + ev.stopPropagation(); // prevent other field managers from handling this request + this.mutex.exec(ev.data.action); + }, }; return FieldManagerMixin; |
