mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-11 13:41:47 +00:00
Merge pull request #57920 from frappe/mergify/bp/version-15-hotfix/pr-57918
fix: sync open reference forms after Quality Inspection submit (backport #57918)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors and Contributors
|
||||
# See license.txt
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
import frappe
|
||||
from frappe.tests.utils import FrappeTestCase, change_settings
|
||||
from frappe.utils import nowdate
|
||||
@@ -58,6 +60,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)
|
||||
|
||||
Reference in New Issue
Block a user