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.

1

Inherit a Class

By
aci aisha
on 2/2/15, 1:04 AM 525 views

Friends....

Can we use the fields of a class in another class??

N;B:Both classes defined in same .py file

(Is inheritance is mandatory here,If yes how??)

Thanks...

Hi,, did you mean that both objects are same or different ?? Please make it more clear with any example or something.... It will he helpful..

Baiju
on 2/2/15, 1:15 AM

No both are different objects(classes).. i want to inherit a class to another class...

aci aisha
on 2/2/15, 3:48 AM
1

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 2/2/15, 1:54 AM

Check out this documentation page on inheritence.  There are various ways to inherit an object, depending on how do you want to "use" the field in the other class from the new class, that is provided by OpenERP.

Inheritence is not really necessary if you don't want to re-use the same methods, etc.  You can just re-define the fields.

Thanks..(1 vote and a Tick=25 points)

aci aisha
on 2/2/15, 3:54 AM
0
anu
On 2/3/15, 12:50 AM

Use name  not equal to inheritance

from openerp import models,fields,api,_
class Inheritance0(models.Model):
    _name = 'inheritance.0'

    name = fields.Char()
    age=fields.Integer(string='age')
    regis=fields.Char(string='regist')
 
    
    
    
    

class Inheritance1(models.Model):
    _name = 'inheritance.1'
    _inherit = 'inheritance.0'

    call=fields.Char(string="register")
   

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

1 follower(s)

Stats

Asked: 2/2/15, 1:04 AM
Seen: 525 times
Last updated: 3/16/15, 8:10 AM