DEV Community

Mehedi Hassan Shifat
Mehedi Hassan Shifat

Posted on AI-assisted

Odoo can send an email with no recipient and tell you nothing

Odoo checks a mail template when you save it. After that, nothing checks it again. A field gets removed by an upgrade, a module is uninstalled, or an expression meets a record with an empty value, and the template breaks.

Disclosure: I make a paid Odoo module that tests templates (link at the bottom). The technique below works without it.

I tried it on Odoo 19: _generate_template with a broken placeholder in email_to returns an empty recipient and no error. The email just has nobody to go to. Calling _render_field on the same field raises the real error. (Subject and body failures do raise.)

So to test templates properly, render each field with _render_field, on more than one record, because a template like {{ object.parent_id.name.upper() }} works on a contact with a parent and fails on one without. Do it inside a savepoint you always roll back, so nothing is created or sent.

I built that into a module that checks every template and reports errors, placeholders left as text, and whole records printed as res.partner(36, 19). On the 33 standard templates of a demo database it raised no false alarm (31 OK, 2 skipped). It's called Email Template Checker, 19 EUR on the Apps Store: https://apps.odoo.com/apps/modules/19.0/email_template_checker/

It does not render attachments or PDF reports.

Top comments (0)