File tree 3 files changed +14
-12
lines changed
administration/odoo_sh/getting_started
developer/tutorials/server_framework_101
3 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -481,15 +481,16 @@ Add
481
481
.. code-block :: python
482
482
483
483
@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)
493
494
494
495
Adding a Python dependency requires a module version increase for the platform to install it.
495
496
Original file line number Diff line number Diff line change @@ -955,7 +955,8 @@ Symbols and Conventions
955
955
...
956
956
957
957
# CRUD methods (and name_search, _search, ...) overrides
958
- def create (self , values ):
958
+ @api.model
959
+ def create (self , vals_list ):
959
960
...
960
961
961
962
# Action methods
Original file line number Diff line number Diff line change @@ -59,11 +59,11 @@ specific business logic::
59
59
...
60
60
61
61
@api.model
62
- def create(self, vals ):
62
+ def create(self, vals_list ):
63
63
# Do some business logic, modify vals...
64
64
...
65
65
# Then call super to execute the parent method
66
- return super().create(vals )
66
+ return super().create(vals_list )
67
67
68
68
The decorator :func: `~odoo.api.model ` is necessary for the :meth: `~odoo.models.Model.create `
69
69
method because the content of the recordset ``self `` is not relevant in the context of creation,
You can’t perform that action at this time.
0 commit comments