Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

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

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
chattermail.message
1 Beantwoorden
9765 Weergaven
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
Annuleer
Avatar
Adrien
Beste antwoord

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
Annuleer
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?

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
How to show message_type = notification in a portal chatter? Opgelost
chatter mail.message
Avatar
Avatar
1
sep. 21
7640
Change Button Label in Chatter from "Send Message" to "Send e-mail" Opgelost
chatter
Avatar
Avatar
1
feb. 25
2464
Chatter looks weird in 18.0 Opgelost
chatter
Avatar
Avatar
2
dec. 24
3613
chat module
chatter
Avatar
0
nov. 24
7755
How to prevent/avoid automatic subscription as follower to newly created records (with chatter) Opgelost
chatter
Avatar
Avatar
3
okt. 25
5867
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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