[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
This commit is contained in:
Denis Ledoux 2014-02-20 15:13:02 +01:00
parent b0f1e57269
commit 2a4d8bc6d5
1 changed files with 10 additions and 8 deletions

View File

@ -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 "<strong>%s</strong>"'),
$('<span />').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;
});