diff --git a/odoo/models.py b/odoo/models.py index 483c79521fe..fe3a9dd4781 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -4978,20 +4978,17 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})): filename, lineno = frame_codeinfo(currentframe(), 1) _logger.warning("Comparing apples and oranges: %r == %r (%s:%s)", self, other, filename, lineno) - return False + return NotImplemented return self._name == other._name and set(self._ids) == set(other._ids) - def __ne__(self, other): - return not self == other - def __lt__(self, other): if not isinstance(other, BaseModel) or self._name != other._name: - raise TypeError("Mixing apples and oranges: %s < %s" % (self, other)) + return NotImplemented return set(self._ids) < set(other._ids) def __le__(self, other): if not isinstance(other, BaseModel) or self._name != other._name: - raise TypeError("Mixing apples and oranges: %s <= %s" % (self, other)) + return NotImplemented # these are much cheaper checks than a proper subset check, so # optimise for checking if a null or singleton are subsets of a # recordset @@ -5001,12 +4998,12 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})): def __gt__(self, other): if not isinstance(other, BaseModel) or self._name != other._name: - raise TypeError("Mixing apples and oranges: %s > %s" % (self, other)) + return NotImplemented return set(self._ids) > set(other._ids) def __ge__(self, other): if not isinstance(other, BaseModel) or self._name != other._name: - raise TypeError("Mixing apples and oranges: %s >= %s" % (self, other)) + return NotImplemented if not other or other in self: return True return set(self._ids) >= set(other._ids)