From 2a4d8bc6d5e1e0efa382beb3381460f49d201dec Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 20 Feb 2014 15:13:02 +0100 Subject: [PATCH] [ADD] web: add no_create option in view_form, allowing to remove create and edit (and quick create) Before, we used to use selection widget to hide or disable the create and edit of many2one fields, but this is actually an abuse of the selection widget, this is not its purpose bzr revid: dle@openerp.com-20140220141302-3paib80ixiyi66qg --- addons/web/static/src/js/view_form.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 599664d14de..f1fc377fa94 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3092,7 +3092,7 @@ instance.web.form.CompletionFieldMixin = { // quick create var raw_result = _(data.result).map(function(x) {return x[1];}); if (search_val.length > 0 && !_.include(raw_result, search_val) && - ! (self.options && self.options.no_quick_create)) { + ! (self.options && (self.options.no_create || self.options.no_quick_create))) { values.push({ label: _.str.sprintf(_t('Create "%s"'), $('').text(search_val).html()), @@ -3103,13 +3103,15 @@ instance.web.form.CompletionFieldMixin = { }); } // create... - values.push({ - label: _t("Create and Edit..."), - action: function() { - self._search_create_popup("form", undefined, self._create_context(search_val)); - }, - classname: 'oe_m2o_dropdown_option' - }); + if (!(self.options && self.options.no_create)){ + values.push({ + label: _t("Create and Edit..."), + action: function() { + self._search_create_popup("form", undefined, self._create_context(search_val)); + }, + classname: 'oe_m2o_dropdown_option' + }); + } return values; });