summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/field_wrapper.js
diff options
context:
space:
mode:
authorMichael Mattiello (mcm) <mcm@odoo.com>2020-03-27 10:49:43 +0000
committerMichael Mattiello (mcm) <mcm@odoo.com>2020-03-31 06:13:11 +0000
commitcde276a1efe39175bb35aa6cc09f1aaa00009c6d (patch)
treea5c4c15d955ceed4b974497e9dd5ded449755d67 /addons/web/static/src/js/fields/field_wrapper.js
parent30f4f610bf146638b71a0b2a936f8ae9acef502e (diff)
[REF] web: add missing features of abstract field
This commit adds missing features of AbstractField written in owl. task id: 2193996
Diffstat (limited to 'addons/web/static/src/js/fields/field_wrapper.js')
-rw-r--r--addons/web/static/src/js/fields/field_wrapper.js46
1 files changed, 32 insertions, 14 deletions
diff --git a/addons/web/static/src/js/fields/field_wrapper.js b/addons/web/static/src/js/fields/field_wrapper.js
index 0b808d0c732..8cf747d84e9 100644
--- a/addons/web/static/src/js/fields/field_wrapper.js
+++ b/addons/web/static/src/js/fields/field_wrapper.js
@@ -33,8 +33,6 @@ odoo.define('web.FieldWrapper', function (require) {
this._data.res_id = record.res_id;
this._data.model = record.model;
this._data.mode = options.mode || "readonly";
- this._data._isValid = true;
- this._data.lastSetValue = undefined;
this._data.formatType = this._data.attrs.widget in field_utils.format ?
this._data.attrs.widget :
this._data.field.type;
@@ -43,9 +41,19 @@ odoo.define('web.FieldWrapper', function (require) {
if (this._data.attrs.decorations) {
this._data.resetOnAnyFieldChange = true;
}
- for (const key in this._data) {
+
+ for (let key in this._data) {
Object.defineProperty(this, key, {
- get: () => (this.el ? this.componentRef.comp : this._data)[key],
+ get: () => {
+ if (this.el) {
+ if (key === 'dataPointID') {
+ return this.componentRef.comp.dataPointId;
+ } else if (key === 'res_id') {
+ return this.componentRef.comp.resId;
+ }
+ }
+ return (this.el ? this.componentRef.comp : this._data)[key];
+ },
});
}
}
@@ -60,9 +68,6 @@ odoo.define('web.FieldWrapper', function (require) {
get fieldDependencies() {
return this.Component.fieldDependencies;
}
- get resetOnAnyFieldChange() {
- return this.Component.resetOnAnyFieldChange;
- }
get specialData() {
return this.Component.specialData;
}
@@ -80,11 +85,11 @@ odoo.define('web.FieldWrapper', function (require) {
// Public
//----------------------------------------------------------------------
- activate(options) {
- return this.componentRef.comp.activate(options);
+ activate() {
+ return this.componentRef.comp.activate(...arguments);
}
commitChanges() {
- return this.componentRef.comp.commitChanges();
+ return this.componentRef.comp.commitChanges(...arguments);
}
getFocusableElement() {
return $(this.componentRef.comp.focusableElement);
@@ -99,7 +104,7 @@ odoo.define('web.FieldWrapper', function (require) {
if (this.componentRef.comp) {
return this.componentRef.comp.isSet;
}
- // because of the willStart, the real field widget may not be
+ // because of the willStart, the real field component may not be
// instantiated yet when the renderer first asks if it is set
// (only the wrapper is instantiated), so we instantiate one
// with the same props, get its 'isSet' status, and destroy it.
@@ -111,14 +116,27 @@ odoo.define('web.FieldWrapper', function (require) {
isValid() {
return this.componentRef.comp.isValid;
}
+ removeInvalidClass() {
+ return this.componentRef.comp.removeInvalidClass(...arguments);
+ }
reset(record, event) {
return this.update({record, event});
}
- setIDForLabel(id) {
- return this.componentRef.comp.setIDForLabel(id);
+ setIDForLabel() {
+ return this.componentRef.comp.setIdForLabel(...arguments);
+ }
+ setInvalidClass() {
+ return this.componentRef.comp.setInvalidClass(...arguments);
}
updateModifiersValue(modifiers) {
- return this.componentRef.comp.updateModifiersValue(modifiers);
+ if (this.props.options.attrs) {
+ this.props.options.attrs.modifiersValue = modifiers || {};
+ } else {
+ const viewType = this.props.options.viewType || 'default';
+ const fieldsInfo = this.props.record.fieldsInfo[viewType];
+ fieldsInfo[this.props.fieldName].modifiersValue = modifiers || {};
+ }
+ this.componentRef.comp.props = this.props;
}
}