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

name '_' is not defined

Suscribirse

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

Se marcó esta pregunta
errorstatusv17
5 Respuestas
3686 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.

Registrarse
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
3032
How to resolve <UncaughtPromiseError>
error website_builder v17
Avatar
Avatar
1
jun 23
9311
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.

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