From 2f5fa3b207fdaead3faac4da3f9f0f5e069dda0d Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Sat, 11 Apr 2026 00:29:16 +0530 Subject: [PATCH] fix: batch/serial should use parent's posting datetime for naming (#54206) --- erpnext/accounts/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index d0707438745..5139f0192a7 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -1615,6 +1615,10 @@ def parse_naming_series_variable(doc, variable): else: data = {"YY": "%y", "YYYY": "%Y", "MM": "%m", "DD": "%d", "JJJ": "%j"} + + if doc and doc.doctype in ["Batch", "Serial No"] and doc.reference_doctype and doc.reference_name: + doc = frappe.get_doc(doc.reference_doctype, doc.reference_name) + date = ( ( getdate(doc.get("posting_date") or doc.get("transaction_date") or doc.get("posting_datetime"))