[FIX] web: allow empty domains on arch

Since the new views, the empty domains on the archs were not be taking
into account.

Now, the empty domains are taken into account, this was the legacy
behaviour

closes odoo/odoo#97791

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
Jorge Pinna Puissant
2022-08-10 19:15:51 +02:00
parent f213f7e349
commit ee9b28b546
3 changed files with 33 additions and 3 deletions
@@ -100,7 +100,7 @@ function mapActiveFieldsToFieldsInfo(activeFields, fields, viewType, env) {
}
Widget = Widget || fieldRegistry.get("abstract");
let domain;
if (fieldDescr.domain && fieldDescr.domain.toString() !== "[]") {
if (fieldDescr.domain) {
domain = fieldDescr.domain.toString();
}
let mode = fieldDescr.viewMode;
+3 -1
View File
@@ -201,7 +201,6 @@ Field.parseFieldNode = function (node, models, modelName, viewType, jsClass) {
name,
viewType,
context: node.getAttribute("context") || "{}",
domain: node.getAttribute("domain") || "[]",
string: node.getAttribute("string") || field.string,
help: node.getAttribute("help"),
widget,
@@ -216,6 +215,9 @@ Field.parseFieldNode = function (node, models, modelName, viewType, jsClass) {
options: evaluateExpr(node.getAttribute("options") || "{}"),
alwaysInvisible: modifiers.invisible === true || modifiers.column_invisible === true,
};
if (node.getAttribute("domain")) {
fieldInfo.domain = node.getAttribute("domain");
}
for (const attribute of node.attributes) {
if (attribute.name in Field.forbiddenAttributeNames) {
throw new Error(Field.forbiddenAttributeNames[attribute.name]);
@@ -4042,6 +4042,33 @@ QUnit.module("Views", (hooks) => {
assert.containsNone(document.body, ".modal", "there should not be a confirm modal");
});
QUnit.test("Domain: allow empty domain on fieldInfo", async function (assert) {
assert.expect(1);
serverData.models.partner.fields.product_id.domain = "[('display_name', '=', name)]";
await makeView({
type: "form",
resModel: "partner",
serverData,
arch: `
<form>
<header>
<field name="product_id" widget="statusbar" domain="[]"></field>
</header>
<sheet>
<group>
<field name="name"></field>
</group>
</sheet>
</form>`,
resId: 1,
mockRPC(route, args) {
if (args.method === "search_read") {
assert.strictEqual(JSON.stringify(args.kwargs.domain), "[]");
}
},
});
});
QUnit.test("discard form with specialdata", async function (assert) {
await makeView({
type: "form",
@@ -11643,7 +11670,8 @@ QUnit.module("Views", (hooks) => {
assert.containsOnce(target, ".o_form_editable");
assert.containsOnce(target, ".o_form_button_save");
assert.containsOnce(target, ".o_form_button_cancel");
});
}
);
QUnit.test("save a form view with an invisible required field", async function (assert) {
serverData.models.partner.fields.text = { string: "Text", type: "char", required: 1 };