Files
odoo-ai/addons/activeblue_ai
Carlos Garcia 70145c9e04 fix: chat attachment detection — 3-method fallback + deferred retry
ab_ai_mail.py: when a user sends a file via Odoo 18 Discuss, the zip
was going through /dispatch (text-only) instead of /upload, causing the
bot to respond "I'm unable to locate the zip file" because attachment_ids
was empty in the message_post override.

Root cause: Odoo 18 Discuss links file attachments to mail.message
records via three different mechanisms depending on the upload path, and
we only checked one (the Many2many relation table).

Fixes:
1. Three-method attachment detection in message_post:
   - Method 1: result.attachment_ids (Many2many relation table)
   - Method 2: ir.attachment with res_model='mail.message' (Odoo 15+ style)
   - Method 3: attachment IDs parsed from href URLs in the HTML body
2. Deferred retry in _agent_thread: if att_data is still empty but a
   message_id is known, sleep 1s then re-read via a fresh DB cursor so
   we see data committed after message_post returned (timing race fix)
3. Skip zero-byte attachments and warn instead of silently using them
4. Pass message_id to the background thread (new kwarg, backward compat)
5. Add debug logging so future issues can be diagnosed from Odoo logs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 22:01:38 -04:00
..