mirror of
https://github.com/odoo/documentation.git
synced 2026-03-26 13:59:55 +07:00
[REF] test_lint: check overwrites of create()
Fix some examples to match the method definition of Model.create(). closes odoo/documentation#12527 Related: odoo/odoo#202106 Related: odoo/enterprise#81599 Signed-off-by: Krzysztof Magusiak (krma) <krma@odoo.com>
This commit is contained in:
@@ -481,15 +481,16 @@ Add
|
||||
.. code-block:: python
|
||||
|
||||
@api.model
|
||||
def create(self, values):
|
||||
if 'name' in values:
|
||||
values['name'] = unidecode(values['name'])
|
||||
return super(my_module, self).create(values)
|
||||
def create(self, vals_list):
|
||||
for vals in vals_list:
|
||||
if 'name' in vals:
|
||||
vals['name'] = unidecode(vals['name'])
|
||||
return super().create(vals_list)
|
||||
|
||||
def write(self, values):
|
||||
if 'name' in values:
|
||||
values['name'] = unidecode(values['name'])
|
||||
return super(my_module, self).write(values)
|
||||
def write(self, vals):
|
||||
if 'name' in vals:
|
||||
vals['name'] = unidecode(vals['name'])
|
||||
return super().write(vals)
|
||||
|
||||
Adding a Python dependency requires a module version increase for the platform to install it.
|
||||
|
||||
|
||||
@@ -955,7 +955,8 @@ Symbols and Conventions
|
||||
...
|
||||
|
||||
# CRUD methods (and name_search, _search, ...) overrides
|
||||
def create(self, values):
|
||||
@api.model
|
||||
def create(self, vals_list):
|
||||
...
|
||||
|
||||
# Action methods
|
||||
|
||||
@@ -59,11 +59,11 @@ specific business logic::
|
||||
...
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
def create(self, vals_list):
|
||||
# Do some business logic, modify vals...
|
||||
...
|
||||
# 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`
|
||||
method because the content of the recordset ``self`` is not relevant in the context of creation,
|
||||
|
||||
Reference in New Issue
Block a user