inheritable-method-lambda (E8148)#
A field passes a method object as default or domain.
What it does#
Reports default= and domain= given a method of the class.
Why is this bad?#
The field keeps a reference to this exact function, so overriding the method in an inheriting class has no effect. A lambda looks the method up at call time.
Example#
def _default_user(self): ...
user_id = fields.Many2one("res.users", default=_default_user)
Use instead:
user_id = fields.Many2one("res.users", default=lambda self: self._default_user())