Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Información
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Food & Hospitality
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Guest House
    • Distribuidor de bebidas
    • Hotel
    Real Estate
    • Real Estate Agency
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consulting
    • Accounting Firm
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Trades
    • Handyman
    • Hardware y asistencia informática
    • Solar Energy Systems
    • Zapatero
    • Servicios de limpieza
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

_inherits delegation OpenERP

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
_inheritsopenerpdelegation
1 Responder
15153 Vistas
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)
Mejor respuesta

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 .

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
Create selection type field dynamically?
openerp
Avatar
Avatar
Avatar
2
sept 23
8422
How to hide the create button dynamical tree view in openerp ? Resuelto
openerp
Avatar
Avatar
2
mar 23
47629
ProgrammingError: can't adapt type 'dict' [SOLVED]
openerp
Avatar
Avatar
Avatar
2
dic 23
58749
How to use the audit app
openerp
Avatar
0
mar 22
2968
unable to add column in res.users table Resuelto
_inherits
Avatar
Avatar
Avatar
Avatar
Avatar
17
dic 21
25690
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

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