Skip to content

Commit 73e4424

Browse files
committed
[FIX] util/fields: update depends on rename
Currently we are not updating the dependencies for custom compute fields which leads to test crawler failure when it tries to access the view and give: KeyError: 'old_field_name'
1 parent 48bb075 commit 73e4424

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/util/fields.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,18 @@ def rename_field(cr, model, old, new, update_references=True, domain_adapter=Non
409409
name = "%s_%s" % (name, fid)
410410
cr.execute("UPDATE ir_model_data SET name=%s WHERE model='ir.model.fields' AND res_id=%s", [name, fid])
411411
cr.execute("UPDATE ir_property SET name=%s WHERE fields_id=%s", [new, fid])
412+
# Rename depends for custom compute fields
413+
cr.execute(
414+
"""
415+
UPDATE ir_model_fields
416+
SET depends = REPLACE(depends, %s, %s)
417+
WHERE model = %s
418+
AND CONCAT(',', depends, ',') LIKE %s
419+
AND state = 'manual'
420+
AND compute IS NOT NULL
421+
""",
422+
(old, new, model, "%," + old + ",%"),
423+
)
412424

413425
if table_exists(cr, "ir_translation"):
414426
cr.execute(

0 commit comments

Comments
 (0)