clinical_laboratory/test/verify_test_sequence.py
Luis Ernesto Portillo Zaldivar 754c5f5572 fix: Corregir generación de secuencias en lims.test
- Eliminar método create duplicado que sobrescribía la lógica de secuencias
- Consolidar la generación de secuencias en un único método create
- Agregar contexto especial para evitar validaciones durante la inicialización
- Ahora todos los tests se crean con códigos secuenciales (LAB-YYYY-NNNNN)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-23 16:59:26 -06:00

64 lines
1.6 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import odoo
def verify_test_sequence(cr):
"""Verificar que los tests están usando la secuencia correcta"""
print("\n=== VERIFICACIÓN DE SECUENCIAS EN LIMS.TEST ===\n")
# Buscar todos los tests
cr.execute("""
SELECT id, name, create_date
FROM lims_test
ORDER BY create_date
LIMIT 10
""")
tests = cr.fetchall()
print(f"Total de tests encontrados (mostrando primeros 10): {len(tests)}")
print("-" * 50)
print("ID | Código | Fecha de Creación")
print("-" * 50)
for test in tests:
print(f"{test[0]:<4} | {test[1]:<15} | {test[2]}")
# Verificar si hay algún test con nombre "Nuevo"
cr.execute("""
SELECT COUNT(*)
FROM lims_test
WHERE name = 'Nuevo'
""")
nuevo_count = cr.fetchone()[0]
print("\n" + "=" * 50)
print(f"\nTests con nombre 'Nuevo': {nuevo_count}")
if nuevo_count == 0:
print("✅ ÉXITO: Todos los tests están usando la secuencia correcta")
else:
print("❌ ERROR: Hay tests con nombre 'Nuevo'")
# Verificar el patrón de la secuencia
cr.execute("""
SELECT name
FROM lims_test
WHERE name LIKE 'LAB-%'
ORDER BY create_date DESC
LIMIT 5
""")
recent_tests = cr.fetchall()
print("\nÚltimos 5 tests con secuencia LAB-:")
for test in recent_tests:
print(f" - {test[0]}")
if __name__ == '__main__':
db_name = 'lims_demo'
registry = odoo.registry(db_name)
with registry.cursor() as cr:
verify_test_sequence(cr)