[REF] web: allow overriding Many2OneField activeActions

Prior to this commit it was not possible to override `computeActiveActions`,
which prevents acting when onWillUpdateProps is triggered as both are private to
the setup function.

task-3001470

X-original-commit: c785327fedd4fa94884af692c21985663a79c454
This commit is contained in:
Laurent Stukkens (LTU)
2022-10-11 13:06:05 +02:00
parent 9b483a6d89
commit d0987e0b25
@@ -51,18 +51,10 @@ export class Many2OneField extends Component {
this.autocompleteContainerRef.el.querySelector("input").focus();
};
const computeActiveActions = (props) => {
this.state.activeActions = {
create: props.canCreate,
createEdit: props.canCreateEdit,
write: props.canWrite,
};
};
this.state = useState({
isFloating: !this.props.value,
});
computeActiveActions(this.props);
this.computeActiveActions(this.props);
this.openMany2X = useOpenMany2XRecord({
resModel: this.relation,
@@ -102,7 +94,7 @@ export class Many2OneField extends Component {
onWillUpdateProps(async (nextProps) => {
this.state.isFloating = !nextProps.value;
computeActiveActions(nextProps);
this.computeActiveActions(nextProps);
});
}
@@ -151,6 +143,13 @@ export class Many2OneField extends Component {
autocomplete_container: this.autocompleteContainerRef,
};
}
computeActiveActions(props) {
this.state.activeActions = {
create: props.canCreate,
createEdit: props.canCreateEdit,
write: props.canWrite,
};
}
getDomain() {
return this.domain.toList(this.context);
}