How to set default values with methods in Odoo?
You can use a lambda function like this:
name = fields.Char(
string='Name',
default=lambda self: self._get_default_name(),
)
@api.model
def _get_default_name(self):
return "test"
A simpler version for the @ChesuCR answer:
def _get_default_name(self):
return "test"
name = fields.Char(
string='Name',
default=_get_default_name,
)