[IMP] core: models __repr__ should show when ids is wrong
As a developer, when you craft your records set manually, and wrongly use the API and set something weird in `ids`, something else than a tuple of integers, `repr` should help you to understand you did something wrong. e.g. before ```py In [1]: env['res.partner']._browse(self.env, '(1,)', 'bar') Out[1]: res.partner(1,) ``` after ```py In [1]: env['res.partner']._browse(self.env, '(1,)', 'bar') Out[1]: res.partner'(1,)' ``` We could put an assert in `_browse` to make sure `ids` is a tuple of integers, but this is considered a non-stable change, as it will suddenly crashes when you will update Odoo while it wasn't the case before. closes odoo/odoo#118119 X-original-commit: f689c4f53fc4663b17c57bd1d704b9ffb9f11f8d Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
This commit is contained in:
+1
-1
@@ -5914,7 +5914,7 @@ class BaseModel(metaclass=MetaModel):
|
||||
return self.id or 0
|
||||
|
||||
def __repr__(self):
|
||||
return f"{self._name}{self._ids}"
|
||||
return f"{self._name}{self._ids!r}"
|
||||
|
||||
def __hash__(self):
|
||||
return hash((self._name, frozenset(self._ids)))
|
||||
|
||||
Reference in New Issue
Block a user