Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Odoo 17 How to expand attachments by default? (CUSTOM CODE)

Subscriure's

Get notified when there's activity on this post

This question has been flagged
attachmentodoo17CE
2 Respostes
2352 Vistes
Avatar
Apiuser

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?

0
Avatar
Descartar
Avatar
Andry Ang
Best Answer

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,

});

1
Avatar
Descartar
Apiuser
Autor

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.

Avatar
Apiuser
Autor Best Answer

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;
},
});
0
Avatar
Descartar
Andry Ang

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

Apiuser
Autor

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.

Andry Ang

sure, thanks!

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
this is my travel agency and we are a travel manager
attachment
Avatar
0
de nov. 25
3
Odoo Community V17
odoo17CE
Avatar
Avatar
Avatar
2
de jul. 25
3074
Acounting and, Repporting tabs are missing to my accounting module, How to display them? Solved
odoo17CE
Avatar
Avatar
1
de març 25
2223
ReferenceError: ComboConfiguratorPopup is not defined
odoo17CE
Avatar
Avatar
1
de des. 24
2000
how to override tools.mail.email_normalize
odoo17CE
Avatar
Avatar
1
de des. 24
2559
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now