首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OpenERP 7.0:为什么product.product从product.template继承?

OpenERP 7.0:为什么product.product从product.template继承?
EN

Stack Overflow用户
提问于 2014-03-24 19:49:27
回答 1查看 1.3K关注 0票数 1

product.productproduct.template继承而不是直接在product.product中定义所有字段有什么好处?

代码语言:javascript
复制
_name = "product.product"
_description = "Product"
_inherits = {'product.template': 'product_tmpl_id'}

我什么时候会在新代码中使用这种技术?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-25 05:25:20

在使用_inherits时,您将以数据库的方式创建一种多态模型。

例如,product.product继承product.templateres.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/

inherits/

希望能帮上忙。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22619243

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档