fix: Laboratory Module patch (#25431)

This commit is contained in:
Rucha Mahabal 2021-04-22 16:11:17 +05:30 committed by GitHub
parent 19b73968d7
commit e3b8057eb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,16 +38,37 @@ def execute():
""".format(doctype), {'parentfield': parentfield}) """.format(doctype), {'parentfield': parentfield})
# copy renamed child table fields (fields were already renamed in old doctype json, hence sql) # copy renamed child table fields (fields were already renamed in old doctype json, hence sql)
frappe.db.sql("""UPDATE `tabNormal Test Result` SET lab_test_name = test_name""") rename_fields = {
frappe.db.sql("""UPDATE `tabNormal Test Result` SET lab_test_event = test_event""") 'lab_test_name': 'test_name',
frappe.db.sql("""UPDATE `tabNormal Test Result` SET lab_test_uom = test_uom""") 'lab_test_event': 'test_event',
frappe.db.sql("""UPDATE `tabNormal Test Result` SET lab_test_comment = test_comment""") 'lab_test_uom': 'test_uom',
frappe.db.sql("""UPDATE `tabNormal Test Template` SET lab_test_event = test_event""") 'lab_test_comment': 'test_comment'
frappe.db.sql("""UPDATE `tabNormal Test Template` SET lab_test_uom = test_uom""") }
frappe.db.sql("""UPDATE `tabDescriptive Test Result` SET lab_test_particulars = test_particulars""")
frappe.db.sql("""UPDATE `tabLab Test Group Template` SET lab_test_template = test_template""") for new, old in rename_fields.items():
frappe.db.sql("""UPDATE `tabLab Test Group Template` SET lab_test_description = test_description""") if frappe.db.has_column('Normal Test Result', old):
frappe.db.sql("""UPDATE `tabLab Test Group Template` SET lab_test_rate = test_rate""") frappe.db.sql("""UPDATE `tabNormal Test Result` SET %(new)s = %(old)s""", {
'new': new, 'old': old})
if frappe.db.has_column('Normal Test Template', 'test_event'):
frappe.db.sql("""UPDATE `tabNormal Test Template` SET lab_test_event = test_event""")
if frappe.db.has_column('Normal Test Template', 'test_uom'):
frappe.db.sql("""UPDATE `tabNormal Test Template` SET lab_test_uom = test_uom""")
if frappe.db.has_column('Descriptive Test Result', 'test_particulars'):
frappe.db.sql("""UPDATE `tabDescriptive Test Result` SET lab_test_particulars = test_particulars""")
rename_fields = {
'lab_test_template': 'test_template',
'lab_test_description': 'test_description',
'lab_test_rate': 'test_rate'
}
for new, old in rename_fields.items():
if frappe.db.has_column('Lab Test Group Template', old):
frappe.db.sql("""UPDATE `tabLab Test Group Template` SET %(new)s = %(old)s""", {
'new': new, 'old': old})
# rename field # rename field
frappe.reload_doc('healthcare', 'doctype', 'lab_test') frappe.reload_doc('healthcare', 'doctype', 'lab_test')