fix: voucher detail no in SABB

(cherry picked from commit c37a56ec89)

# Conflicts:
#	erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py
This commit is contained in:
Rohit Waghchaure
2026-03-01 13:32:00 +05:30
committed by Mergify
parent 6147541f58
commit 6e5738e95c
3 changed files with 40 additions and 3 deletions

View File

@@ -936,7 +936,14 @@ def get_serial_batches_based_on_bundle(doctype, field, _bundle_ids):
if doctype == "Packed Item": if doctype == "Packed Item":
if key is None: if key is None:
key = frappe.get_cached_value("Packed Item", row.voucher_detail_no, field) key = frappe.get_cached_value(
"Packed Item",
{"parent_detail_docname": row.voucher_detail_no, "item_code": row.item_code},
field,
)
if key is None:
key = frappe.get_cached_value("Packed Item", row.voucher_detail_no, field)
if row.voucher_type == "Delivery Note": if row.voucher_type == "Delivery Note":
key = frappe.get_cached_value("Delivery Note Item", key, "dn_detail") key = frappe.get_cached_value("Delivery Note Item", key, "dn_detail")
elif row.voucher_type == "Sales Invoice": elif row.voucher_type == "Sales Invoice":

View File

@@ -718,10 +718,13 @@ class SerialandBatchBundle(Document):
if rate is None and child_table in ["Delivery Note Item", "Sales Invoice Item"]: if rate is None and child_table in ["Delivery Note Item", "Sales Invoice Item"]:
rate = frappe.db.get_value( rate = frappe.db.get_value(
"Packed Item", "Packed Item",
self.voucher_detail_no, {"parent_detail_docname": self.voucher_detail_no, "item_code": self.item_code},
"incoming_rate", "incoming_rate",
) )
if rate is None:
rate = frappe.db.get_value("Packed Item", self.voucher_detail_no, "incoming_rate")
if rate is not None: if rate is not None:
is_packed_item = True is_packed_item = True
@@ -788,11 +791,21 @@ class SerialandBatchBundle(Document):
if not self.voucher_detail_no or self.voucher_detail_no != row.name: if not self.voucher_detail_no or self.voucher_detail_no != row.name:
values_to_set["voucher_detail_no"] = row.name values_to_set["voucher_detail_no"] = row.name
<<<<<<< HEAD
if parent.get("posting_date") and (not self.posting_date or self.posting_date != parent.posting_date): if parent.get("posting_date") and (not self.posting_date or self.posting_date != parent.posting_date):
values_to_set["posting_date"] = parent.posting_date or today() values_to_set["posting_date"] = parent.posting_date or today()
if parent.get("posting_time") and (not self.posting_time or self.posting_time != parent.posting_time): if parent.get("posting_time") and (not self.posting_time or self.posting_time != parent.posting_time):
values_to_set["posting_time"] = parent.posting_time values_to_set["posting_time"] = parent.posting_time
=======
if row.get("doctype") == "Packed Item" and row.get("parent_detail_docname"):
values_to_set["voucher_detail_no"] = row.get("parent_detail_docname")
if parent.get("posting_date") and parent.get("posting_time"):
posting_datetime = combine_datetime(parent.posting_date, parent.posting_time)
if not self.posting_datetime or self.posting_datetime != posting_datetime:
values_to_set["posting_datetime"] = posting_datetime
>>>>>>> c37a56ec89 (fix: voucher detail no in SABB)
if parent.doctype in [ if parent.doctype in [
"Delivery Note", "Delivery Note",
@@ -1329,7 +1342,21 @@ class SerialandBatchBundle(Document):
) )
if not vouchers and self.voucher_type == "Delivery Note": if not vouchers and self.voucher_type == "Delivery Note":
frappe.db.set_value("Packed Item", self.voucher_detail_no, "serial_and_batch_bundle", None) if frappe.db.exists("Packed Item", self.voucher_detail_no):
frappe.db.set_value("Packed Item", self.voucher_detail_no, "serial_and_batch_bundle", None)
else:
packed_items = frappe.get_all(
"Packed Item",
filters={
"parent_detail_docname": self.voucher_detail_no,
"serial_and_batch_bundle": self.name,
},
pluck="name",
)
for packed_item in packed_items:
frappe.db.set_value("Packed Item", packed_item, "serial_and_batch_bundle", None)
return return
for voucher in vouchers: for voucher in vouchers:

View File

@@ -382,6 +382,9 @@ class SerialBatchBundle:
def submit_serial_and_batch_bundle(self): def submit_serial_and_batch_bundle(self):
doc = frappe.get_doc("Serial and Batch Bundle", self.sle.serial_and_batch_bundle) doc = frappe.get_doc("Serial and Batch Bundle", self.sle.serial_and_batch_bundle)
if self.sle.voucher_detail_no and doc.voucher_detail_no != self.sle.voucher_detail_no:
doc.voucher_detail_no = self.sle.voucher_detail_no
self.validate_actual_qty(doc) self.validate_actual_qty(doc)
doc.flags.ignore_voucher_validation = True doc.flags.ignore_voucher_validation = True