odoo-exception-warning (ODR8101)
Preview (since 0.16.2.2) · Related issues · View source
Derived from the odoo linter.
Fix is sometimes available.
This rule is unstable and in preview. The --preview flag is required for use.
What it does
Checks for from odoo.exceptions import Warning.
Why is this bad?
odoo.exceptions.Warning is a deprecated alias for odoo.exceptions.UserError,
and was removed in Odoo 15.0.
Example
Use instead:
Fix safety
The fix rewrites the import to UserError and renames every use of the imported name.
It is marked as unsafe because other modules may import Warning from this module, and
a name only referenced dynamically (e.g. via getattr) is not renamed. As an exception,
dropping a Warning as UserError alias changes no name at all and is safe. No fix is
offered when UserError is already bound to something other than
odoo.exceptions.UserError.