diff --git a/addons/web_editor/models/ir_qweb_fields.py b/addons/web_editor/models/ir_qweb_fields.py index dbf3749abff..d5a6b295c76 100644 --- a/addons/web_editor/models/ir_qweb_fields.py +++ b/addons/web_editor/models/ir_qweb_fields.py @@ -28,7 +28,8 @@ from werkzeug import urls import odoo.modules -from odoo import api, models, fields +from odoo import _, api, models, fields +from odoo.exceptions import ValidationError from odoo.tools import ustr, posix_to_ldml, pycompat from odoo.tools import html_escape as escape from odoo.tools.misc import get_lang, babel_locale_parse @@ -181,8 +182,11 @@ class Float(models.AbstractModel): def from_html(self, model, field, element): lang = self.user_lang() value = element.text_content().strip() - return float(value.replace(lang.thousands_sep, '') - .replace(lang.decimal_point, '.')) + try: + return float(value.replace(lang.thousands_sep, '') + .replace(lang.decimal_point, '.')) + except: + raise ValidationError(_('You entered an invalid value, please try again.')) class ManyToOne(models.AbstractModel): @@ -478,8 +482,11 @@ class Monetary(models.AbstractModel): value = element.find('span').text.strip() - return float(value.replace(lang.thousands_sep, '') - .replace(lang.decimal_point, '.')) + try: + return float(value.replace(lang.thousands_sep, '') + .replace(lang.decimal_point, '.')) + except: + raise ValidationError(_('You entered an invalid value, please try again.')) class Duration(models.AbstractModel): diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 47db234477f..862c1b279f9 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -1844,13 +1844,13 @@ const Wysiwyg = Widget.extend({ // the DOM regeneration. Add markings instead, and returns a // new rejection with all relevant info var id = _.uniqueId('carlos_danger_'); - $el.addClass('o_dirty oe_carlos_danger ' + id); + $el.addClass('o_dirty o_editable oe_carlos_danger ' + id); $('.o_editable.' + id) .removeClass(id) .popover({ trigger: 'hover', content: response.message.data.message || '', - placement: 'auto top', + placement: 'auto', }) .popover('show'); }); @@ -1860,8 +1860,7 @@ const Wysiwyg = Widget.extend({ window.onbeforeunload = null; }).guardedCatch((failed) => { // If there were errors, re-enable edition - this.cancel(); - this.start(); + this.cancel(false); }); }, // TODO unused => remove or reuse as it should be