[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 <rco@odoo.com>
Signed-off-by: Nicolas Danhier (nda) <nda@odoo.com>
This commit is contained in:
nda
2023-11-25 01:23:20 +00:00
parent b478c42beb
commit dd94201d0f
2 changed files with 7 additions and 7 deletions
@@ -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 = '<p>comment</p>'
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):
+2 -2
View File
@@ -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)