From 5dcd044a94048cb646483142fd6ba086ba7d1d81 Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Tue, 2 Jun 2015 14:23:13 +0200 Subject: [PATCH] Added option m2o_dialog in System parameters --- web_m2x_options/README.rst | 5 +++ web_m2x_options/static/src/js/form.js | 55 ++++++++++++++------------- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/web_m2x_options/README.rst b/web_m2x_options/README.rst index 48a3515a..be6e7603 100644 --- a/web_m2x_options/README.rst +++ b/web_m2x_options/README.rst @@ -77,6 +77,10 @@ If you disable one option, you can enable it for particular field by setting "cr Whether to display "Create and Edit..." entry in dropdown panel for all fields in the odoo instance. +``web_m2x_options.m2o_dialog`` *boolean* (Default: depends if user have create rights) + + Whether to display the many2one dialog in case of validation error for all fields in the odoo instance. + ``web_m2x_options.limit`` *int* (Default: openerp default value is ``7``) Number of displayed record in drop-down panel for all fields in the odoo instance @@ -89,6 +93,7 @@ To add these parameters go to Configuration -> Technical -> Parameters -> System - web_m2x_options.create: False - web_m2x_options.create_edit: False +- web_m2x_options.m2o_dialog: False - web_m2x_options.limit: 10 - web_m2x_options.search_more: True diff --git a/web_m2x_options/static/src/js/form.js b/web_m2x_options/static/src/js/form.js index d06ed47b..7b6a5c16 100644 --- a/web_m2x_options/static/src/js/form.js +++ b/web_m2x_options/static/src/js/form.js @@ -11,36 +11,37 @@ openerp.web_m2x_options = function (instance) { var OPTIONS = ['web_m2x_options.create', 'web_m2x_options.create_edit', 'web_m2x_options.limit', - 'web_m2x_options.search_more',]; + 'web_m2x_options.search_more', + 'web_m2x_options.m2o_dialog',]; instance.web.form.FieldMany2One = instance.web.form.FieldMany2One.extend({ - start: function() { - this._super.apply(this, arguments); - return this.get_options(); - }, - - get_options: function() { - var self = this; - if (!_.isUndefined(this.view) && _.isUndefined(this.view.ir_options_loaded)) { - this.view.ir_options_loaded = $.Deferred(); - this.view.ir_options = {}; - (new instance.web.Model("ir.config_parameter")) - .query(["key", "value"]).filter([['key', 'in', OPTIONS]]) - .all().then(function(records) { - _(records).each(function(record) { - self.view.ir_options[record.key] = record.value; - }); - self.view.ir_options_loaded.resolve(); - }); - return this.view.ir_options_loaded; - } - return $.when(); - }, - - show_error_displayer: function () { - if ((typeof this.options.m2o_dialog === 'undefined' && this.can_create) || - this.options.m2o_dialog) { + start: function() { + this._super.apply(this, arguments); + return this.get_options(); + }, + + get_options: function() { + var self = this; + if (!_.isUndefined(this.view) && _.isUndefined(this.view.ir_options_loaded)) { + this.view.ir_options_loaded = $.Deferred(); + this.view.ir_options = {}; + (new instance.web.Model("ir.config_parameter")) + .query(["key", "value"]).filter([['key', 'in', OPTIONS]]) + .all().then(function(records) { + _(records).each(function(record) { + self.view.ir_options[record.key] = record.value; + }); + self.view.ir_options_loaded.resolve(); + }); + return this.view.ir_options_loaded; + } + return $.when(); + }, + + show_error_displayer: function () { + if (((typeof this.options.m2o_dialog === 'undefined' && this.can_create) || + this.options.m2o_dialog) && (!this.view.ir_options['web_m2x_options.search_more'] === "False")) { new instance.web.form.M2ODialog(this).open(); } },