Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

_inherits delegation OpenERP

Subscriure's

Get notified when there's activity on this post

This question has been flagged
_inheritsopenerpdelegation
1 Respondre
15196 Vistes
Avatar
omprakash
Hai Friends ,

     First I like to thank everyone for such good support for newbies . I have question regards _inherits delegation in OpenERP . 

1. For which purpose we make use of _inherits = {  'tiny.object_a': 'object_a_id' }  & _inherit = ['objectname']  ? Please explain with suitable example ?

2. After viewing code , had Question in my mind ..

         **sample code : addons / hr /hr.py**

class hr_employee(osv.osv):
    _name = "hr.employee"
    _inherits = {'resource.resource': "**resource_id**"}
    _columns = {
                     '**resource_id**': fields.many2one('resource.resource', 'Resource', ondelete='cascade', required=True),
                .................

                         }

    ......

     def unlink(self, cr, uid, ids, context=None):
              resource_ids = []
              for employee in self.browse(cr, uid, ids, context=context):
              resource_ids.append(employee.resource_id.id)
               return self.pool.get('resource.resource').unlink(cr, uid, resource_ids, context=context)
  ..........
  hr_employee()

 **In addons / hr /hr_view.xml** 

         Fields - **resource_id**  ( have not been used )

Actually what is described in this code . Please explain . If you explain both _inherit & _inherits  it will be more useful for understanding .. Please help me.


Thanks & Regards
 OMPRAKASH.A
2
Avatar
Descartar
Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Best Answer

If you want to extend or customize anything for particular object/class _inherit is used. It is a single object/class inheritance.

When you use _inherit and add new fields, those fields will be added inside inherited object. No other table will be created in database.

For example I want to add one or more field(s) or I want to add/override method in sale.order then I will use:

class sale_order(osv.Model):
    _inherit = 'sale.order'
    _columns = {
        'my_field': fields.char('My New Field', size=50),
    }

    def my_new_method(self, cr, uid, ids, context=None):
        ...
        ...

If I want to use anything (fields or methods) of any object and I want to achieve multiple inheritance, then I will use _inherits which allows you to use features of any object. That means you can directly use fields and methods of inherited object.

When you use _inherits and new table is created in database. That will have your own fields and field ID of inherited object.

For example in hr.employee object resource.resource object is inherited. So you can see fields of hr.employee object and resource_id of resource.resource object.


Now lets talk about code you want to know.

def unlink(self, cr, uid, ids, context=None):
          resource_ids = []
          for employee in self.browse(cr, uid, ids, context=context):
          resource_ids.append(employee.resource_id.id)
           return self.pool.get('resource.resource').unlink(cr, uid, resource_ids, context=context)

This method will be called when I will delete any employee record.

When any employee record is deleted, resource record related to employee will also be deleted.

Have a look at What is _inherit and What is _inherits.

Hope my answer will help you.

4
Avatar
Descartar
omprakash
Autor

Hi Sudhir Arya , Thanks for immediate reply . You are such good friend for me . I will try in my code , If any doubt raise in my mind i will ask you . And once again thanks for reply

omprakash
Autor

Hi Sudhir Arya , Finally i like to conclude - As you mentioned _inherits has the property to access (methods) of any object . Can you please explain with example . Please still not clear at this point .

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
Create selection type field dynamically?
openerp
Avatar
Avatar
Avatar
2
de set. 23
8506
How to hide the create button dynamical tree view in openerp ? Solved
openerp
Avatar
Avatar
2
de març 23
47756
ProgrammingError: can't adapt type 'dict' [SOLVED]
openerp
Avatar
Avatar
Avatar
2
de des. 23
58887
How to use the audit app
openerp
Avatar
0
de març 22
3061
unable to add column in res.users table Solved
_inherits
Avatar
Avatar
Avatar
Avatar
Avatar
17
de des. 21
25835
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now