fix: not able to delete cancelled delivery note (#40508)
(cherry picked from commit 7695759f3c)
Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -9,6 +9,8 @@ frappe.ui.form.on("Work Order", {
|
||||
"Job Card": "Create Job Card",
|
||||
};
|
||||
|
||||
frm.ignore_doctypes_on_cancel_all = ["Serial and Batch Bundle"];
|
||||
|
||||
// Set query for warehouses
|
||||
frm.set_query("wip_warehouse", function () {
|
||||
return {
|
||||
|
||||
@@ -1097,9 +1097,30 @@ class TestDeliveryNote(FrappeTestCase):
|
||||
dn.load_from_db()
|
||||
|
||||
batch_no = get_batch_from_bundle(dn.packed_items[0].serial_and_batch_bundle)
|
||||
packed_name = dn.packed_items[0].name
|
||||
self.assertTrue(batch_no)
|
||||
|
||||
dn.cancel()
|
||||
|
||||
# Cancel the reposting entry
|
||||
reposting_entries = frappe.get_all("Repost Item Valuation", filters={"docstatus": 1})
|
||||
for entry in reposting_entries:
|
||||
doc = frappe.get_doc("Repost Item Valuation", entry.name)
|
||||
doc.cancel()
|
||||
doc.delete()
|
||||
|
||||
frappe.db.set_single_value("Accounts Settings", "delete_linked_ledger_entries", 1)
|
||||
|
||||
dn.reload()
|
||||
dn.delete()
|
||||
|
||||
bundle = frappe.db.get_value(
|
||||
"Serial and Batch Bundle", {"voucher_detail_no": packed_name}, "name"
|
||||
)
|
||||
self.assertFalse(bundle)
|
||||
|
||||
frappe.db.set_single_value("Stock Settings", "use_serial_batch_fields", 1)
|
||||
frappe.db.set_single_value("Accounts Settings", "delete_linked_ledger_entries", 0)
|
||||
|
||||
def test_payment_terms_are_fetched_when_creating_sales_invoice(self):
|
||||
from erpnext.accounts.doctype.payment_entry.test_payment_entry import (
|
||||
|
||||
@@ -184,7 +184,11 @@ class PickList(Document):
|
||||
|
||||
def delink_serial_and_batch_bundle(self):
|
||||
for row in self.locations:
|
||||
if row.serial_and_batch_bundle:
|
||||
if (
|
||||
row.serial_and_batch_bundle
|
||||
and frappe.db.get_value("Serial and Batch Bundle", row.serial_and_batch_bundle, "docstatus")
|
||||
== 1
|
||||
):
|
||||
frappe.db.set_value(
|
||||
"Serial and Batch Bundle",
|
||||
row.serial_and_batch_bundle,
|
||||
|
||||
@@ -778,6 +778,10 @@ class SerialandBatchBundle(Document):
|
||||
or_filters=or_filters,
|
||||
)
|
||||
|
||||
if not vouchers and self.voucher_type == "Delivery Note":
|
||||
frappe.db.set_value("Packed Item", self.voucher_detail_no, "serial_and_batch_bundle", None)
|
||||
return
|
||||
|
||||
for voucher in vouchers:
|
||||
if voucher.get("current_serial_and_batch_bundle"):
|
||||
frappe.db.set_value(self.child_table, voucher.name, "current_serial_and_batch_bundle", None)
|
||||
|
||||
Reference in New Issue
Block a user