"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
# 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',
# 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:
# 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']