[FIX] web: SampleServer: properly mock unity_web_search_read

Before this commit, many2one values were still returned as pairs
of id and display_name by unity read, whereas they should be
objects with keys id and display_name.

Part-of: odoo/odoo#133617
This commit is contained in:
Aaron Bohy
2023-08-31 09:04:58 +00:00
parent 573516e9c1
commit 660cde4298
2 changed files with 29 additions and 1 deletions
+11 -1
View File
@@ -608,9 +608,19 @@ export class SampleServer {
} else {
result = this._mockWebSearchRead({ ...params, fields });
}
// populate x2many values
// populate many2one and x2many values
for (const fieldName in params.specification) {
const field = this.data[params.model].fields[fieldName];
if (field.type === "many2one") {
for (const record of result.records) {
record[fieldName] = record[fieldName]
? {
id: record[fieldName][0],
display_name: record[fieldName][1],
}
: false;
}
}
if (field.type === "one2many" || field.type === "many2many") {
const relFields = Object.keys(params.specification[fieldName].fields || {});
if (relFields.length) {