콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
1214 화면

In odoo 15 I used to do this via js via editing this:

isAttachmentBoxVisibleInitially: (
this._getFieldOption('message_ids', 'open_attachments', true) ||
this._getFieldOption('message_follower_ids', 'open_attachments', false)
),

But in odoo 17 this makes no sense. I found this in chatter.js

static defaultProps = {
compactHeight: false,
hasActivities: true,
hasFollowers: true,
hasMessageList: true,
isChatterAside: false,
hasParentReloadOnAttachmentsChanged: false,
hasParentReloadOnFollowersUpdate: false,
hasParentReloadOnMessagePosted: false,
isAttachmentBoxVisibleInitially: false,
isInFormSheetBg: true,
threadId: false,
};

But so far I've been unable to make it work, everytime i try changing the inherited js i get either a blank page with an error (bottom-left) "An error ocurred while loading javascript modules, you may find more information in the devtools console", or odoo loads as usual and the same error appears. And there is no info on the error apart from the js not loading (checked via logs and via f12 in the browser).

Has anyone this or anything similar?

아바타
취소
베스트 답변

Hi Apiuser,

Would you like to test snippet from me? I tried to replace the default compileChatter function and it works. Maybe you can try with other inheritance that you can do, but this also works. Might not be the best solution, but hopefully it helps.

/* @odoo-module */

import { registry } from "@web/core/registry";

import { evaluateExpr } from "@web/core/py_js/py";

import { append, createElement, setAttributes } from "@web/core/utils/xml";


// rewrite the default compileChatter function to set isAttachmentBoxVisibleInitially to true

function compileChatterOpenAttachments(node, params) {

let hasActivities = false;

let hasFollowers = false;

let hasMessageList = false;

let hasParentReloadOnAttachmentsChanged;

let hasParentReloadOnFollowersUpdate = false;

let hasParentReloadOnMessagePosted = false;

let isAttachmentBoxVisibleInitially = true; // here we change the initial value

for (const childNode of node.children) {

const options = evaluateExpr(childNode.getAttribute("options") || "{}");

switch (childNode.getAttribute("name")) {

case "activity_ids":

hasActivities = true;

break;

case "message_follower_ids":

hasFollowers = true;

hasParentReloadOnFollowersUpdate = Boolean(options["post_refresh"]);

isAttachmentBoxVisibleInitially =

isAttachmentBoxVisibleInitially || Boolean(options["open_attachments"]);

break;

case "message_ids":

hasMessageList = true;

hasParentReloadOnAttachmentsChanged = options["post_refresh"] === "always";

hasParentReloadOnMessagePosted = Boolean(options["post_refresh"]);

isAttachmentBoxVisibleInitially =

isAttachmentBoxVisibleInitially || Boolean(options["open_attachments"]);

break;

}

}

const chatterContainerXml = createElement("t");

setAttributes(chatterContainerXml, {

"t-component": "__comp__.mailComponents.Chatter",

hasActivities,

hasFollowers,

hasMessageList,

hasParentReloadOnAttachmentsChanged,

hasParentReloadOnFollowersUpdate,

hasParentReloadOnMessagePosted,

isAttachmentBoxVisibleInitially,

threadId: "__comp__.props.record.resId or undefined",

threadModel: "__comp__.props.record.resModel",

webRecord: "__comp__.props.record",

saveRecord: "() => __comp__.save and __comp__.save()",

});

const chatterContainerHookXml = createElement("div");

chatterContainerHookXml.classList.add("o-mail-ChatterContainer", "o-mail-Form-chatter");

append(chatterContainerHookXml, chatterContainerXml);

return chatterContainerHookXml;

}


// remove the default chatter_compiler from the registry and add the new one

registry.category("form_compilers").remove("chatter_compiler",)

registry.category("form_compilers").add("chatter_compiler", {

selector: "div.oe_chatter",

fn: compileChatterOpenAttachments,

});

아바타
취소
작성자

This solution does work but didn't want to overwrite all the file. But you are right I was looking in the wrong place, I was looking in the chatter.js and needed to check form_compiler.js and overwrite function compileChatter.

작성자 베스트 답변

For anyone wondering, I finally solved it like so:

patch(FormCompiler.prototype, {
compile(node, params) {
const res = super.compile(node, params);
const chatterContainerXml = res.querySelector("t[t-component='__comp__.mailComponents.Chatter']");
if (chatterContainerXml) {
chatterContainerXml.setAttribute("isAttachmentBoxVisibleInitially", "true");
}
return res;
},
});
아바타
취소

Great that it give you a little bit of insights for your challenge.
If you don't mind, you could give an upvote to my answer or mark it as solve I guess.

Good Luck

작성자

Well, I wanted to mark my answer as solved, as it is what I was looking for, but apparently i can't. I upvotted yours.

sure, thanks!

관련 게시물 답글 화면 활동
2
7월 25
1615
1
3월 25
1173
1
12월 24
1068
1
12월 24
1429
2
8월 24
2851