[REF] web: x2manyField: ensure we don't pass the props viewMode if not set

Before this commit, we passed the viewMode props to the X2many field everytime.
Since that props is optional, we don't have to pass it if it is not a string (null or undefined)

This allows to display a field set as invisible in studio

Part-of: odoo/odoo#115799
This commit is contained in:
Lucas Perais
2023-04-03 13:55:16 +02:00
parent a28c3c6897
commit 47699f3e47
@@ -43,7 +43,7 @@ export class X2ManyField extends Component {
this.isMany2Many
);
this.archInfo = this.props.views[this.props.viewMode] || {};
this.archInfo = this.props.views?.[this.props.viewMode] || {};
const { activeActions, creates } = this.archInfo;
if (this.props.viewMode === "kanban") {
@@ -277,11 +277,13 @@ export const x2ManyField = {
addLabel: attrs["add-label"],
context: dynamicInfo.context,
domain: dynamicInfo.domain,
viewMode,
views,
crudOptions: options,
string,
};
if (viewMode) {
props.views = views;
props.viewMode = viewMode;
}
if (widget) {
props.widget = widget;
}