让product.product从product.template继承而不是直接在product.product中定义所有字段有什么好处?
_name = "product.product"
_description = "Product"
_inherits = {'product.template': 'product_tmpl_id'}我什么时候会在新代码中使用这种技术?
发布于 2014-03-25 05:25:20
在使用_inherits时,您将以数据库的方式创建一种多态模型。
例如,product.product继承product.template或res.users继承res.partner。这意味着我们创建了一个模型,该模型了解如何使用Model,但是在一个新的数据库表中添加了属性数据/列。因此,在创建用户时,所有合作伙伴数据都存储在res_partner表中(并且创建了一个合作伙伴),所有与用户相关的信息都存储在res_users表中。
为此,我们使用dict:_inherits = {'res.partner': 'partner_id'},键对应于基模型,值对应于基本模型的外键。
从这里你可以混合继承如果你敢..。
这里有一些链接:
http://help.openerp.com/question/46/the-different-openerp-model-inheritance-mechanisms-whats-the-difference-between-them-and-when-should-they-be-used/
希望能帮上忙。
https://stackoverflow.com/questions/22619243
复制相似问题