Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Concept of Primary and Foreign Keys in OpenERP?

By
Ali Khan
on 4/23/14, 9:57 AM 1,121 views

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

2

Dhinesh - Technical Consultant, Sodexis Inc

--Dhinesh - Technical Consultant, Sodexis Inc--
3577
| 5 4 9
Pondicherry, India
--Dhinesh - Technical Consultant, Sodexis Inc--

Passionate coder in Python/OpenERP. Knows Django/Flask MVC frameworks. Did code in Java, PHP.

Contact me at: dvdhinesh.mail@gmail.com

Dhinesh - Technical Consultant, Sodexis Inc
On 4/23/14, 10:14 AM

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 ?

Ali Khan
on 4/23/14, 10:24 AM

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

Dhinesh - Technical Consultant, Sodexis Inc
on 4/23/14, 10:47 AM

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

Ali Khan
on 4/23/14, 12:39 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 4/23/14, 9:57 AM
Seen: 1121 times
Last updated: 3/16/15, 8:10 AM