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

Chatter currently orders messages by id. Is there a way to order items by date?

Subscriure's

Get notified when there's activity on this post

This question has been flagged
chattermail.message
1 Respondre
9716 Vistes
Avatar
foo

Odoo 11. In the chatter dialog beneath a record, all the logs (from Log Note) are ordered by id. This is defined on the mail.message model:


```

class Message(models.Model):

""" Messages model: system notification (replacing res.log notifications),

comments (OpenChatter discussion) and incoming emails. """

_name = 'mail.message'

_description = 'Message'

_order = 'id desc'

```

Is there a way to order this by date? Simply inheriting the model and setting the _order did not work. eg. this is what I thought would work:

```

class Message(models.Model):

_inherit = 'mail.message'

_order = 'date desc'

```

Considering chatter has some Javascript involvement, I imagine there may be somewhere to change this in the javascript layer?

Thank you in advance! 

1
Avatar
Descartar
Avatar
Adrien
Best Answer

Hi,

I managed to do that the following way:

1. What you want is to modify the function _fetchDocumentMessages in JS file chat_manager.js from native 'mail' addon, in ChatManager class. Instead of sort by message id, you want to sort by date :

_fetchDocumentMessages : function (ids, options) {
var loaded_msgs = _.filter(messages, function (message) {
return _.contains(ids, message.id);
});
var loaded_msg_ids = _.pluck(loaded_msgs, 'id');

options = options || {};
if (options.force_fetch || _.difference(ids.slice(0, LIMIT), loaded_msg_ids).length) {
var ids_to_load = _.difference(ids, loaded_msg_ids).slice(0, LIMIT);

return this._rpc({
model: 'mail.message',
method: 'message_format',
args: [ids_to_load],
context: session.user_context,
})
.then(function (msgs) {
var processed_msgs = [];
_.each(msgs, function (msg) {
processed_msgs.push(add_message(msg, {silent: true}));
});
return _.sortBy(loaded_msgs.concat(processed_msgs), function (msg) {
//CUSTOM HERE: sort by date instead of id in native
return msg.date;
});
});
} else {
return $.when(loaded_msgs);
}
},

2. Thing is, the way ChatManager is defined, you cannot properly inherit it in your custom module (I can't explain exactly why, i am not JS expert)... In this case I found out it is not possible to use a "include" as usually done to overwrite only a JS class method.

3. So I copied / paste the whole chat_manager.js file from 'mail' module to my custom module, and made the previous modification in my pasted file

4. Then i told odoo to replace the native file by mine, by putting in the xml (note the expr in xpath and 'replace' position):

<template id="assets_backend" name="sort message by date assets" inherit_id="web.assets_backend">
<!--unable to inherit javascript properly. So whole script is replaced here-->
<!--see https://www.odoo.com/fr_FR/forum/aide-1/question/how-inheritance-of-a-js-mail-chat-manager-130963-->
<xpath expr="//script[@src='/mail/static/src/js/chat_manager.js']" position="replace">
<script src="/your_custom_module/static/src/js/chat_manager.js" type="text/javascript"/>
</xpath>

</template>
2
Avatar
Descartar
Techloyce

Yeah that is perfect solution for Odoov11 but I'm looking for version 13 can you please guide me how to do that..because there is no file in 'mail' as chat_manager.js

Aurel Balanay

Hi are you able to solve this in version 13?

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
How to show message_type = notification in a portal chatter? Solved
chatter mail.message
Avatar
Avatar
1
de set. 21
7570
Change Button Label in Chatter from "Send Message" to "Send e-mail" Solved
chatter
Avatar
Avatar
1
de febr. 25
2421
Chatter looks weird in 18.0 Solved
chatter
Avatar
Avatar
2
de des. 24
3550
chat module
chatter
Avatar
0
de nov. 24
7711
How to prevent/avoid automatic subscription as follower to newly created records (with chatter) Solved
chatter
Avatar
Avatar
3
d’oct. 25
5811
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