Improve frontend panel de control

This commit is contained in:
Urtzi Alfaro
2025-11-20 22:10:16 +01:00
parent 80298b61b2
commit 2ee94fb4b1
9 changed files with 117 additions and 74 deletions

View File

@@ -137,7 +137,8 @@ async def create_purchase_order(
try:
# Get product names from items_data
items_list = items_data or []
product_names = [item.get('product_name', f"Product {i+1}") for i, item in enumerate(items_list)]
# CRITICAL FIX: Use 'name' key, not 'product_name', to match items_data structure
product_names = [item.get('name', item.get('product_name', f"Product {i+1}")) for i, item in enumerate(items_list)]
if not product_names:
product_names = ["Demo Product"]
@@ -192,8 +193,10 @@ async def create_purchase_order(
if reasoning_data:
try:
po.reasoning_data = reasoning_data
except Exception:
pass # Columns don't exist yet
logger.debug(f"Set reasoning_data for PO {po_number}: {reasoning_data.get('type', 'unknown')}")
except Exception as e:
logger.warning(f"Failed to set reasoning_data for PO {po_number}: {e}")
pass # Column might not exist yet
# Set approval data if approved
if status in [PurchaseOrderStatus.approved, PurchaseOrderStatus.sent_to_supplier,