From 2ebd8cc50d031dd63a20440ff13ab69aed241783 Mon Sep 17 00:00:00 2001 From: Luis Ernesto Portillo Zaldivar Date: Tue, 15 Jul 2025 20:57:09 -0600 Subject: [PATCH] =?UTF-8?q?fix(#10):=20Corregir=20sintaxis=20del=20c=C3=B3?= =?UTF-8?q?digo=20de=20barras=20en=20template=20QWeb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Cambiar sintaxis de % a t-attf-src para mejor compatibilidad - Agregar el número del código debajo de la imagen - Verificado que las muestras tienen barcode en BD - Simplificar la lógica del template Co-Authored-By: Claude --- .../__pycache__/sale_order.cpython-312.pyc | Bin 13625 -> 13714 bytes .../__pycache__/stock_lot.cpython-312.pyc | Bin 9551 -> 9881 bytes .../report/sample_label_report.xml | 13 +- test/check_sample_barcodes.py | 128 ++++++++++++++++++ 4 files changed, 134 insertions(+), 7 deletions(-) create mode 100644 test/check_sample_barcodes.py diff --git a/lims_management/models/__pycache__/sale_order.cpython-312.pyc b/lims_management/models/__pycache__/sale_order.cpython-312.pyc index b3d93328b5a2cdbcd666aa92932e57414f8b963a..4a0505704bdef8867813e177ca6beb9160621da0 100644 GIT binary patch delta 189 zcmdm)H7T3#G%qg~0}#v-F3-?4+Q`>oz{JEjc`b*^4$*hQ{D;{h|hHY5N5 delta 134 zcmbP~y)%pNG%qg~0}$+CE6-SKxRI~Jfax5=F_<_97FY>LMEu!44wWfW+i>qiV*G$;`$&lbwyXF?LPr7lJRxJ!s>Xp`-Hk;=%?+|2MIXO&J zlX2zd2GIys#@NX>rK&lSfZ8+}i!vt1NL%rx0y($Xic=Gdk~4~8H!qP^Vq}cld|YNH zGe;pv9dl9H#;VDW6%J1>6cH0D018iMs9|tnh&5zjsAa5SoP2;^gr%6VM_}@L z5izzR#va)k#z_J)^)-y~j6lU;&|}QPP|2vtRHf>gS6o_@s*sqIqmYxBq)?ogTac4l ztdNmd1{73C0y-o=B{ifd2B@tl9!L~30SN_#B3U4Hi$6XUtUVs8u1X@fBtJRZC%;4w zP39$o8&Iz~P*VfL12L&j3{0HPj2&(__(iYtD_`bUUg5UhZ?)eIMfK~74i^<2E-N}s zV4KSKffc0e0~>>YNRd2Hub-yIxc-c%3^AC{k1fBBoD1uO!EKck?@?tBl;A zBAD1%H9iZlvWiSTsiLl34ODT9)fecEoFWd8>Qx{DWE|KNzc_4i^HWN5QtgV?PL@`c W7tLU16zM4Iuj#D$$^c@6l>z|XE{&Q1 delta 235 zcmbQ~d)|xhG%qg~0}ynxmSr5<_R+`qE7c=h=WYnA-BdW=$xw%a= zf|W65@_ngljs&0vO~#_M$w|^ye91u0EwSkqL|IAq?H&MV>h3b*~!e24^qcm zR5H0wA&RkL@=Jxo%zm2clV2)%01YxyzOEVzR8Uj_BvvvM$%ELkAc6x%umKsxH#Qrq zTxDeY9KpoKsxetuO
- - - - - - + + +
+ +
diff --git a/test/check_sample_barcodes.py b/test/check_sample_barcodes.py new file mode 100644 index 0000000..5ad5ada --- /dev/null +++ b/test/check_sample_barcodes.py @@ -0,0 +1,128 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Script para verificar los códigos de barras de las muestras en la orden S00025 +""" +import odoo +import json +from datetime import datetime + +def check_order_samples(cr, order_name='S00025'): + """Verificar las muestras y sus códigos de barras para una orden específica""" + + # Buscar la orden + cr.execute(""" + SELECT id, name, state, is_lab_request + FROM sale_order + WHERE name = %s + """, (order_name,)) + + order = cr.fetchone() + if not order: + print(f"❌ No se encontró la orden {order_name}") + return + + print(f"✅ Orden encontrada: {order[1]}") + print(f" - ID: {order[0]}") + print(f" - Estado: {order[2]}") + print(f" - Es orden de lab: {order[3]}") + print("") + + # Buscar las muestras asociadas a la orden + cr.execute(""" + SELECT + sl.id, + sl.name, + sl.barcode, + sl.is_lab_sample, + sl.patient_id, + sl.collection_date, + sl.state, + sl.sample_type_product_id, + rp.name as patient_name + FROM stock_lot sl + LEFT JOIN res_partner rp ON sl.patient_id = rp.id + WHERE sl.id IN ( + SELECT lot_id + FROM sale_order_stock_lot_rel + WHERE order_id = %s + ) + """, (order[0],)) + + samples = cr.fetchall() + + if not samples: + print(f"❌ No se encontraron muestras para la orden {order_name}") + + # Verificar si hay relación en la tabla intermedia + cr.execute(""" + SELECT COUNT(*) + FROM sale_order_stock_lot_rel + WHERE order_id = %s + """, (order[0],)) + count = cr.fetchone()[0] + print(f" Registros en sale_order_stock_lot_rel: {count}") + return + + print(f"📋 Muestras encontradas: {len(samples)}") + print("-" * 80) + + for sample in samples: + print(f"Muestra ID: {sample[0]}") + print(f" - Nombre: {sample[1]}") + print(f" - Código de barras: {sample[2] or '❌ VACÍO'}") + print(f" - Es muestra de lab: {sample[3]}") + print(f" - Paciente: {sample[8]} (ID: {sample[4]})") + print(f" - Fecha recolección: {sample[5]}") + print(f" - Estado: {sample[6]}") + print(f" - Tipo muestra ID: {sample[7]}") + + # Si no tiene código de barras, generar uno de ejemplo + if not sample[2]: + print(f" ⚠️ FALTA CÓDIGO DE BARRAS - Ejemplo generado: {datetime.now().strftime('%y%m%d')}000001") + + print("-" * 40) + + # Verificar el campo generated_sample_ids + cr.execute(""" + SELECT COUNT(*) + FROM sale_order_stock_lot_rel + WHERE order_id = %s + """, (order[0],)) + + rel_count = cr.fetchone()[0] + print(f"\n📊 Resumen:") + print(f" - Total muestras en relación: {rel_count}") + print(f" - Muestras sin código de barras: {sum(1 for s in samples if not s[2])}") + + # Verificar si el campo barcode es calculado o almacenado + cr.execute(""" + SELECT + column_name, + data_type, + is_nullable, + column_default + FROM information_schema.columns + WHERE table_name = 'stock_lot' + AND column_name = 'barcode' + """) + + col_info = cr.fetchone() + if col_info: + print(f"\n🔍 Información del campo 'barcode':") + print(f" - Tipo de dato: {col_info[1]}") + print(f" - Permite NULL: {col_info[2]}") + print(f" - Valor por defecto: {col_info[3]}") + +if __name__ == '__main__': + print("🔍 Verificando códigos de barras para orden S00025...") + print("=" * 80) + + db_name = 'lims_demo' + try: + registry = odoo.registry(db_name) + with registry.cursor() as cr: + check_order_samples(cr, 'S00025') + except Exception as e: + print(f"❌ Error: {str(e)}") + print(" Asegúrate de ejecutar este script dentro del contenedor de Odoo") \ No newline at end of file