'test the behavior of related fields traversing new records.'

@mute_logger('odoo.addons.base.ir.ir_model')
def test_42_new_related(self):

    access = self.env.ref('test_new_api.access_discussion')
    access.write({'perm_read': False})
    env = self.env(user=self.env.ref('base.user_demo'))
    self.assertEqual(env.user.login, 'demo')
    discussion = env['test_new_api.discussion'].new({'name': 'Stuff'})
    message = env['test_new_api.message'].new({'discussion': discussion})
    self.assertEqual(message.discussion, discussion)
    self.assertNotEqual(message.sudo().env, message.env)
    self.assertEqual(message.discussion_name, discussion.name)
