Skip to content
Snippets Groups Projects
Commit 775eaae9 authored by Raphael Collet's avatar Raphael Collet
Browse files

[IMP] test_inherit: add test case, redefine Many2one field in inherited model

parent 5e5c73e7
No related branches found
No related tags found
No related merge requests found
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
access_test_inherit_mother,access_test_inherit_mother,model_test_inherit_mother,,1,1,1,1
access_test_inherit_daugther,access_test_inherit_daugther,model_test_inherit_daugther,,1,1,1,1
access_test_inherit_daughter,access_test_inherit_daughter,model_test_inherit_daughter,,1,1,1,1
......@@ -17,7 +17,7 @@ class mother(models.Model):
# We want to inherits from the parent model and we add some fields
# in the child object
class daughter(models.Model):
_name = 'test.inherit.daugther'
_name = 'test.inherit.daughter'
_inherits = {'test.inherit.mother': 'template_id'}
template_id = fields.Many2one('test.inherit.mother', 'Template',
......@@ -55,4 +55,11 @@ class mother(models.Model):
# extend again the selection of the state field
state = fields.Selection(selection_add=[('d', 'D')])
class daughter(models.Model):
_inherit = 'test.inherit.daughter'
# simply redeclare the field without adding any option
template_id = fields.Many2one()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
......@@ -10,20 +10,28 @@ class test_inherits(common.TransactionCase):
# to verify the purpose of the inheritance computing of the class
# in the openerp.osv.orm._build_model.
mother = self.env['test.inherit.mother']
daugther = self.env['test.inherit.daugther']
daugther = self.env['test.inherit.daughter']
self.assertIn('field_in_mother', mother._fields)
self.assertIn('field_in_mother', daugther._fields)
def test_field_extension(self):
""" check the extension of a field in an inherited model """
# the field mother.name should inherit required=True, and have a default
# value
mother = self.env['test.inherit.mother']
field = mother._fields['name']
# the field should inherit required=True, and have a default value
self.assertTrue(field.required)
self.assertEqual(field.default, 'Unknown')
# the field daugther.template_id should inherit
# model_name='test.inherit.mother', string='Template', required=True
daugther = self.env['test.inherit.daughter']
field = daugther._fields['template_id']
self.assertEqual(field.comodel_name, 'test.inherit.mother')
self.assertEqual(field.string, "Template")
self.assertTrue(field.required)
def test_depends_extension(self):
""" check that @depends on overridden compute methods extends dependencies """
mother = self.env['test.inherit.mother']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment