[FIX] web_editor: fix required html fields

Issue

    - Studio
    - Add an required html field
    - Create new record
    - Leave it empty

    It is saved

Cause

    The isSet function of FieldHtml widget, have a "/" in the <br> tag
    and summernote empty = <p><br></p>. If you add a space, the value
    becomes <p>&nbsp;&nbsp;   <p>.

Solution

    Remove the "/" and the spaces, check if value != <p></p> &&
    <p><br></p>

OPW-2183687

closes odoo/odoo#44427

X-original-commit: c984b1b1210cea1e63f3bc66cec2120554c76c2a
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Jason Van Malder
2020-01-31 17:20:34 +00:00
parent 58732e4dc8
commit cf2f53e4cf
2 changed files with 40 additions and 1 deletions
@@ -116,7 +116,8 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, {
* @override
*/
isSet: function () {
return this.value && this.value !== "<p><br/></p>" && this.value.match(/\S/);
var value = this.value && this.value.split('&nbsp;').join('').replace(/\s/g, ''); // Removing spaces & html spaces
return value && value !== "<p></p>" && value !== "<p><br></p>" && value.match(/\S/);
},
/**
* @override