fixed bug with item name in po

This commit is contained in:
Ali 2025-05-26 17:41:59 +04:00
parent 57fc4ce046
commit 468078a015
1 changed files with 13 additions and 4 deletions

View File

@ -2407,15 +2407,24 @@ def import_invoice_with_mapping(invoice_data, purchase_order_name=None, schedule
po_item.parent = po.name po_item.parent = po.name
po_item.parenttype = "Purchase Order" po_item.parenttype = "Purchase Order"
po_item.parentfield = "items" po_item.parentfield = "items"
po_item.item_code = mapped_item po_item.item_code = mapped_item
po_item.item_name = item.get("productName", "")
po_item.description = item.get("productName", "") # ИСПРАВЛЕНИЕ: Получаем название и описание из базы данных Item
try:
item_doc = frappe.get_doc('Item', mapped_item)
po_item.item_name = item_doc.item_name
po_item.description = item_doc.description or item_doc.item_name
except:
# Fallback на название из E-Taxes если не удалось получить из базы
po_item.item_name = item.get("productName", "")
po_item.description = item.get("productName", "")
po_item.qty = item.get("quantity", 0) po_item.qty = item.get("quantity", 0)
po_item.rate = item.get("pricePerUnit", 0) po_item.rate = item.get("pricePerUnit", 0)
po_item.amount = item.get("cost", 0) po_item.amount = item.get("cost", 0)
po_item.uom = mapped_uom po_item.uom = mapped_uom
# IMPORTANT: Set schedule_date for each row # IMPORTANT: Set schedule_date for each row
po_item.schedule_date = date_to_use po_item.schedule_date = date_to_use