fix healthcare patch (#15584)
This commit is contained in:
parent
4c61861163
commit
dc2bab2b72
@ -15,7 +15,7 @@ def execute():
|
|||||||
frappe.reload_doc('accounts', 'doctype', 'loyalty_program')
|
frappe.reload_doc('accounts', 'doctype', 'loyalty_program')
|
||||||
frappe.reload_doc('accounts', 'doctype', 'sales_invoice_item')
|
frappe.reload_doc('accounts', 'doctype', 'sales_invoice_item')
|
||||||
|
|
||||||
if "healthcare" not in frappe.get_active_domains():
|
if "Healthcare" not in frappe.get_active_domains():
|
||||||
return
|
return
|
||||||
|
|
||||||
healthcare_custom_field_in_sales_invoice()
|
healthcare_custom_field_in_sales_invoice()
|
||||||
@ -34,24 +34,25 @@ def execute():
|
|||||||
frappe.reload_doc(get_doctype_module("Sales Invoice"), 'doctype', 'sales_invoice')
|
frappe.reload_doc(get_doctype_module("Sales Invoice"), 'doctype', 'sales_invoice')
|
||||||
for doc_id in doc_list:
|
for doc_id in doc_list:
|
||||||
invoice_id = frappe.db.get_value(si_ref_doc, doc_id[0], sales_invoice_referenced_doc[si_ref_doc])
|
invoice_id = frappe.db.get_value(si_ref_doc, doc_id[0], sales_invoice_referenced_doc[si_ref_doc])
|
||||||
invoice = frappe.get_doc("Sales Invoice", invoice_id)
|
if frappe.db.exists("Sales Invoice", invoice_id):
|
||||||
if invoice.items:
|
if si_ref_doc == "Lab Test":
|
||||||
marked = False
|
template = frappe.db.get_value("Lab Test", doc_id[0], "template")
|
||||||
if not marked:
|
if template:
|
||||||
|
item = frappe.db.get_value("Lab Test Template", template, "item")
|
||||||
|
if item:
|
||||||
|
frappe.db.sql("""update `tabSales Invoice Item` set reference_dt = '{0}',
|
||||||
|
reference_dn = '{1}' where parent = '{2}' and item_code='{3}'""".format\
|
||||||
|
(si_ref_doc, doc_id[0], invoice_id, item))
|
||||||
|
else:
|
||||||
|
invoice = frappe.get_doc("Sales Invoice", invoice_id)
|
||||||
for item_line in invoice.items:
|
for item_line in invoice.items:
|
||||||
marked = True
|
if not item_line.reference_dn:
|
||||||
frappe.db.sql("""
|
item_line.db_set({"reference_dt":si_ref_doc, "reference_dn": doc_id[0]})
|
||||||
update `tabSales Invoice Item`
|
break
|
||||||
set reference_dt = '{0}', reference_dn = '{1}'
|
|
||||||
where name = '{2}'
|
|
||||||
""".format(si_ref_doc, doc_id[0], item_line.name))
|
|
||||||
|
|
||||||
# Documents mark invoiced for submitted sales invoice
|
# Documents mark invoiced for submitted sales invoice
|
||||||
frappe.db.sql("""
|
frappe.db.sql("""update `tab{0}` doc, `tabSales Invoice` si
|
||||||
update `tab{0}` doc, `tabSales Invoice` si
|
set doc.invoiced = 1 where si.docstatus = 1 and doc.{1} = si.name
|
||||||
set doc.invoiced = 1
|
""".format(si_ref_doc, sales_invoice_referenced_doc[si_ref_doc]))
|
||||||
where si.docstatus = 1 and doc.{1} = si.name
|
|
||||||
""".format(si_ref_doc, sales_invoice_referenced_doc[si_ref_doc]))
|
|
||||||
|
|
||||||
def healthcare_custom_field_in_sales_invoice():
|
def healthcare_custom_field_in_sales_invoice():
|
||||||
frappe.reload_doc('healthcare', 'doctype', 'patient')
|
frappe.reload_doc('healthcare', 'doctype', 'patient')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user