[FIX] core: infinite recursion when accessing Html field on new record
closes odoo/odoo#127718 Related: odoo/enterprise#43815 Signed-off-by: Raphael Collet <rco@odoo.com>
This commit is contained in:
@@ -3260,6 +3260,14 @@ class TestHtmlField(common.TransactionCase):
|
||||
self.assertEqual(record.comment5, '',
|
||||
"should be sanitized (not in groups)")
|
||||
|
||||
# extra test with new record having 'record' as origin
|
||||
new_record = record.new(origin=record)
|
||||
new_record.with_user(bypass_user).comment5
|
||||
|
||||
# this was causing an infinite recursion (see explanation in fields.py)
|
||||
new_record.invalidate_recordset()
|
||||
new_record.with_user(internal_user).comment5
|
||||
|
||||
|
||||
class TestMagicFields(common.TransactionCase):
|
||||
|
||||
|
||||
+5
-1
@@ -2002,7 +2002,11 @@ class Html(_String):
|
||||
if record.user_has_groups('base.group_sanitize_override'):
|
||||
return value
|
||||
|
||||
original_value = record[self.name]
|
||||
# This may cause an infinite recursion when accessing the field on a
|
||||
# new record. Indeed, if record has no value in cache, we default
|
||||
# on the field's value on record._origin and convert it to the
|
||||
# cache format, which ends up here, accessing the field on record!
|
||||
original_value = record[self.name] if record.id else None
|
||||
if original_value:
|
||||
# Note that sanitize also normalize
|
||||
original_value_sanitized = html_sanitize(original_value, **sanitize_vals)
|
||||
|
||||
Reference in New Issue
Block a user