From 890b6c6219192bcadb5be0f6ee3fcc69f6d4f3ff Mon Sep 17 00:00:00 2001 From: Akash Date: Tue, 27 Feb 2024 17:13:27 +0530 Subject: [PATCH] fix(Diagnostic Report): update sales_invoice_status on Sales Invoice payment updation (cherry picked from commit 224e0f26f40663143a781faba7c7cf0ddb917c01) --- .../diagnostic_report/diagnostic_report.json | 6 ++++-- .../diagnostic_report/diagnostic_report.py | 8 +++++--- healthcare/healthcare/utils.py | 17 +++++++++-------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/healthcare/healthcare/doctype/diagnostic_report/diagnostic_report.json b/healthcare/healthcare/doctype/diagnostic_report/diagnostic_report.json index fc97a3b91c..8433766c9e 100644 --- a/healthcare/healthcare/doctype/diagnostic_report/diagnostic_report.json +++ b/healthcare/healthcare/doctype/diagnostic_report/diagnostic_report.json @@ -97,7 +97,8 @@ "fieldtype": "Link", "hidden": 1, "label": "Sample Collection", - "options": "Sample Collection" + "options": "Sample Collection", + "search_index": 1 }, { "fieldname": "amended_from", @@ -118,6 +119,7 @@ { "fieldname": "sales_invoice_status", "fieldtype": "Data", + "is_virtual": 1, "label": "Sales Invoice Status", "read_only": 1 }, @@ -169,7 +171,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-10-16 17:53:14.702170", + "modified": "2024-02-19 18:41:30.142285", "modified_by": "Administrator", "module": "Healthcare", "name": "Diagnostic Report", diff --git a/healthcare/healthcare/doctype/diagnostic_report/diagnostic_report.py b/healthcare/healthcare/doctype/diagnostic_report/diagnostic_report.py index 14bb4bbe92..365cd06420 100644 --- a/healthcare/healthcare/doctype/diagnostic_report/diagnostic_report.py +++ b/healthcare/healthcare/doctype/diagnostic_report/diagnostic_report.py @@ -30,9 +30,11 @@ def set_title(self): def set_reference_details(self): if self.ref_doctype == "Sales Invoice" and self.docname: - self.sales_invoice_status, self.reference_posting_date = frappe.db.get_value( - "Sales Invoice", self.docname, ["status", "posting_date"] - ) + self.reference_posting_date = frappe.db.get_value("Sales Invoice", self.docname, "posting_date") + + @property + def sales_invoice_status(self): + return frappe.db.get_value(self.ref_doctype, self.docname, "status") def diagnostic_report_print(diagnostic_report): diff --git a/healthcare/healthcare/utils.py b/healthcare/healthcare/utils.py index e1a14465f9..631aa76b22 100644 --- a/healthcare/healthcare/utils.py +++ b/healthcare/healthcare/utils.py @@ -1183,14 +1183,15 @@ def create_sample_collection(doc, patient): def insert_diagnostic_report(doc, patient, sample_collection=None): - diagnostic_report = frappe.new_doc("Diagnostic Report") - diagnostic_report.company = doc.company - diagnostic_report.patient = patient - diagnostic_report.ref_doctype = doc.doctype - diagnostic_report.docname = doc.name - diagnostic_report.practitioner = doc.ref_practitioner - diagnostic_report.sample_collection = sample_collection - diagnostic_report.save(ignore_permissions=True) + if not frappe.db.exists("Diagnostic Report", {"docname": doc.name}): + diagnostic_report = frappe.new_doc("Diagnostic Report") + diagnostic_report.company = doc.company + diagnostic_report.patient = patient + diagnostic_report.ref_doctype = doc.doctype + diagnostic_report.docname = doc.name + diagnostic_report.practitioner = doc.ref_practitioner + diagnostic_report.sample_collection = sample_collection + diagnostic_report.save(ignore_permissions=True) def insert_observation_and_sample_collection(doc, patient, grp, sample_collection, child=None):