From 4b38cc6590abcb58a0ca102a06063eb3db7ac1f4 Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Wed, 10 Jul 2019 14:59:37 +0200 Subject: [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'` --- doc/reference/guidelines.rst | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'doc/reference/guidelines.rst') 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_* - Onchange method : the onchange method pattern is *_onchange_* - Constraint method : the constraint method pattern is *_check_* - - 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() ... -- cgit v1.2.3