[IMP] web: core: ModelFieldSelector improved extensibility
Before this commit, when the ModelFieldSelector was updated, it only transmitted its chain as a string But in some cases we do need the full chain as Object to check on fields that are part of it. After this commit, this is the case. Part-of: odoo/odoo#115799
This commit is contained in:
@@ -4,7 +4,7 @@ import { useModelField } from "./model_field_hook";
|
||||
import { useUniquePopover } from "./unique_popover_hook";
|
||||
import { ModelFieldSelectorPopover } from "./model_field_selector_popover";
|
||||
|
||||
import { Component, onWillStart, onWillUpdateProps, useState } from "@odoo/owl";
|
||||
import { Component, onWillStart, onWillUpdateProps, toRaw, useState } from "@odoo/owl";
|
||||
|
||||
export class ModelFieldSelector extends Component {
|
||||
setup() {
|
||||
@@ -40,13 +40,13 @@ export class ModelFieldSelector extends Component {
|
||||
}
|
||||
return this.modelField.loadChain(resModel, fieldName);
|
||||
}
|
||||
|
||||
async update(fieldName, isFieldSelected) {
|
||||
this.state.fieldName = fieldName;
|
||||
this.state.isDirty = !isFieldSelected;
|
||||
this.state.chain = await this.loadChain(this.props.resModel, fieldName);
|
||||
if (isFieldSelected) {
|
||||
await this.props.update(fieldName);
|
||||
} else {
|
||||
this.state.chain = await this.loadChain(this.props.resModel, fieldName);
|
||||
await this.props.update(fieldName, toRaw(this.state.chain));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ export class ModelFieldSelector extends Component {
|
||||
popoverClass: "o_popover_field_selector",
|
||||
onClose: () => {
|
||||
if (this.state.isDirty) {
|
||||
this.props.update(this.state.fieldName);
|
||||
this.props.update(this.state.fieldName, toRaw(this.state.chain));
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user