Use self.debug_mode():
self.debug_mode()
my_form = Form(self.env['my.model']) my_form.field_name = 'test'```