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
    • Conocimientos
    • 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
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • 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

name '_' is not defined

Suscribirse

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

Se marcó esta pregunta
errorstatusv17
5 Respuestas
3687 Vistas
Avatar
Christian Lloyd

Hello everyone,


I created a custom field to display the status label from the quality check module to the delivery orders module. I use a computed field to display the status label.


Dependencies: check_ids.quality_state

Code:

for record in self:
    if quality_state == "none":
        record['x_studio_quality_checks'] = "To Do"
    elif quality_state == "pass":
        record['x_studio_quality_checks'] = "Passed"
    else:
        record['x_studio_quality_checks'] = "Failed"

Error:

NameError: name 'quality_state' is not defined
ValueError: : "name 'quality_state' is not defined" while evaluating
'for record in self:\r\n    if quality_state == "none":\r\n        record[\'x_studio_quality_checks\'] = "To Do"\r\n    elif quality_state == "pass":\r\n        record[\'x_studio_quality_checks\'] = "Passed"\r\n    else:\r\n        record[\'x_studio_quality_checks\'] = "Failed"'


0
Avatar
Descartar
Avatar
Hans Rickhoff 🚀 https://obd.digital
Mejor respuesta

Your loop is on the right track, iterating through records in self, which is good Odoo etiquette. The hiccup is that quality_state seems to be a mysterious stranger in this context. To resolve this, you'll need to determine quality_state for each record within your loop. I'm going to assume that quality_state is a field of a related quality check record (perhaps from a One2many or Many2one relationship).

1
Avatar
Descartar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Mejor respuesta

Hi,

Ensure that you have defined the field quality_state within the function. From the dependencies you have provided, it seems that quality_state is a field in the one2many model check_ids. Therefore, you can't directly call a field name within a function without defining it first.

For example, in your code you have provided the dependency as check_ids.quality_state, so you should try to reference the field name from it. For instance:


for record in self:
    for check in record.check_ids:
        if check.quality_state == "none":

If you have multiple records in check_ids, you need to loop through them to access the quality_state field."


Hope it helps

0
Avatar
Descartar
Avatar
MUHAMMED ASLAM
Mejor respuesta

Hi Christian, 

The problem is in your loop . quality_state field is in another model .
Please check the code .

for record in self.check_ids:   
if record.quality_state == "none":
        record['x_studio_quality_checks'] = "To Do"
    elif record.quality_state == "pass":
        record['x_studio_quality_checks'] = "Passed"
    else:
        record['x_studio_quality_checks'] = "Failed"


0
Avatar
Descartar
Avatar
Niyas Raphy (Walnut Software Solutions)
Mejor respuesta

Hi,
See what is the value coming in quality_state variable and ensure that you are checking against the correct values ?

Are you sure that the quality_state will return Failed and not failed ? or not just fail ? Similarly for Passed, is it Passed itself, not pass or passed ?

Thanks

0
Avatar
Descartar
Avatar
Christian Lloyd
Autor Mejor respuesta

Hello Hans, thank you for your feedback. I can't comment due to low karma. Yes, quality_state is a field under Quality Checks Module. I want to display it in Delivery Orders View in Inventory Module. It works after I declare the quality_state:

for record in self:
    quality_state = str(line.quality_state for line in record.check_ids)
    if quality_state == "fail":
        record['x_studio_quality_checks'] = "Failed"
    elif quality_state == "pass":
        record['x_studio_quality_checks'] = "Passed"
    else:
        record['x_studio_quality_checks'] = "To Do"

The problem now is whenever the status in quality_state is "Passed" the value in Delivery Orders should be "Passed" but it display "To Do"

0
Avatar
Descartar
Christian Lloyd
Autor

Hi Niyas,

Yes, I check the value in quality_state. quality_state is a selection field from Quality Check Module. Here is its selection value:
[none] - To Do
[pass] - Passed
[fail] - Failed

I want to call the value in the Delivery Orders in Inventory. I keep on tweaking the code still it display "To Do" or gets error.

¿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
TypeError: odoo.tools.misc.frozendict() got multiple values for keyword argument 'deferred_start_date'
error v17
Avatar
0
ene 25
1769
UnknownTimeZoneError: 'Europe/Kyiv' in Odoo.sh
error v17
Avatar
Avatar
1
abr 24
2486
Odoo Version Discrepancy Error in Settings Module Resuelto
settings error v17
Avatar
Avatar
Avatar
Avatar
4
abr 24
4036
Error Run Odoo17 In Pycharm
error pycharm v17
Avatar
Avatar
1
abr 24
3033
How to resolve <UncaughtPromiseError>
error website_builder v17
Avatar
Avatar
1
jun 23
9313
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