diff options
| author | Adrian Torres <adt@odoo.com> | 2019-07-10 14:59:37 +0200 |
|---|---|---|
| committer | Adrian Torres <adt@odoo.com> | 2019-07-17 14:13:12 +0200 |
| commit | 4b38cc6590abcb58a0ca102a06063eb3db7ac1f4 (patch) | |
| tree | cfd11739fc6b4c0cb4b23b54cc6badad4bf5c55e /doc | |
| parent | f6fdde96bddfedf8764cd8a73089e44340d476ae (diff) | |
[REM] *: calls to @api.multi
Multi is the default api for methods, it is not necessary to explicitly
decorate methods with it, adds clutter and most people use it because
they see that the rest of the code uses it.
Done with `find . -type f -name '*.py' | xargs sed -i '/@api.multi/d'`
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/howtos/backend.rst | 1 | ||||
| -rw-r--r-- | doc/howtos/profilecode.rst | 1 | ||||
| -rw-r--r-- | doc/reference/guidelines.rst | 13 | ||||
| -rw-r--r-- | doc/reference/orm.rst | 10 |
4 files changed, 4 insertions, 21 deletions
diff --git a/doc/howtos/backend.rst b/doc/howtos/backend.rst index a5d03443f52..90300568c8f 100644 --- a/doc/howtos/backend.rst +++ b/doc/howtos/backend.rst @@ -789,7 +789,6 @@ method should simply set the value of the field to compute on every record in name = fields.Char(compute='_compute_name') - @api.multi def _compute_name(self): for record in self: record.name = str(random.randint(1, 1e6)) diff --git a/doc/howtos/profilecode.rst b/doc/howtos/profilecode.rst index ed6d2640648..1251c052ff7 100644 --- a/doc/howtos/profilecode.rst +++ b/doc/howtos/profilecode.rst @@ -20,7 +20,6 @@ its sub-called methods. from odoo.tools.profiler import profile [...] @profile('/temp/prof.profile') - @api.multi def mymethod(...) This produces a file called /temp/prof.profile diff --git a/doc/reference/guidelines.rst b/doc/reference/guidelines.rst index de9723121ff..c1a282cf19f 100644 --- a/doc/reference/guidelines.rst +++ b/doc/reference/guidelines.rst @@ -586,13 +586,11 @@ Programming in Odoo Make your method work in batch ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -When adding a function, make sure it can process multiple records. Typically, -such methods are decorated with the ``api.multi`` decorator. Then you will have -to iterate on ``self`` to treat each record. +When adding a function, make sure it can process multiple records by iterating +on self to treat each record. .. code-block:: python - @api.multi def my_method(self) for record in self: record.do_cool_stuff() @@ -607,7 +605,6 @@ is recommended to use ``read_group`` method, to compute all value in only one re .. code-block:: python - @api.multi def _compute_equipment_count(self): """ Count the number of equipement per category """ equipment_data = self.env['hr.equipment'].read_group([('category_id', 'in', self.ids)], ['category_id'], ['category_id']) @@ -943,8 +940,8 @@ Symbols and Conventions - Selection method: the selection method pattern is *_selection_<field_name>* - Onchange method : the onchange method pattern is *_onchange_<field_name>* - Constraint method : the constraint method pattern is *_check_<constraint_name>* - - Action method : an object action method is prefix with *action_*. Its decorator is - ``@api.multi``, but since it use only one record, add ``self.ensure_one()`` + - Action method : an object action method is prefix with *action_*. + Since it uses only one record, add ``self.ensure_one()`` at the beginning of the method. - In a Model attribute order should be @@ -979,7 +976,6 @@ Symbols and Conventions event_type = fields.Selection(string="Type", selection='_selection_type') # compute and search fields, in the same order of fields declaration - @api.multi @api.depends('seats_max', 'registration_ids.state', 'registration_ids.nb_register') def _compute_seats(self): ... @@ -1002,7 +998,6 @@ Symbols and Conventions ... # Action methods - @api.multi def action_validate(self): self.ensure_one() ... diff --git a/doc/reference/orm.rst b/doc/reference/orm.rst index 20440d5c414..47e8b1c9d61 100644 --- a/doc/reference/orm.rst +++ b/doc/reference/orm.rst @@ -565,16 +565,6 @@ Two decorators can expose a new-style method to the old API: # can be called as old_style_model.some_method(cr, uid, a_value, context=context) -:func:`~odoo.api.multi` - the method is exposed as taking a list of ids (possibly empty), its - "old API" signature is ``cr, uid, ids, *arguments, context``:: - - @api.multi - def some_method(self, a_value): - pass - # can be called as - old_style_model.some_method(cr, uid, [id1, id2], a_value, context=context) - Note that a method `create` decorated with :func:`~odoo.api.model` will always be called with a single dictionary. A method `create` decorated with the variant :func:`~odoo.api.model_create_multi` will always be called with a list of dicts. |
