From d54b30bb7feed52de86f4302dc4a01f2d4009782 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vanhaudenard?= <jev@odoo.com>
Date: Tue, 11 May 2021 12:35:43 +0000
Subject: [PATCH] [FIX] expression: Better Binaries logs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When building a domain `(=|!=)` with
a Binary field stored in attachment and
the right part of the domain is not null,
the full binary content is logged, giving
the logs a huge size.

Now, the content of the binary is cropped to
20 chars as it is useless to log more.

opw-2527629

closes odoo/odoo#70640

Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
---
 odoo/osv/expression.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/odoo/osv/expression.py b/odoo/osv/expression.py
index d490e391e63f..987c598a03b8 100644
--- a/odoo/osv/expression.py
+++ b/odoo/osv/expression.py
@@ -116,6 +116,7 @@ start the server specifying the ``--unaccent`` flag.
 import collections
 
 import logging
+import reprlib
 import traceback
 from functools import partial
 from zlib import crc32
@@ -1087,7 +1088,7 @@ class expression(object):
                     push(create_substitution_leaf(leaf, ('id', inselect_operator, (subselect, params)), model, internal=True))
                 else:
                     _logger.error("Binary field '%s' stored in attachment: ignore %s %s %s",
-                                  field.string, left, operator, right)
+                                  field.string, left, operator, reprlib.repr(right))
                     leaf.leaf = TRUE_LEAF
                     push(leaf)
 
-- 
GitLab