Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

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

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
chattermail.message
1 Responder
9745 Vistas
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
Mejor respuesta

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?

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
How to show message_type = notification in a portal chatter? Resuelto
chatter mail.message
Avatar
Avatar
1
sept 21
7617
Change Button Label in Chatter from "Send Message" to "Send e-mail" Resuelto
chatter
Avatar
Avatar
1
feb 25
2457
Chatter looks weird in 18.0 Resuelto
chatter
Avatar
Avatar
2
dic 24
3594
chat module
chatter
Avatar
0
nov 24
7747
How to prevent/avoid automatic subscription as follower to newly created records (with chatter) Resuelto
chatter
Avatar
Avatar
3
oct 25
5856
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

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