diff options
| author | Adrian Torres <adt@odoo.com> | 2018-12-12 09:46:02 +0000 |
|---|---|---|
| committer | Adrian Torres <adt@odoo.com> | 2019-07-05 09:04:45 +0000 |
| commit | 9e71d57d11faf3fabd00b8a09188e9d4f9808c63 (patch) | |
| tree | 4dfda85fb19bf1f68954cadbd8a39bbb582ef775 /odoo/api.py | |
| parent | f5676fabea8a09f5702d00e75f3cf55f01ed5b22 (diff) | |
[REM] *: remove calls to `api.one` and adapt code
Adapt all code that was using `api.one` to recordset-style method and
remove any and all calls to `api.one` in preparation for its removal.
Diffstat (limited to 'odoo/api.py')
| -rw-r--r-- | odoo/api.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/odoo/api.py b/odoo/api.py index a08a12e297a..614101756a2 100644 --- a/odoo/api.py +++ b/odoo/api.py @@ -140,11 +140,11 @@ def constrains(*args): """ Decorates a constraint checker. Each argument must be a field name used in the check:: - @api.one @api.constrains('name', 'description') def _check_description(self): - if self.name == self.description: - raise ValidationError("Fields name and description must be different") + for record in self: + if record.name == record.description: + raise ValidationError("Fields name and description must be different") Invoked on the records on which one of the named fields has been modified. @@ -206,13 +206,13 @@ def depends(*args): pname = fields.Char(compute='_compute_pname') - @api.one @api.depends('partner_id.name', 'partner_id.is_company') def _compute_pname(self): - if self.partner_id.is_company: - self.pname = (self.partner_id.name or "").upper() - else: - self.pname = self.partner_id.name + for record in self: + if record.partner_id.is_company: + record.pname = (record.partner_id.name or "").upper() + else: + record.pname = record.partner_id.name One may also pass a single function as argument. In that case, the dependencies are given by calling the function with the field's model. |
