[FIX] web: missing required attribute for html field
To reproduce
============
* referrals -> configuration -> rewards
* try creating a new reward keeping description empty
* here description is required html field
* traceback on clicking save
Problem
=======
in case of html field, `this.data[fieldName]` is an object `Markup{''}`,
so `!this.data[fieldName]` is always `false` as objects are considered
as true value in JS.
Solution
========
in case of html, check the length of the Markup object
opw-3469539
closes odoo/odoo#134365
X-original-commit: dce8e1a8b6137c035488240f8004b870b73c8d51
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Abdelouahab Laaroussi (abla) <abla@odoo.com>
Co-authored-by: Niyas Raphy <https://github.com/niyasraphy>
This commit is contained in:
committed by
Abdelouahab (abla)
co-authored by
Niyas Raphy <https://github.com/niyasraphy>
parent
707f6cb92e
commit
37cc5266f9
@@ -335,6 +335,11 @@ export class Record extends DataPoint {
|
||||
case "integer":
|
||||
case "monetary":
|
||||
continue;
|
||||
case "html":
|
||||
if (this._isRequired(fieldName) && this.data[fieldName].length === 0) {
|
||||
unsetRequiredFields.push(fieldName);
|
||||
}
|
||||
break;
|
||||
case "one2many":
|
||||
case "many2many": {
|
||||
const list = this.data[fieldName];
|
||||
|
||||
@@ -57,6 +57,32 @@ QUnit.module("Fields", ({ beforeEach }) => {
|
||||
assert.strictEqual(target.querySelector(".o_field_html").textContent, "some text");
|
||||
});
|
||||
|
||||
QUnit.test("html field with required attribute", async function (assert) {
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
resId: 1,
|
||||
serverData,
|
||||
arch: /* xml */ `<form><field name="txt" required="1"/></form>`,
|
||||
});
|
||||
|
||||
const textarea = target.querySelector(".o_field_html textarea");
|
||||
assert.ok(textarea, "should have a text area");
|
||||
|
||||
await editInput(textarea, null, "");
|
||||
assert.strictEqual(textarea.value, "");
|
||||
|
||||
await clickSave(target);
|
||||
assert.strictEqual(
|
||||
target.querySelector(".o_notification_title").textContent,
|
||||
"Invalid fields: "
|
||||
);
|
||||
assert.strictEqual(
|
||||
target.querySelector(".o_notification_content").innerHTML,
|
||||
"<ul><li>txt</li></ul>"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("html fields are correctly rendered (edit)", async (assert) => {
|
||||
await makeView({
|
||||
type: "form",
|
||||
|
||||
Reference in New Issue
Block a user