OD105 missing-super¶
An ORM override never calls super().
| Category | Severity | Series | Needs the index |
|---|---|---|---|
| Correctness | Error | all | no |
What it reports¶
A model class that defines create, write, unlink, copy or default_get and whose method
contains no super() call.
Why it matters¶
Odoo builds a model's class from every module that extends it, in dependency order, and each
override reaches the next one through super(). An override that returns without it ends the
chain: the overrides of other modules never run, so tracking, followers, computed values or
constraints they add are silently skipped, and when it does not reach the ORM either, nothing is
created, written, deleted or copied. Calling models.Model.write(self, vals) directly reaches the
ORM but still skips every module in between.
Any super() call in the method counts, even one in a branch that does not always run, so an
override that calls the parent on one path only is not reported. Other methods are not checked:
many are meant to be replaced entirely.
Example¶
class ResPartner(models.Model):
_inherit = "res.partner"
def write(self, vals):
if vals.get("email"):
vals["email"] = vals["email"].strip().lower()
return models.Model.write(self, vals)
The values are written, but every other write() of res.partner is skipped, including the one in
base itself and the tracking that mail adds.
class ResPartner(models.Model):
_inherit = "res.partner"
def write(self, vals):
if vals.get("email"):
vals["email"] = vals["email"].strip().lower()
return super().write(vals)