[FIX] web: list.binary field should show filename

Steps to reproduce:

- Make any list binary field with filename attribute

Current behaviour:

- The binary file does not use the filename field

Expected behaviour:

- The binary file should use the filename field

Explanation:

After the updates of list-specific binary field [1], the list
binary cannot get the attributes field name of the record anymore.

[1] odoo/odoo#129631

closes odoo/odoo#130719

X-original-commit: ddfa65782a8ff59c07adcb8c56797c57a06789a0
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
tong-odoo
2023-08-03 19:31:59 +02:00
committed by Aaron Bohy
parent d8848e0147
commit 24edd423dd
2 changed files with 29 additions and 8 deletions
@@ -66,11 +66,6 @@ export class ListBinaryField extends BinaryField {
static template = "web.ListBinaryField";
}
export const listBinaryField = {
...BinaryField,
component: ListBinaryField,
};
export const binaryField = {
component: BinaryField,
displayName: _t("File"),
@@ -88,5 +83,10 @@ export const binaryField = {
}),
};
export const listBinaryField = {
...binaryField,
component: ListBinaryField,
};
registry.category("fields").add("binary", binaryField);
registry.category("fields").add("list.binary", listBinaryField);
@@ -386,7 +386,7 @@ QUnit.module("Fields", (hooks) => {
}
);
QUnit.test("Binary field in list view", async function (assert) {
QUnit.test("BinaryField in list view (formatter)", async function (assert) {
serverData.models.partner.records[0].document = BINARY_FILE;
await makeView({
@@ -395,7 +395,7 @@ QUnit.module("Fields", (hooks) => {
serverData,
arch: `
<tree>
<field name="document" filename="yooo"/>
<field name="document"/>
</tree>`,
resId: 1,
});
@@ -406,7 +406,28 @@ QUnit.module("Fields", (hooks) => {
);
});
QUnit.test("Binary field for new record has no download button", async function (assert) {
QUnit.test("BinaryField in list view with filename", async function (assert) {
serverData.models.partner.records[0].document = BINARY_FILE;
await makeView({
type: "list",
resModel: "partner",
serverData,
arch: `
<tree>
<field name="document" filename="foo" widget="binary"/>
<field name="foo"/>
</tree>`,
resId: 1,
});
assert.strictEqual(
target.querySelector(".o_data_row .o_data_cell").textContent,
"coucou.txt"
);
});
QUnit.test("BinaryField for new record has no download button", async function (assert) {
serverData.models.partner.fields.document.default = BINARY_FILE;
await makeView({
serverData,