Inheritance by Delegation - _inherits

Syntax ::

  1. class tiny_object(osv.osv)
  2. _name = 'tiny.object'
  3. _table = 'tiny_object'
  4. _inherits = {
  5. 'tiny.object_a': 'object_a_id',
  6. 'tiny.object_b': 'object_b_id',
  7. ... ,
  8. 'tiny.object_n': 'object_n_id'
  9. }
  10. (...)

对象“tiny.object”继承n个对象“tiny.object_a, …,tiny.object_n”的所有的字段和方法。

为了继承多种表格,每继承一个对象就加一列到表格中。这个列存储继承表格的外键。值‘object_a_id’ ‘object_b_id’ … ‘object_n_id’ 是字符串类型,定义列头,它里面放着存储对象‘tiny.object_a’, …, ‘tiny.object_n’的外键。

This inheritance mechanism is usually called “ instance inheritance “ or “ value inheritance “. A resource (instance) has the VALUES of its parents.