19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:30:27 +01:00
parent d1963a3c3a
commit 2d3ee4855a
7430 changed files with 2687981 additions and 2965473 deletions

View file

@ -0,0 +1,66 @@
import { expect, test } from "@odoo/hoot";
import { defineModels, fields, models, mountView } from "@web/../tests/web_test_helpers";
class Partner extends models.Model {
lines = fields.One2many({ relation: "lines_sections" });
_records = [
{
id: 1,
lines: [1, 2],
},
];
}
class LinesSections extends models.Model {
_name = "lines_sections";
display_type = fields.Char();
title = fields.Char();
int = fields.Integer();
_records = [
{
id: 1,
display_type: "line_section",
title: "firstSectionTitle",
int: 4,
},
{
id: 2,
display_type: false,
title: "recordTitle",
int: 5,
},
];
}
defineModels([Partner, LinesSections]);
test("basic rendering", async () => {
await mountView({
type: "form",
resModel: "partner",
resId: 1,
arch: `
<form>
<field name="lines" widget="section_one2many">
<list>
<field name="display_type" column_invisible="1" />
<field name="title" />
<field name="int" />
</list>
</field>
</form>
`,
});
expect(".o_field_x2many .o_list_renderer table.o_section_list_view").toHaveCount(1);
expect(".o_data_row").toHaveCount(2);
expect(".o_data_row:first").toHaveClass("o_is_line_section fw-bold");
expect(".o_data_row:eq(1)").not.toHaveClass("o_is_line_section fw-bold");
expect(".o_data_row:first").toHaveText("firstSectionTitle");
expect(".o_data_row:eq(1)").toHaveText("recordTitle 5");
expect(".o_data_row:first td[name=title]").toHaveAttribute("colspan", "3");
expect(".o_data_row:eq(1) td[name=title]").not.toHaveAttribute("colspan");
expect(".o_list_record_remove").toHaveCount(1);
expect(".o_is_line_section .o_list_record_remove").toHaveCount(0);
});

View file

@ -1,81 +0,0 @@
/** @odoo-module */
import { getFixture } from "@web/../tests/helpers/utils";
import { makeView, setupViewRegistries } from "@web/../tests/views/helpers";
QUnit.module("SectionOneToManyField", (hooks) => {
let serverData;
let target;
hooks.beforeEach(() => {
target = getFixture();
serverData = {
models: {
partner: {
fields: { lines: { type: "one2many", relation: "lines_sections" } },
records: [
{
id: 1,
lines: [1, 2],
},
],
},
lines_sections: {
fields: {
display_type: { type: "char" },
title: { type: "char", string: "Title" },
int: { type: "number", string: "integer" },
},
records: [
{
id: 1,
display_type: "line_section",
title: "firstSectionTitle",
int: 4,
},
{
id: 2,
display_type: false,
title: "recordTitle",
int: 5,
},
],
},
},
};
setupViewRegistries();
});
QUnit.test("basic rendering", async (assert) => {
await makeView({
type: "form",
resModel: "partner",
resId: 1,
serverData,
arch: `
<form>
<field name="lines" widget="section_one2many">
<tree>
<field name="display_type" invisible="1" />
<field name="title" />
<field name="int" />
</tree>
</field>
</form>
`,
});
assert.containsOnce(target, ".o_field_x2many .o_list_renderer table.o_section_list_view");
assert.containsN(target, ".o_data_row", 2);
const rows = target.querySelectorAll(".o_data_row");
assert.hasClass(rows[0], "o_is_line_section fw-bold");
assert.doesNotHaveClass(rows[1], "o_is_line_section fw-bold");
assert.strictEqual(rows[0].textContent, "firstSectionTitle");
assert.strictEqual(rows[1].textContent, "recordTitle5");
assert.strictEqual(rows[0].querySelector("td[name=title]").getAttribute("colspan"), "3");
assert.strictEqual(rows[1].querySelector("td[name=title]").getAttribute("colspan"), null);
assert.containsOnce(target, ".o_list_record_remove");
assert.containsNone(target, ".o_is_line_section .o_list_record_remove");
});
});

View file

@ -0,0 +1,5 @@
import { models } from "@web/../tests/web_test_helpers";
export class ResourceResource extends models.ServerModel {
_name = "resource.resource";
}

View file

@ -0,0 +1,10 @@
import { fields, models } from "@web/../tests/web_test_helpers";
export class ResourceTask extends models.Model {
_name = "resource.task";
display_name = fields.Char({ string: "Name" });
resource_ids = fields.Many2many({ string: "Resources", relation: "resource.resource" });
resource_id = fields.Many2one({ string: "Resource", relation: "resource.resource"});
resource_type = fields.Char({ string: "Resource Type" });
}

View file

@ -0,0 +1,12 @@
import { ResourceTask } from "./mock_server/mock_models/resource_task";
import { ResourceResource } from "./mock_server/mock_models/resource_resource";
import { defineModels } from "@web/../tests/web_test_helpers";
export const resourceModels = {
ResourceTask,
ResourceResource,
};
export function defineResourceModels() {
return defineModels(resourceModels);
}