【问题标题】:How do the relational fields work internally?关系字段如何在内部工作?
【发布时间】:2014-04-22 11:53:50
【问题描述】:

我已经使用了所有这 3 个关系字段,即 many2one、one2many、many2many,但现在我仍然无法确切知道它们在内部是如何工作的,所以请对它们的工作有所了解。

【问题讨论】:

    标签: openerp


    【解决方案1】:

    我给你举个简单的例子。

    class a(osv.osv):
    _name = 'a'
    _columns = {
        'f1': fields.many2one('b', 'Creates new column "f1" in "a" table'),
        'f2': fields.one2many('b', 'xxx', 'Creates new column "xxx" in "b" table'),
        'f3': fields.many2many('b', 'aaa', 'a_id', 'b_id', 'Creates new table "aaa" with column "a_id" related to "a" object and column "b_id" related to "b" object'),
    }
    a()
    
    class b(osv.osv):
        _name = 'b'
    b()
    

    如果我的示例不清楚,您可以随时查看您的数据库并将其与代码进行比较。

    【讨论】:

    • 非常感谢.. 现在我知道了
    猜你喜欢
    • 2016-04-13
    • 1970-01-01
    • 2019-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-15
    • 2012-12-05
    • 2017-01-05
    相关资源
    最近更新 更多