Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
5830 Vizualizări

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...

Imagine profil
Abandonează

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..

Autor

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

Cel mai bun răspuns

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.

Imagine profil
Abandonează
Autor

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

Cel mai bun răspuns

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

Imagine profil
Abandonează