[IMP] doc: remove calls to @api.multi and @api.one
Those two decorators are removed/deprecated since recent commits but some references remained in the documentation. api.multi is deprecated since https://github.com/odoo/odoo/commit/cc62447a44c2cf4e2edaf8a1f6d94520e799ddd9 api.one was removed with https://github.com/odoo/odoo/commit/407f1f6cdb87a59bbad9f853078d7345cdf9f60c closes odoo/odoo#35261 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
This commit is contained in:
@@ -5,11 +5,10 @@
|
||||
diff --git a/openacademy/models.py b/openacademy/models.py
|
||||
--- a/openacademy/models.py
|
||||
+++ b/openacademy/models.py
|
||||
@@ -14,6 +14,20 @@ class Course(models.Model):
|
||||
@@ -14,6 +14,19 @@ class Course(models.Model):
|
||||
session_ids = fields.One2many(
|
||||
'openacademy.session', 'course_id', string="Sessions")
|
||||
|
||||
+ @api.multi
|
||||
|
||||
+ def copy(self, default=None):
|
||||
+ default = dict(default or {})
|
||||
+
|
||||
|
||||
@@ -19,12 +19,11 @@ Index: addons/openacademy/wizard.py
|
||||
===================================================================
|
||||
--- addons.orig/openacademy/wizard.py
|
||||
+++ addons/openacademy/wizard.py
|
||||
@@ -12,3 +12,8 @@
|
||||
@@ -12,3 +12,7 @@
|
||||
session_id = fields.Many2one('openacademy.session',
|
||||
string="Session", required=True, default=_default_session)
|
||||
attendee_ids = fields.Many2many('res.partner', string="Attendees")
|
||||
+
|
||||
+ @api.multi
|
||||
+ def subscribe(self):
|
||||
+ self.session_id.attendee_ids |= self.attendee_ids
|
||||
+ return {}
|
||||
|
||||
@@ -15,22 +15,21 @@ Index: addons/openacademy/wizard.py
|
||||
===================================================================
|
||||
--- addons.orig/openacademy/wizard.py
|
||||
+++ addons/openacademy/wizard.py
|
||||
@@ -6,14 +6,15 @@ class Wizard(models.TransientModel):
|
||||
@@ -6,13 +6,14 @@ class Wizard(models.TransientModel):
|
||||
_name = 'openacademy.wizard'
|
||||
_description = "Wizard: Quick Registration of Attendees to Sessions"
|
||||
|
||||
|
||||
- def _default_session(self):
|
||||
- return self.env['openacademy.session'].browse(self._context.get('active_id'))
|
||||
+ def _default_sessions(self):
|
||||
+ return self.env['openacademy.session'].browse(self._context.get('active_ids'))
|
||||
|
||||
|
||||
- session_id = fields.Many2one('openacademy.session',
|
||||
- string="Session", required=True, default=_default_session)
|
||||
+ session_ids = fields.Many2many('openacademy.session',
|
||||
+ string="Sessions", required=True, default=_default_sessions)
|
||||
attendee_ids = fields.Many2many('res.partner', string="Attendees")
|
||||
|
||||
@api.multi
|
||||
|
||||
def subscribe(self):
|
||||
- self.session_id.attendee_ids |= self.attendee_ids
|
||||
+ for session in self.session_ids:
|
||||
|
||||
@@ -595,12 +595,8 @@ on self to treat each record.
|
||||
for record in self:
|
||||
record.do_cool_stuff()
|
||||
|
||||
Avoid to use ``api.one`` decorator : this will probably not do what you expected,
|
||||
and extending a such method is not as easy than a *api.multi* method, since it
|
||||
returns a list of result (ordered by recordset ids).
|
||||
|
||||
For performance issue, when developping a 'stat button' (for instance), do not
|
||||
perform a ``search`` or a ``search_count`` in a loop in a ``api.multi`` method. It
|
||||
perform a ``search`` or a ``search_count`` in a loop. It
|
||||
is recommended to use ``read_group`` method, to compute all value in only one request.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -588,8 +588,7 @@ return lists of ids, there is also a decorator managing this:
|
||||
No effect if the method is called in new API style, but transforms the
|
||||
recordset into a list of ids when called from the old API style::
|
||||
|
||||
>>> @api.multi
|
||||
... @api.returns('self')
|
||||
>>> @api.returns('self')
|
||||
... def some_method(self):
|
||||
... return self
|
||||
>>> new_style_model = env['a.model'].browse(1, 2, 3)
|
||||
@@ -1165,9 +1164,9 @@ Porting from the old API to the new API
|
||||
* **remove** all ``onchange`` methods on computed fields. Computed fields are
|
||||
automatically re-computed when one of their dependencies is changed, and
|
||||
that is used to auto-generate ``onchange`` by the client
|
||||
* the decorators :func:`~odoo.api.model` and :func:`~odoo.api.multi` are
|
||||
* the decorator :func:`~odoo.api.model` is
|
||||
for bridging *when calling from the old API context*, for internal or pure
|
||||
new-api (e.g. compute) they are useless
|
||||
new-api (e.g. compute) it is useless
|
||||
* remove :attr:`~odoo.models.Model._default`, replace by ``default=``
|
||||
parameter on corresponding fields
|
||||
* if a field's ``string=`` is the titlecased version of the field name::
|
||||
@@ -1186,8 +1185,6 @@ Porting from the old API to the new API
|
||||
* the normal new-api import is ``from odoo import fields, models``. If
|
||||
compatibility decorators are necessary, use ``from odoo import api,
|
||||
fields, models``
|
||||
* avoid the :func:`~odoo.api.one` decorator, it probably does not do what
|
||||
you expect
|
||||
* remove explicit definition of :attr:`~odoo.models.Model.create_uid`,
|
||||
:attr:`~odoo.models.Model.create_date`,
|
||||
:attr:`~odoo.models.Model.write_uid` and
|
||||
|
||||
@@ -15,7 +15,7 @@ Index: coalroller/coalroller/models/res_partner.py
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ coalroller/coalroller/models/res_partner.py
|
||||
@@ -0,0 +1,22 @@
|
||||
@@ -0,0 +1,21 @@
|
||||
+# -*- coding: utf-8 -*-
|
||||
+from odoo import api, models
|
||||
+from odoo.addons.iap import jsonrpc, InsufficientCreditError
|
||||
@@ -25,7 +25,6 @@ Index: coalroller/coalroller/models/res_partner.py
|
||||
+DEFAULT_ENDPOINT = 'http://localhost:8070'
|
||||
+class Partner(models.Model):
|
||||
+ _inherit = 'res.partner'
|
||||
+ @api.multi
|
||||
+ def action_partner_coalroll(self):
|
||||
+ # fetch the user's token for our service
|
||||
+ user_token = self.env['iap.account'].get('coalroller')
|
||||
|
||||
Reference in New Issue
Block a user