'test inverse computation of fields'

def test_13_inverse(self):

    Category = self.env['test_new_api.category']
    abel = Category.create({'name': 'Abel'})
    beth = Category.create({'name': 'Bethany'})
    cath = Category.create({'name': 'Catherine'})
    dean = Category.create({'name': 'Dean'})
    ewan = Category.create({'name': 'Ewan'})
    finn = Category.create({'name': 'Finnley'})
    gabe = Category.create({'name': 'Gabriel'})
    self.assertEqual(ewan.display_name, 'Ewan')
    ewan.display_name = 'Abel    /    Bethany    /    Catherine    /    Erwan'
    self.assertEqual(beth.parent, abel)
    self.assertEqual(cath.parent, beth)
    self.assertEqual(ewan.parent, cath)
    self.assertEqual(ewan.name, 'Erwan')
    record = self.env['test_new_api.compute.inverse']
    record.counts.update(compute=0, inverse=0)
    record = record.create({'foo': 'Hi'})
    self.assertEqual(record.foo, 'Hi')
    self.assertEqual(record.bar, 'Hi')
    self.assertEqual(record.counts, {'compute': 1, 'inverse': 0})
    record.counts.update(compute=0, inverse=0)
    record.write({'foo': 'Ho'})
    self.assertEqual(record.foo, 'Ho')
    self.assertEqual(record.bar, 'Ho')
    self.assertEqual(record.counts, {'compute': 1, 'inverse': 0})
    record.counts.update(compute=0, inverse=0)
    record = record.create({'bar': 'Hi'})
    self.assertEqual(record.foo, 'Hi')
    self.assertEqual(record.bar, 'Hi')
    self.assertEqual(record.counts, {'compute': 0, 'inverse': 1})
    record.counts.update(compute=0, inverse=0)
    record.write({'bar': 'Ho'})
    self.assertEqual(record.foo, 'Ho')
    self.assertEqual(record.bar, 'Ho')
    self.assertEqual(record.counts, {'compute': 0, 'inverse': 1})
