translation-required (ODOO049)
Preview (since 0.16.2.5) · Related issues · View source
Derived from the odoo linter.
This rule is unstable and in preview. The --preview flag is required for use.
What it does
Checks for user-facing string literals that reach the user without a translation call:
the body/subject of a message_post, and the message of a raised Odoo exception.
Why is this bad?
Chatter text and error messages are shown to users; a plain literal is displayed as-is for every language instead of being looked up in the translations.
Example
Use instead:
self.message_post(body=self.env._("Order confirmed"))
raise UserError(self.env._("Order cannot be confirmed"))
Interpolated literals ("..." % values, "...".format(values)) are flagged too: the
term must be translated before the values are interpolated.
The suggested translation call follows the configured odoo-version: self.env._ from
Odoo 18.0 on (and when no version is configured), the bare _ before that. This keeps
the suggestion consistent with prefer-env-translation (ODOO024), which only applies
from 18.0.
Files under a tests/ directory are ignored, matching pylint-odoo.