[FIX] spreadsheet: fix name get assignation
Since d6a1aa63702132ffc59d2412c2a009912eba797a, a name get saved from the result of a pivot was stored with an incorrect `deferred`. The value stored was not the deferred, but the result of `new Deferred().resolve`, which is undefined. This revision fixes this issue by storing the correct deferred. closes odoo/odoo#109472 X-original-commit: b3ad5ee64865dc7a3b84cae18cd37002f6d69a91 Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com> Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
This commit is contained in:
@@ -83,9 +83,11 @@ export class DisplayNameRepository {
|
||||
if (!this._displayNames[model]) {
|
||||
this._displayNames[model] = {};
|
||||
}
|
||||
const deferred = new Deferred();
|
||||
deferred.resolve(displayName);
|
||||
this._displayNames[model][id] = {
|
||||
state: "COMPLETED",
|
||||
deferred: new Deferred().resolve(displayName),
|
||||
deferred,
|
||||
value: displayName,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -127,6 +127,32 @@ QUnit.module("spreadsheet > Metadata Repository", {}, () => {
|
||||
assert.verifySteps(["name_get-A-[2]"]);
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"Assigning a result after triggering the request should not crash",
|
||||
async function (assert) {
|
||||
const orm = {
|
||||
silent: {
|
||||
call: async (model, method, args) => {
|
||||
const ids = args[0];
|
||||
assert.step(`${method}-${model}-[${ids.join(",")}]`);
|
||||
return ids.map((id) => [id, id.toString()]);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const metadataRepository = new MetadataRepository(orm);
|
||||
|
||||
assert.throws(() => metadataRepository.getRecordDisplayName("A", 1));
|
||||
assert.verifySteps([]);
|
||||
metadataRepository.setDisplayName("A", 1, "test");
|
||||
assert.strictEqual(metadataRepository.getRecordDisplayName("A", 1), "test");
|
||||
|
||||
await nextTick();
|
||||
assert.verifySteps(["name_get-A-[1]"]);
|
||||
assert.strictEqual(metadataRepository.getRecordDisplayName("A", 1), "1");
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"Name_get will retry with one id by request in case of failure",
|
||||
async function (assert) {
|
||||
|
||||
Reference in New Issue
Block a user