Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita 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
  • Proyectos
  • 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

ORM API - method name_search. When should I use it and redefine it?

Suscribirse

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

Se marcó esta pregunta
name_searchodoo
1 Responder
25483 Vistas
Avatar
Pepiño

Hi Odoo developers,

I have read the documentantion about the method 'name_search' of the Odoo 8 ORM API in the following link: https://www.odoo.com/documentation/8.0/reference/orm.html.

First question:

The problem is that I don't understand very well when and where the 'name_search' is useful. Could someone explain me with some example, please?.

Second question:

Also, I have seen modules created by the community that overwrite the 'name_search' method in a module. Why do they do this?.

I'm starting to develop with the Odoo 8 framework and there are difficult things to understand for me.

An example of the overwrited 'name_search' method is in the following link: 
https://github.com/acsone/acsone-addons/blob/8.0/project_code/project_code.py


And here a part of the model source code of that example: 

from openerp.osv import orm, fields


class project(orm.Model):
_inherit = "project.project"

def name_search(self, cr, uid, name, args=None, operator='ilike',
context=None, limit=100):

if not args:
args = []
args = args[:]
ids = []
if name:
ids = self.search(cr, uid,
[('code', '=like', name + "%")] + args,
limit=limit)
if not ids:
ids = self.search(cr, uid,
[('name', operator, name)] + args,
limit=limit)
else:
ids = self.search(cr, uid, args, context=context, limit=limit)
return self.name_get(cr, uid, ids, context=context)

def name_get(self, cr, uid, ids, context=None):
if not ids:
return []
if isinstance(ids, (int, long)):
ids = [ids]
reads = self.read(cr, uid, ids, ['name', 'code'], context=context)
res = []
for record in reads:
name = record['name']
if record['code']:
name = record['code'] + ' - ' + name
res.append((record['id'], name))
return res

 In the above example the name_search method signature,

def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100) 

doesn't match the name_search method signature in the Odoo 8 ORM API:

name_search(name='', args=None, operator='ilike', limit=100)
I guess it is because they are using the OpenERP v7 framework, but I'm not sure.
0
Avatar
Descartar
Sehrish

When should you use name_search method: https://goo.gl/7PHhPP

Avatar
Atchuthan - Technical Consultant, Sodexis Inc
Mejor respuesta

1. name_search and name_get are used when used as a related table is checked i.e. use of many2one
When a many2one field is created who have a relation to an object(res.partner), then how the value needs to be shown is done through name_get method and to search at many2one field uses name_search method.

2. Yes, it is due to change of API environment.

In v7,
def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100)

In v8, @api.mode
def name_search(name='', args=None, operator='ilike', limit=100)



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

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

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Odoo installatie
odoo
Avatar
0
dic 25
90
How Odoo Help Businesses??
odoo
Avatar
0
dic 25
213
Odoo Studio Many2one field not appearing in automations
odoo
Avatar
Avatar
1
dic 25
383
SOC 1 Report
odoo
Avatar
Avatar
2
nov 25
470
邮箱无法正常使用
odoo
Avatar
Avatar
1
nov 25
2382
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • 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 estar totalmente integrado.

Sitio web hecho con

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