[18.0] mail_quoted_reply: sent reply only appears in chatter after page reload

Aperta Adatta ai principianti
#276 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
74/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, python
Ambito
backend, frontend

Direzione di ricerca

Inizia da static/src/message_model.esm.js e confronta il relativo callback onClose con Chatter.onCloseFullComposerCallback in mail/static/src/chatter/web_portal/chatter.js e chatter/web/chatter_patch.js. Verifica come funziona l’API di aggiornamento del thread in mail/static/src/core/common/thread_model.js; il lavoro è completato quando una risposta citata inviata appare immediatamente nel chatter, mentre l’abbandono della procedura guidata non attiva un aggiornamento.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Module

mail_quoted_reply (18.0.1.0.0)

Describe the bug

After sending a quoted reply via the "Reply" message action, the composer wizard closes, but the new message does not appear in the chatter. It only becomes visible after a full page reload. A normal message sent from the chatter (including via the full composer) appears immediately.

To reproduce
  1. Install mail_quoted_reply on Odoo 18.0.
  2. Open any record with a chatter that has an incoming email or comment.
  3. Click the "Reply" action on that message.
  4. Send the email from the composer wizard.

Current behavior: The wizard closes and the chatter stays unchanged.
Expected behavior: The sent reply appears in the chatter immediately, like it does after closing the native full composer.

Root cause

In static/src/message_model.esm.js, the onClose callback of doAction does:

await self.store.env.services["mail.store"].Thread.getOrFetch(thread, ["messages"]);
self.store.env.bus.trigger("update-messages");

Neither call refreshes the thread in 18.0:

  • Thread.getOrFetch(data) in mail/static/src/core/common/thread_model.js is just return this.get(data);. It returns the local record and never does an RPC, and the second argument is ignored.
  • Nothing in 18.0 listens for the update-messages bus event anymore.
Suggested fix

Do what the native chatter does when the full composer closes (Chatter.onCloseFullComposerCallback → thread.fetchData(requestList) in mail/static/src/chatter/web_portal/chatter.js and chatter/web/chatter_patch.js). Also skip the refresh when the wizard is discarded:

import {Message} from "@mail/core/common/message_model";
import {patch} from "@web/core/utils/patch";

patch(Message.prototype, {
    async messageReply(message) {
        const thread = message.thread;
        const action = await this.store.env.services.orm.call(
            "mail.message",
            "reply_message",
            [message.id]
        );
        await this.store.env.services.action.doAction(action, {
            onClose: async (...args) => {
                // [] = "X"/Escape, [{special: true}] = Discard -> nothing was sent
                const discarded = args.length === 0 || args[0]?.special;
                if (discarded || !thread?.id) {
                    return;
                }
                if (thread.fetchData) {
                    await thread.fetchData(["messages", "scheduledMessages"]);
                } else {
                    await thread.fetchNewMessages();
                }
            },
        });
    },
});

We run this as a small companion module on Odoo 18.0 Enterprise, and the reply now shows up in the chatter right after sending.

Lingua principale
Python
Stelle
36
Fork
180
Merge medio
4g 2h
PR unite (30g)
14

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OCA/mail

Tutte le issue di OCA/mail

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.