[IMP] mail: do not call getViews for chatter fields

Before this commit, in form views, a call to "getViews" was done
for each field in the div with className "oe_chatter" (i.e.
"message_ids", "message_follower_ids" and "activity_ids"). Those
calls were unnecessary since those fields are displayed with a
custom widget (the Chatter) anyway.

Part-of: odoo/odoo#87522
This commit is contained in:
Aaron Bohy
2022-04-29 09:57:45 +02:00
committed by Denis Ledoux
parent f573e93bb2
commit 89112f8ecf
+27
View File
@@ -4,6 +4,8 @@ import BasicView from 'web.BasicView';
const mailWidgets = ['kanban_activity'];
const chatterFields = ["message_ids", "message_follower_ids", "activity_ids"];
BasicView.include({
init: function () {
this._super.apply(this, arguments);
@@ -62,4 +64,29 @@ BasicView.include({
_hasField(fieldName) {
return !!this.fieldsInfo[this.viewType][fieldName];
},
/**
* Override to mark chatter fields inside the "oe_chatter" div such that we
* don't fetch their sub views, as we don't need them. Without this, those
* subviews would be loaded as there is no "widget" set on those fields.
*
* @override
*/
_processNode(node, fv) {
if (node.tag === "div" && node.attrs.class && node.attrs.class.includes("oe_chatter")) {
const viewType = fv.type;
const fieldsInfo = fv.fieldsInfo[viewType];
const fields = fv.viewFields;
for (const child of node.children) {
if (child.tag === 'field' && chatterFields.includes(child.attrs.name)) {
const attrs = { ...child.attrs, modifiers: {}, __no_fetch: true };
const fieldName = attrs.name;
fieldsInfo[fieldName] = this._processField(viewType, fields[fieldName], attrs);
} else {
this._processNode(child, fv);
}
}
return false;
}
return this._super(...arguments);
},
});