[FIX] web: raise a warning for bad domain

When a user wrote a wrong value in char_domain field it should raise a warning
message instead of a traceback.

Backport of b3a88b6ed846a13c0cd07cc25ea49bccbdf84aa8

opw:676783
This commit is contained in:
Goffin Simon 2016-05-25 14:54:00 +02:00
parent 97492a12a9
commit 4c7a9bdac4
2 changed files with 21 additions and 1 deletions

View File

@ -1073,6 +1073,13 @@ msgstr ""
msgid "Error"
msgstr ""
#. module: web
#. openerp-web
#: code:addons/web/static/src/js/views/form_widgets.js:2600
#, python-format
msgid "Error: Bad domain"
msgstr ""
#. module: web
#: code:addons/web/controllers/main.py:764
#: code:addons/web/controllers/main.py:805
@ -2318,6 +2325,13 @@ msgstr ""
msgid "The database has been duplicated."
msgstr ""
#. module: web
#. openerp-web
#: code:addons/web/static/src/js/views/form_widgets.js:2600
#, python-format
msgid "The domain is wrong."
msgstr ""
#. module: web
#. openerp-web
#: code:addons/web/static/src/js/view_form.js:5637

View File

@ -2593,7 +2593,13 @@ instance.web.form.FieldCharDomain = instance.web.form.AbstractField.extend(insta
this.$el.html(instance.web.qweb.render("FieldCharDomain", {widget: this}));
if (this.get('value')) {
var model = this.options.model || this.field_manager.get_field_value(this.options.model_field);
var domain = instance.web.pyeval.eval('domain', this.get('value'));
try{
var domain = pyeval.eval('domain', this.get('value'));
}
catch(e){
this.do_warn(_t('Error: Bad domain'), _t('The domain is wrong.'));
return;
}
var ds = new instance.web.DataSetStatic(self, model, self.build_context());
ds.call('search_count', [domain, self.build_context()]).then(function (results) {
$('.oe_domain_count', self.$el).text(results + _t(' records selected'));