
- Agregar campo computed selection_options_display que muestra las opciones disponibles - Implementar método _compute_selection_options_display que obtiene opciones del parámetro - Actualizar vista para mostrar las opciones disponibles debajo del campo de entrada - Remover widget selection que no funciona con campos Char dinámicos - Agregar placeholder descriptivo para guiar al usuario El usuario ahora puede ver las opciones válidas (ej: "Negativo < /dev/null | Positivo") y escribir el valor correcto en el campo de texto. Scripts de prueba agregados para validar la solución. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
116 lines
3.6 KiB
Python
116 lines
3.6 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
Script para probar la solución del bug de selection
|
|
"""
|
|
|
|
import odoo
|
|
import logging
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
def test_selection_fix(env):
|
|
"""Probar que la solución funciona correctamente"""
|
|
|
|
print("=" * 80)
|
|
print("PRUEBA DE SOLUCIÓN PARA BUG DE SELECTION")
|
|
print("=" * 80)
|
|
|
|
# Crear una orden de prueba
|
|
patient = env['res.partner'].search([('is_patient', '=', True)], limit=1)
|
|
if not patient:
|
|
patient = env['res.partner'].create({
|
|
'name': 'Paciente Test Selection',
|
|
'is_patient': True,
|
|
})
|
|
|
|
# Buscar análisis con parámetros tipo selection
|
|
# Por ejemplo: Prueba de Embarazo
|
|
product = env['product.template'].search([
|
|
('is_analysis', '=', True),
|
|
('name', 'ilike', 'embarazo')
|
|
], limit=1)
|
|
|
|
if not product:
|
|
print("No se encontró el análisis de Prueba de Embarazo")
|
|
return False
|
|
|
|
# Crear orden
|
|
order = env['sale.order'].create({
|
|
'partner_id': patient.id,
|
|
'is_lab_request': True,
|
|
'order_line': [(0, 0, {
|
|
'product_id': product.product_variant_id.id,
|
|
'product_uom_qty': 1,
|
|
})]
|
|
})
|
|
|
|
# Confirmar orden
|
|
order.action_confirm()
|
|
print(f"\nOrden creada: {order.name}")
|
|
|
|
# Obtener la prueba generada
|
|
test = order.lab_test_ids[0]
|
|
print(f"Prueba: {test.name}")
|
|
|
|
# Generar resultados
|
|
test.sudo()._generate_test_results()
|
|
print(f"Resultados generados: {len(test.result_ids)}")
|
|
|
|
# Verificar el resultado con parámetro tipo selection
|
|
for result in test.result_ids:
|
|
if result.parameter_value_type == 'selection':
|
|
print(f"\nResultado de tipo selection encontrado:")
|
|
print(f" - Parámetro: {result.parameter_id.name}")
|
|
print(f" - Opciones en parámetro: {result.parameter_id.selection_values}")
|
|
print(f" - Opciones disponibles: {result.selection_options_display}")
|
|
|
|
# Verificar que el campo computed funciona
|
|
if result.selection_options_display:
|
|
print(" ✓ Campo selection_options_display funciona correctamente")
|
|
|
|
# Simular asignación de valor
|
|
options = result.parameter_id.get_selection_list()
|
|
if options:
|
|
result.value_selection = options[0]
|
|
print(f" ✓ Valor asignado: '{result.value_selection}'")
|
|
else:
|
|
print(" ✗ No se muestran las opciones disponibles")
|
|
|
|
return True
|
|
|
|
print("\nNo se encontraron resultados de tipo selection")
|
|
return False
|
|
|
|
|
|
if __name__ == '__main__':
|
|
# Configuración
|
|
db_name = 'lims_demo'
|
|
|
|
# Conectar a Odoo
|
|
odoo.tools.config.parse_config(['--database', db_name])
|
|
|
|
# Obtener el registro de la base de datos
|
|
registry = odoo.registry(db_name)
|
|
|
|
# Crear cursor y environment
|
|
with registry.cursor() as cr:
|
|
env = odoo.api.Environment(cr, odoo.SUPERUSER_ID, {})
|
|
|
|
try:
|
|
# Probar la solución
|
|
success = test_selection_fix(env)
|
|
|
|
if success:
|
|
print("\n✅ La solución funciona correctamente")
|
|
else:
|
|
print("\n❌ La prueba falló")
|
|
|
|
# No guardar cambios, solo probar
|
|
cr.rollback()
|
|
|
|
except Exception as e:
|
|
cr.rollback()
|
|
print(f"\n❌ Error durante la prueba: {str(e)}")
|
|
_logger.error(f"Error probando fix: {str(e)}", exc_info=True) |