From c1d198d20521fb76236effa7c652661958da46bb Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Sun, 9 Aug 2026 15:45:07 +0530 Subject: [PATCH 1/3] fix: sync open reference forms after Quality Inspection updates them update_qc_reference() writes the QI link and bumps the reference document's modified timestamp via raw db writes, which emit no realtime event. A reference form (Purchase Receipt, Delivery Note, Stock Entry, Job Card) still open in the browser keeps the old timestamp and fails the timestamp conflict check on the next save/submit, forcing a manual refresh after every QI submit/cancel/delete. Calling notify_update() on the reference publishes the standard doc_update event, so an open, unedited form silently reloads and syncs its timestamp. get_lazy_doc skips child table loading since notify_update only needs the parent row. (cherry picked from commit 647452c95befc0cb6b749478372b95899e059a1d) --- erpnext/stock/doctype/quality_inspection/quality_inspection.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/erpnext/stock/doctype/quality_inspection/quality_inspection.py b/erpnext/stock/doctype/quality_inspection/quality_inspection.py index a7733b0bf8b..1fbf323f0dd 100644 --- a/erpnext/stock/doctype/quality_inspection/quality_inspection.py +++ b/erpnext/stock/doctype/quality_inspection/quality_inspection.py @@ -253,6 +253,9 @@ class QualityInspection(Document): self.modified, ) + if self.reference_type and self.reference_name: + frappe.get_lazy_doc(self.reference_type, self.reference_name).notify_update() + def inspect_and_set_status(self): for reading in self.readings: if not reading.manual_inspection: # dont auto set status if manual From 2270b2240027b88fc70c3243a708bbfbb4075853 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Sun, 9 Aug 2026 15:53:37 +0530 Subject: [PATCH 2/3] test: doc_update published for reference on Quality Inspection submit (cherry picked from commit e8a6884d5ec7b1ed6b4ca21b21fb5a392e7b157b) # Conflicts: # erpnext/stock/doctype/quality_inspection/test_quality_inspection.py --- .../test_quality_inspection.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/erpnext/stock/doctype/quality_inspection/test_quality_inspection.py b/erpnext/stock/doctype/quality_inspection/test_quality_inspection.py index e49a0b3b678..96b8760d349 100644 --- a/erpnext/stock/doctype/quality_inspection/test_quality_inspection.py +++ b/erpnext/stock/doctype/quality_inspection/test_quality_inspection.py @@ -1,6 +1,12 @@ # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors and Contributors # See license.txt +<<<<<<< HEAD +======= +from contextlib import contextmanager +from unittest.mock import patch + +>>>>>>> e8a6884d5e (test: doc_update published for reference on Quality Inspection submit) import frappe from frappe.tests.utils import FrappeTestCase, change_settings from frappe.utils import nowdate @@ -58,6 +64,27 @@ class TestQualityInspection(FrappeTestCase): qa.delete() dn.delete() + def test_doc_update_published_for_reference_on_submit(self): + """Submitting a QI publishes doc_update so open reference forms resync their timestamp.""" + dn = create_delivery_note(item_code="_Test Item with QA", do_not_submit=True) + qa = create_quality_inspection( + reference_type="Delivery Note", reference_name=dn.name, do_not_submit=True + ) + + with patch.object(frappe, "publish_realtime") as publish_realtime: + qa.submit() + + reference_updates = [ + call + for call in publish_realtime.call_args_list + if call.args and call.args[0] == "doc_update" and call.kwargs.get("docname") == dn.name + ] + self.assertEqual(len(reference_updates), 1) + + message = reference_updates[0].args[1] + self.assertEqual(message["doctype"], "Delivery Note") + self.assertEqual(message["modified"], frappe.db.get_value("Delivery Note", dn.name, "modified")) + def test_value_based_qi_readings(self): # Test QI based on acceptance values (Non formula) dn = create_delivery_note(item_code="_Test Item with QA", do_not_submit=True) From 94d1dfdcb4d44813e9a8be356250912ea7799f40 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Sun, 9 Aug 2026 16:18:49 +0530 Subject: [PATCH 3/3] chore: resolve conflict --- .../doctype/quality_inspection/test_quality_inspection.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/erpnext/stock/doctype/quality_inspection/test_quality_inspection.py b/erpnext/stock/doctype/quality_inspection/test_quality_inspection.py index 96b8760d349..17b9a82c492 100644 --- a/erpnext/stock/doctype/quality_inspection/test_quality_inspection.py +++ b/erpnext/stock/doctype/quality_inspection/test_quality_inspection.py @@ -1,12 +1,8 @@ # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors and Contributors # See license.txt -<<<<<<< HEAD -======= -from contextlib import contextmanager from unittest.mock import patch ->>>>>>> e8a6884d5e (test: doc_update published for reference on Quality Inspection submit) import frappe from frappe.tests.utils import FrappeTestCase, change_settings from frappe.utils import nowdate