fix(#10): Corregir sintaxis del código de barras en template QWeb
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
2c76b97402
commit
2ebd8cc50d
Binary file not shown.
Binary file not shown.
|
@ -58,14 +58,13 @@
|
|||
|
||||
<!-- Código de barras -->
|
||||
<div style="text-align: center; margin-top: 3mm;">
|
||||
<t t-if="o.barcode">
|
||||
<img t-att-src="'/report/barcode/?barcode_type=%s&value=%s&width=%s&height=%s&humanreadable=%s' % ('Code128', o.barcode, 250, 60, 1)"
|
||||
style="width: 250px; height: 60px;"/>
|
||||
</t>
|
||||
<t t-else="">
|
||||
<!-- Si no hay barcode, usar el name del lote -->
|
||||
<img t-att-src="'/report/barcode/?barcode_type=%s&value=%s&width=%s&height=%s&humanreadable=%s' % ('Code128', o.name, 250, 60, 1)"
|
||||
<t t-set="barcode_value" t-value="o.barcode or o.name"/>
|
||||
<t t-if="barcode_value">
|
||||
<img t-attf-src="/report/barcode/?barcode_type=Code128&value={{barcode_value}}&width=250&height=60&humanreadable=1"
|
||||
style="width: 250px; height: 60px;"/>
|
||||
<div style="text-align: center; font-size: 10px; margin-top: 2px;">
|
||||
<span t-esc="barcode_value"/>
|
||||
</div>
|
||||
</t>
|
||||
</div>
|
||||
|
||||
|
|
128
test/check_sample_barcodes.py
Normal file
128
test/check_sample_barcodes.py
Normal file
|
@ -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")
|
Loading…
Reference in New Issue
Block a user