[REF] test_lint: check overwrites of create()
Fix some examples to match the method definition of Model.create().
This commit is contained in:
parent
57977d2a10
commit
282ef3f402
@ -481,15 +481,15 @@ Add
|
|||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, values):
|
def create(self, vals_list):
|
||||||
if 'name' in values:
|
if 'name' in vals_list:
|
||||||
values['name'] = unidecode(values['name'])
|
vals_list['name'] = unidecode(vals_list['name'])
|
||||||
return super(my_module, self).create(values)
|
return super().create(vals_list)
|
||||||
|
|
||||||
def write(self, values):
|
def write(self, vals):
|
||||||
if 'name' in values:
|
if 'name' in vals:
|
||||||
values['name'] = unidecode(values['name'])
|
vals['name'] = unidecode(vals['name'])
|
||||||
return super(my_module, self).write(values)
|
return super().write(vals)
|
||||||
|
|
||||||
Adding a Python dependency requires a module version increase for the platform to install it.
|
Adding a Python dependency requires a module version increase for the platform to install it.
|
||||||
|
|
||||||
|
@ -904,7 +904,8 @@ Symbols and Conventions
|
|||||||
...
|
...
|
||||||
|
|
||||||
# CRUD methods (and name_search, _search, ...) overrides
|
# CRUD methods (and name_search, _search, ...) overrides
|
||||||
def create(self, values):
|
@api.model
|
||||||
|
def create(self, vals_list):
|
||||||
...
|
...
|
||||||
|
|
||||||
# Action methods
|
# Action methods
|
||||||
|
@ -59,11 +59,11 @@ specific business logic::
|
|||||||
...
|
...
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals_list):
|
||||||
# Do some business logic, modify vals...
|
# Do some business logic, modify vals...
|
||||||
...
|
...
|
||||||
# Then call super to execute the parent method
|
# Then call super to execute the parent method
|
||||||
return super().create(vals)
|
return super().create(vals_list)
|
||||||
|
|
||||||
The decorator :func:`~odoo.api.model` is necessary for the :meth:`~odoo.models.Model.create`
|
The decorator :func:`~odoo.api.model` is necessary for the :meth:`~odoo.models.Model.create`
|
||||||
method because the content of the recordset ``self`` is not relevant in the context of creation,
|
method because the content of the recordset ``self`` is not relevant in the context of creation,
|
||||||
|
Loading…
Reference in New Issue
Block a user