← Back to Pull requests

[18.0][ADD] mail_message_import #1966

Open
unknown opened this pull request with 406 lines diff across 5 files
View on GitHub
unknown unknown commented on Nov 04, 2026 13:54 UTC
Author

Description

New module that gives Odoo one inbox for the messages a company receives on any channel (email, WhatsApp...). Each channel will be its own module.

The module only receives, identifies and groups messages. It does not decide what a conversation means: other modules do that (for example, turning the documents received into sale or purchase orders). Without one of those modules, a conversation is simply closed once it has been grouped.

What it adds

  • Receiving channels: the email addresses or phone numbers where messages arrive.

  • Senders and authorized addresses: the phones and email addresses allowed to send messages on behalf of each sender.

  • - A message from any other address waits in Unknown senders.
    - A user can assign it to a sender and authorize the address in the same step.
  • Conversations:

  • - Consecutive messages from a sender are grouped.
    - They are processed together once the sender has been silent for a few minutes (configurable per company), so clarifications and corrections are read in context.
    - They are queued and retried with backoff.
    - When they keep failing, they are reported as incidents.
  • Panel: one card per receiving channel showing unknown senders, incidents, conversations with errors or being processed, and the messages of the last days.

  • Forwarded emails:

  • - .eml attachments are unpacked.
    - .msg attachments are unpacked too when the optional extract-msg library is installed.

    Extension points

    A channel module:

  • adds its value to mail.message.import.channel.channel_type;

  • reports the state of its channels in _channel_state();

  • defines how its addresses are compared in mail.message.import.address._normalize_address();

  • hands over each message with mail.message.import.message._receive_message().
  • A processing module:

  • overrides mail.message.import.conversation._process_messages(), which receives the messages in chronological order, with their files downloaded and forwarded emails unpacked;

  • can declare its own expected errors and incident types through _expected_errors(), _failure_incident_type() and mail.message.import.incident._retry_types().
  • Technical notes

  • Depends only on mail.

  • Open conversations are unique per channel, address and sender, enforced by a partial unique index. Messages that arrive at the same time join the same conversation.

  • The cron claims conversations with FOR UPDATE SKIP LOCKED, so several workers can run it safely.
  • Follow-up PRs

  • OCA/social:

  • - mail_message_import_email: incoming mail servers as receiving channels. (#1960)
    - mail_message_import_whatsapp: mail_gateway_whatsapp gateways as receiving channels. (#1962)
  • OCA/ai:

  • - ai_message_import: processes the conversations with ai_connection. (https://github.com/OCA/ai/pull/150)

    How to test

    1. Install the module. The administrator gets the Message Import Manager group.
    2. Go to Message Import > Configuration and check senders, authorized addresses and settings.
    3. Messages only arrive through a channel module (see the follow-up PRs). Until then, the tests cover reception, sender identification, grouping, retries, incidents and the panel.

    @BinhexTeam

    Diff: 406 lines (+304 / -102) across 5 files Reviewer: edescalona Review duration: 38312m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 406 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.359
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #1966"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.8% (MEDIUM) · Higher = larger blast radius
    44.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23.9% · Safe to merge
    23.9%
    Repository