diff options
| author | Xavier Morel <xmo@odoo.com> | 2020-01-08 14:42:49 +0000 |
|---|---|---|
| committer | Xavier Morel <xmo@odoo.com> | 2020-03-23 10:53:34 +0000 |
| commit | d418bff698f1601d7d3b2d1579d785e47f4f47d1 (patch) | |
| tree | 2b7662daa84b83975b33208d949e0315861ce196 /odoo/exceptions.py | |
| parent | af67c53582d4e35c9b3ad0549550cde54acd33e3 (diff) | |
[FIX] core: make accessing fields from __str__ possible
Because CacheMiss calls str() on the record it's given, it's not
possible to override __str__ and get field values: on the first cache
miss (= the first field access) we're going to blow the stack:
* any random field is accessed
* and faults
* which creates a CacheMiss
* which stringifies the record
* which accesses a field
* which faults
* which creates a CacheMiss
* etc...
Fix:
* move the basic Model's stringification to repr(), which is
implicitly called on str() if no __str__ is specified, for historical
reasons we were doing the opposite
* use repr() when initialising CacheMiss
closes odoo/odoo#42966
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Diffstat (limited to 'odoo/exceptions.py')
| -rw-r--r-- | odoo/exceptions.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/odoo/exceptions.py b/odoo/exceptions.py index 17a3d89ede8..93a0a84e20f 100644 --- a/odoo/exceptions.py +++ b/odoo/exceptions.py @@ -104,7 +104,7 @@ class CacheMiss(except_orm, KeyError): """ def __init__(self, record, field): - super(CacheMiss, self).__init__("%s.%s" % (str(record), field.name)) + super(CacheMiss, self).__init__("%r.%s" % (record, field.name)) class MissingError(except_orm): |
