跳至内容
菜单
此问题已终结
1 回复
7217 查看

I got a problem in Openerp. how I can create a specific key as a primary key and then refer it from another table. Suppose I have two tables in my DB (Table A and Table B) I want only a few fields from table A into Table B not all... how I can do this ? if I inherit Table A class , its all relevant fields will come in Table B that I don't want.. Thanks in Advance

形象
丢弃
最佳答案

Hi, take a look at inheritance by Delegation - _inherits

 class tiny_object(osv.osv)
        _name = 'tiny.object'
        _table = 'tiny_object'
        _inherits = {
            'tiny.object_a': 'object_a_id',
            'tiny.object_b': 'object_b_id',
            ... ,
            'tiny.object_n': 'object_n_id'
        }
    (...)

It will create a table B with your declared fields and a foreign key for table A. You can store the data in table A on the field you want and leave the rest empty...

形象
丢弃
编写者

thanks for the quick response ... will it solve my problem? i mean with iheritance by delegation i must put exactly the same columns in Table B ?

You can access the fields in table A and you can create table B with your required field and both will be linked by common id. Go through the technical memento for more details about different types of inheritance. You can find it in https://www.openerp.com/files/memento/OpenERP_Technical_Memento_latest.pdf

编写者

in the doc there is no simple example of inheriting specific fields from one table to another table with OpenERP relationship (One2many and Many2one

相关帖文 回复 查看 活动
1
3月 15
3829
1
4月 17
3089
1
1月 16
3644
1
10月 15
3638
2
9月 15
7331