From dd94201d0f8ef650641f5fe08d3732551565d21f Mon Sep 17 00:00:00 2001 From: nda Date: Wed, 22 Nov 2023 16:33:16 -0400 Subject: [PATCH] [FIX] core: perform one validation in convert_to_column for HTML field This commit removes an unnecessary field validation for HTML field. closes odoo/odoo#143307 Signed-off-by: Raphael Collet Signed-off-by: Nicolas Danhier (nda) --- odoo/addons/test_new_api/tests/test_new_fields.py | 10 +++++----- odoo/fields.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/odoo/addons/test_new_api/tests/test_new_fields.py b/odoo/addons/test_new_api/tests/test_new_fields.py index 0b38546f1e2..d2f5370f1e0 100644 --- a/odoo/addons/test_new_api/tests/test_new_fields.py +++ b/odoo/addons/test_new_api/tests/test_new_fields.py @@ -3278,25 +3278,25 @@ class TestHtmlField(common.TransactionCase): # in a perfect world this should be 1, but at the moment the value is # sanitized more than once during creation of the record - self.assertEqual(patch.call_count, 3) + self.assertEqual(patch.call_count, 2) # new value needs to be validated, so it is sanitized once more record.comment2 = '

comment

' - self.assertEqual(patch.call_count, 4) + self.assertEqual(patch.call_count, 3) # the value is already sanitized for flushing record.flush_recordset() - self.assertEqual(patch.call_count, 4) + self.assertEqual(patch.call_count, 3) # value coming from db does not need to be sanitized record.invalidate_recordset() record.comment2 - self.assertEqual(patch.call_count, 4) + self.assertEqual(patch.call_count, 3) # value coming from db during an onchange does not need to be sanitized new_record = record.new(origin=record) new_record.comment2 - self.assertEqual(patch.call_count, 4) + self.assertEqual(patch.call_count, 3) class TestMagicFields(common.TransactionCase): diff --git a/odoo/fields.py b/odoo/fields.py index d00e98d317d..3b9b4501781 100644 --- a/odoo/fields.py +++ b/odoo/fields.py @@ -1686,7 +1686,7 @@ class _String(Field): return func(term) def convert_to_column(self, value, record, values=None, validate=True): - cache_value = self.convert_to_cache(value, record) + cache_value = self.convert_to_cache(value, record, validate) if cache_value is None: return None if callable(self.translate): @@ -2016,7 +2016,7 @@ class Html(_String): _description_strip_classes = property(attrgetter('strip_classes')) def convert_to_column(self, value, record, values=None, validate=True): - return super().convert_to_column(self._convert(value, record, True), record, values, validate) + return super().convert_to_column(self._convert(value, record, validate=True), record, values, validate=False) def convert_to_cache(self, value, record, validate=True): return self._convert(value, record, validate)