Skip to content

Commit ae9030b

Browse files
committed
[REF] test_lint: check overwrites of create()
Fix some examples to match the method definition of Model.create(). closes #12527 Related: odoo/odoo#202106 Related: odoo/enterprise#81599 Signed-off-by: Krzysztof Magusiak (krma) <[email protected]>
1 parent 8db2fbc commit ae9030b

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

content/administration/odoo_sh/getting_started/first_module.rst

+10-9
Original file line numberDiff line numberDiff line change
@@ -481,15 +481,16 @@ Add
481481
.. code-block:: python
482482
483483
@api.model
484-
def create(self, values):
485-
if 'name' in values:
486-
values['name'] = unidecode(values['name'])
487-
return super(my_module, self).create(values)
488-
489-
def write(self, values):
490-
if 'name' in values:
491-
values['name'] = unidecode(values['name'])
492-
return super(my_module, self).write(values)
484+
def create(self, vals_list):
485+
for vals in vals_list:
486+
if 'name' in vals:
487+
vals['name'] = unidecode(vals['name'])
488+
return super().create(vals_list)
489+
490+
def write(self, vals):
491+
if 'name' in vals:
492+
vals['name'] = unidecode(vals['name'])
493+
return super().write(vals)
493494
494495
Adding a Python dependency requires a module version increase for the platform to install it.
495496

content/contributing/development/coding_guidelines.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,8 @@ Symbols and Conventions
955955
...
956956
957957
# CRUD methods (and name_search, _search, ...) overrides
958-
def create(self, values):
958+
@api.model
959+
def create(self, vals_list):
959960
...
960961
961962
# Action methods

content/developer/tutorials/server_framework_101/12_inheritance.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ specific business logic::
5959
...
6060

6161
@api.model
62-
def create(self, vals):
62+
def create(self, vals_list):
6363
# Do some business logic, modify vals...
6464
...
6565
# Then call super to execute the parent method
66-
return super().create(vals)
66+
return super().create(vals_list)
6767

6868
The decorator :func:`~odoo.api.model` is necessary for the :meth:`~odoo.models.Model.create`
6969
method because the content of the recordset ``self`` is not relevant in the context of creation,

0 commit comments

Comments
 (0)