diff --git a/documents/logs/Screenshot_8.png b/documents/logs/Screenshot_8.png new file mode 100644 index 0000000..9c6085f Binary files /dev/null and b/documents/logs/Screenshot_8.png differ diff --git a/lims_management/models/lims_test.py b/lims_management/models/lims_test.py index 32b503d..3a9f3c9 100644 --- a/lims_management/models/lims_test.py +++ b/lims_management/models/lims_test.py @@ -284,7 +284,7 @@ class LimsTest(models.Model): # Verificar que todos los resultados tengan valores ingresados empty_results = self.result_ids.filtered( - lambda r: not r.value_text and not r.value_numeric and not r.value_boolean and r.parameter_id.value_type != 'boolean' + lambda r: not r.value_text and not r.value_numeric and not r.value_selection and not r.value_boolean and r.parameter_id.value_type != 'boolean' ) if empty_results: params = ', '.join(empty_results.mapped('parameter_id.name')) diff --git a/test/debug_selection_autocomplete.py b/test/debug_selection_autocomplete.py new file mode 100644 index 0000000..9b9681f --- /dev/null +++ b/test/debug_selection_autocomplete.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Script para debuggear el autocompletado de selection +""" + +import odoo +import logging + +_logger = logging.getLogger(__name__) + + +def debug_selection_autocomplete(env): + """Debug del autocompletado""" + + print("=" * 80) + print("DEBUG DE AUTOCOMPLETADO DE SELECTION") + print("=" * 80) + + # Buscar un resultado con tipo selection + result = env['lims.result'].search([ + ('parameter_value_type', '=', 'selection'), + ('test_id.state', '=', 'in_process') + ], limit=1) + + if result: + print(f"\nResultado encontrado:") + print(f" - ID: {result.id}") + print(f" - Parámetro: {result.parameter_id.name}") + print(f" - Valor actual: '{result.value_selection}'") + print(f" - Valores posibles: {result.parameter_id.selection_values}") + + # Probar el autocompletado + test_values = ['Negative', 'negative', 'NEG', 'neg', 'N', 'n', 'Positivo', 'P'] + + print("\nProbando autocompletado:") + for test_val in test_values: + autocompleted = result._validate_and_autocomplete_selection(test_val) + print(f" '{test_val}' -> '{autocompleted}'") + else: + print("No se encontraron resultados de tipo selection") + + +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: + # Debug + debug_selection_autocomplete(env) + + # No guardar cambios + cr.rollback() + + except Exception as e: + cr.rollback() + print(f"\n❌ Error: {str(e)}") + _logger.error(f"Error: {str(e)}", exc_info=True) \ No newline at end of file