From cf2f53e4cf4e8f5e2e2d23c5aaf4554630be68c8 Mon Sep 17 00:00:00 2001 From: Jason Van Malder Date: Thu, 30 Jan 2020 08:16:33 +0000 Subject: [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
tag and summernote empty =


. If you add a space, the value becomes

  

. Solution Remove the "/" and the spaces, check if value !=

&&


OPW-2183687 closes odoo/odoo#44427 X-original-commit: c984b1b1210cea1e63f3bc66cec2120554c76c2a Signed-off-by: Aaron Bohy (aab) --- addons/web_editor/static/tests/field_html_tests.js | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'addons/web_editor/static/tests') diff --git a/addons/web_editor/static/tests/field_html_tests.js b/addons/web_editor/static/tests/field_html_tests.js index 6c4c3f9c5a3..ff50e0ef809 100644 --- a/addons/web_editor/static/tests/field_html_tests.js +++ b/addons/web_editor/static/tests/field_html_tests.js @@ -22,6 +22,11 @@ QUnit.module('web_editor', {}, function () { string: "Displayed name", type: "char" }, + header: { + string: "Header", + type: "html", + required: true, + }, body: { string: "Message", type: "html" @@ -30,6 +35,7 @@ QUnit.module('web_editor', {}, function () { records: [{ id: 1, display_name: "first record", + header: "

  

", body: "

toto toto toto

tata

", }], }, @@ -126,6 +132,38 @@ QUnit.module('web_editor', {}, function () { form.destroy(); }); + QUnit.test('check if required field is set', async function (assert) { + assert.expect(1); + + var form = await testUtils.createView({ + View: FormView, + model: 'note.note', + data: this.data, + arch: '
' + + '' + + '', + res_id: 1, + }); + + testUtils.mock.intercept(form, 'call_service', function (ev) { + if (ev.data.service === 'notification') { + assert.deepEqual(ev.data.args[0], { + "className": undefined, + "message": "
  • Header
", + "sticky": undefined, + "title": "The following fields are invalid:", + "type": "danger" + }); + } + }, true); + + await testUtils.form.clickEdit(form); + await testUtils.nextTick(); + await testUtils.dom.click(form.$('.o_form_button_save')); + + form.destroy(); + }); + QUnit.test('colorpicker', async function (assert) { assert.expect(6); -- cgit v1.2.3