From 381c0f02280ee389ac2c4eb79266b893d8725c58 Mon Sep 17 00:00:00 2001 From: "Louis Wicket (wil)" Date: Tue, 23 Aug 2022 12:08:40 +0000 Subject: [PATCH] [IMP] mail: model_field: use this.model instead of record.constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since be0fc43bbd0664340d555f2156630870e3548466, a reference to the model is passed to ModelField constructor. This commit replaces all occurrences of record.constructor with this.model (shorter and more straightforward). closes odoo/odoo#98687 Signed-off-by: Sébastien Theys (seb) --- addons/mail/static/src/model/model_field.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/mail/static/src/model/model_field.js b/addons/mail/static/src/model/model_field.js index 2301de1d732..b749ab4eb5a 100644 --- a/addons/mail/static/src/model/model_field.js +++ b/addons/mail/static/src/model/model_field.js @@ -146,7 +146,7 @@ export class ModelField { */ if (this.identifying) { this.readonly = true; - if (model.identifyingMode === 'and') { + if (this.model.identifyingMode === 'and') { this.required = true; } } @@ -225,8 +225,7 @@ export class ModelField { */ computeRelated(record) { const [relationName, relatedFieldName] = this.related.split('.'); - const model = record.constructor; - const relationField = model.__fieldMap.get(relationName); + const relationField = this.model.__fieldMap.get(relationName); if (relationField.relationType === 'many') { const newVal = []; for (const otherRecord of record[relationName]) { @@ -378,7 +377,7 @@ export class ModelField { } break; default: - throw new Error(`Field "${record.constructor.name}/${this.fieldName}"(${this.fieldType} type) does not support command "${commandName}"`); + throw new Error(`Field "${this.model.name}/${this.fieldName}"(${this.fieldType} type) does not support command "${commandName}"`); } } else if (this.fieldType === 'relation') { switch (commandName) { @@ -423,7 +422,7 @@ export class ModelField { } break; default: - throw new Error(`Field "${record.constructor.name}/${this.fieldName}"(${this.fieldType} type) does not support command "${commandName}"`); + throw new Error(`Field "${this.model.name}/${this.fieldName}"(${this.fieldType} type) does not support command "${commandName}"`); } } }