[FIX] web: binary field filename in form view not updated with pager
Steps to reproduce ================== - Go to a form view with a binary field, or add one with studio - Upload a file a.txt to a record - Upload a file b.txt to another record - Switch between both records with the pager - The filename is not updated opw-3208810 closes odoo/odoo#116323 X-original-commit: 90515916e8adb3edb560d73ec8889ad52319cc1d Signed-off-by: Luca Vitali <luvi@odoo.com> Signed-off-by: Hubert Van De Walle <huvw@odoo.com>
This commit is contained in:
@@ -29,9 +29,7 @@ export class BinaryField extends Component {
|
||||
fileName: this.props.record.data[this.props.fileNameField] || "",
|
||||
});
|
||||
onWillUpdateProps((nextProps) => {
|
||||
if (nextProps.readonly) {
|
||||
this.state.fileName = nextProps.record.data[nextProps.fileNameField] || "";
|
||||
}
|
||||
this.state.fileName = nextProps.record.data[nextProps.fileNameField] || "";
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -430,4 +430,46 @@ QUnit.module("Fields", (hooks) => {
|
||||
});
|
||||
assert.containsNone(target, "button.fa-download");
|
||||
});
|
||||
|
||||
QUnit.test("BinaryField filename is updated when using the pager", async function (assert) {
|
||||
serverData.models.partner.records.push(
|
||||
{
|
||||
id: 1,
|
||||
document: "abc",
|
||||
foo: "abc.txt",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
document: "def",
|
||||
foo: "def.txt",
|
||||
}
|
||||
);
|
||||
await makeView({
|
||||
serverData,
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
arch: `
|
||||
<form>
|
||||
<field name="document" filename="foo"/>
|
||||
<field name="foo"/>
|
||||
</form>
|
||||
`,
|
||||
resIds: [1, 2],
|
||||
resId: 1,
|
||||
});
|
||||
|
||||
assert.strictEqual(
|
||||
target.querySelector(".o_field_binary input[type=text]").value,
|
||||
"abc.txt",
|
||||
'displayed value should be "abc.txt"'
|
||||
);
|
||||
|
||||
await click(target.querySelector(".o_pager_next"));
|
||||
|
||||
assert.strictEqual(
|
||||
target.querySelector(".o_field_binary input[type=text]").value,
|
||||
"def.txt",
|
||||
'displayed value should be changed to "def.txt"'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user