fix: system was allowing credit notes with serial numbers for any customer

This commit is contained in:
Rohit Waghchaure
2025-07-15 14:00:04 +05:30
parent 6e98adecdd
commit e073075834
7 changed files with 62 additions and 3 deletions

View File

@@ -409,6 +409,10 @@ class SerialBatchBundle:
]:
status = "Consumed"
customer = None
if sle.voucher_type in ["Sales Invoice", "Delivery Note"] and sle.actual_qty < 0:
customer = frappe.get_cached_value(sle.voucher_type, sle.voucher_no, "customer")
sn_table = frappe.qb.DocType("Serial No")
query = (
@@ -419,10 +423,11 @@ class SerialBatchBundle:
"Active"
if warehouse
else status
if (sn_table.purchase_document_no != sle.voucher_no and sle.is_cancelled != 1)
if (sn_table.purchase_document_no != sle.voucher_no or sle.is_cancelled != 1)
else "Inactive",
)
.set(sn_table.company, sle.company)
.set(sn_table.customer, customer)
.where(sn_table.name.isin(serial_nos))
)