import re with open('addons/education_lms/tests/test_education_lms.py', 'r') as f: text = f.read() text = text.replace( " res = course_a.with_user(self.user_student_a).read(['name'])", " self.env.invalidate_all()\n res = course_a.with_user(self.user_student_a).read(['name'])" ) with open('addons/education_lms/tests/test_education_lms.py', 'w') as f: f.write(text)