[IMP] web: allow Record override

With this fix, it will be possible to override Record.

Part-of: odoo/odoo#97739
This commit is contained in:
Audric Onockx (auon)
2022-09-13 07:37:56 +02:00
committed by Laurent Stukkens (LTU)
parent 3036c7dc47
commit 927ec413c5
@@ -872,7 +872,7 @@ export class StaticList extends DataPoint {
if (record) {
record.__syncData();
} else {
record = new Record(this.model, {
record = new this.model.constructor.Record(this.model, {
handle: dp.id,
onRecordWillSwitchMode: this.onRecordWillSwitchMode,
mode: "readonly",
@@ -1299,6 +1299,7 @@ export class RelationalModel extends Model {
}
}
const Record = this.constructor.Record;
const newRecord = new Record(this, {
handle,
viewType: params.viewMode,
@@ -1370,7 +1371,7 @@ export class RelationalModel extends Model {
loadParams.context = params.context;
}
const state = this.root ? this.root.exportState() : {};
const nextRoot = new Record(
const nextRoot = new this.constructor.Record(
this,
{
__bm_load_params__: loadParams,
@@ -1446,7 +1447,8 @@ export class RelationalModel extends Model {
context: params.context,
},
});
return new Record(this, params, state);
return new this.constructor.Record(this, params, state);
}
}
RelationalModel.services = ["action", "dialog", "notification"];
RelationalModel.Record = Record;