Skip to content

Commit 8312f53

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 8312f53

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/util/fields.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,19 @@ 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, '{0}', '{1}')
417+
WHERE model = '{2}'
418+
AND depends LIKE '%{3}%'
419+
AND state = 'manual'
420+
AND compute IS NOT NULL
421+
""".format(
422+
old, new, model, old
423+
)
424+
)
412425

413426
if table_exists(cr, "ir_translation"):
414427
cr.execute(

0 commit comments

Comments
 (0)