#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Script para diagnosticar el problema específico con S00029 """ import odoo import traceback def diagnose_order(cr): """Diagnosticar el problema con S00029""" env = odoo.api.Environment(cr, odoo.SUPERUSER_ID, {}) # Buscar la orden order = env['sale.order'].search([('name', '=', 'S00029')], limit=1) if not order: print("❌ No se encontró la orden S00029") return print(f"✓ Orden encontrada: {order.name}") print(f" Estado: {order.state}") # Intentar confirmar para ver el error exacto print("\n🔄 Intentando confirmar para capturar el error...") try: order.action_confirm() print("✅ ¡Orden confirmada sin problemas!") except Exception as e: print(f"❌ Error: {str(e)}") # Si el error es sobre parámetros de selección, investigar if "parámetros de selección" in str(e): print("\n🔍 Investigando las pruebas generadas...") # Buscar las pruebas asociadas a esta orden tests = env['lims.test'].search([ ('sale_order_line_id.order_id', '=', order.id) ]) print(f"\n Pruebas encontradas: {len(tests)}") for test in tests: print(f"\n 📋 Prueba: {test.name}") print(f" Análisis: {test.product_id.name}") print(f" Resultados: {len(test.result_ids)}") # Revisar los resultados problemáticos for result in test.result_ids: if result.parameter_value_type == 'selection': print(f"\n ⚠️ Resultado de selección: {result.parameter_id.name}") print(f" - value_numeric: {result.value_numeric}") print(f" - value_text: '{result.value_text}'") print(f" - value_selection: '{result.value_selection}'") print(f" - value_boolean: {result.value_boolean}") # Verificar si tiene múltiples valores values_count = 0 if result.value_numeric is not False and result.value_numeric is not None: values_count += 1 if result.value_text: values_count += 1 if result.value_selection: values_count += 1 if result.value_boolean: values_count += 1 if values_count > 1: print(f" ❌ PROBLEMA: {values_count} valores establecidos!") # Limpiar valores incorrectos print(" 🔧 Limpiando valores incorrectos...") result.write({ 'value_numeric': False, 'value_text': False, 'value_boolean': False, 'value_selection': False # También limpiar selection por ahora }) print(" ✓ Valores limpiados") # Intentar confirmar nuevamente print("\n🔄 Intentando confirmar después de limpiar...") try: order.action_confirm() print("✅ ¡Orden confirmada exitosamente!") cr.commit() print("✅ Cambios guardados") except Exception as e2: print(f"❌ Nuevo error: {str(e2)}") cr.rollback() # Si sigue fallando, mostrar más detalles print("\n📊 Información adicional del error:") traceback.print_exc() if __name__ == '__main__': db_name = 'lims_demo' try: registry = odoo.modules.registry.Registry(db_name) with registry.cursor() as cr: diagnose_order(cr) except Exception as e: print(f"Error general: {e}") traceback.print_exc()