How do the relational fields work internally?

时光总嘲笑我的痴心妄想 提交于 2019-12-13 04:39:32

问题


I have used all these 3 relational fields i.e many2one,one2many,many2many but still now I'm unable to know exactly how do they work internally,So please throw some light on their working .


回答1:


I'll give you a simple example.

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()

You can always look on your database and compare it with code if my example wasn't clear.



来源:https://stackoverflow.com/questions/23218737/how-do-the-relational-fields-work-internally

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!