From 99d348ffa3d88cd5e0c8a21fcb66f4b62ae73fb6 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Tue, 19 May 2020 20:28:19 +0530 Subject: [PATCH] fix: Patch for Setting Missing Company in Healthcare DocTypes (#21790) * fix: patch for setting missing company in Healthcare DocTypes * fix: check doctype exists Co-authored-by: Nabin Hait --- erpnext/patches.txt | 1 + .../v13_0/set_company_field_in_healthcare_doctypes.py | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 erpnext/patches/v13_0/set_company_field_in_healthcare_doctypes.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 56186c4e4c..bb9bb97e64 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -688,4 +688,5 @@ erpnext.patches.v12_0.set_serial_no_status erpnext.patches.v12_0.update_price_list_currency_in_bom execute:frappe.delete_doc_if_exists('Dashboard', 'Accounts') erpnext.patches.v13_0.update_actual_start_and_end_date_in_wo +erpnext.patches.v13_0.set_company_field_in_healthcare_doctypes erpnext.patches.v12_0.update_bom_in_so_mr diff --git a/erpnext/patches/v13_0/set_company_field_in_healthcare_doctypes.py b/erpnext/patches/v13_0/set_company_field_in_healthcare_doctypes.py new file mode 100644 index 0000000000..2c646b164f --- /dev/null +++ b/erpnext/patches/v13_0/set_company_field_in_healthcare_doctypes.py @@ -0,0 +1,9 @@ +from __future__ import unicode_literals +import frappe + +def execute(): + company = frappe.db.get_single_value('Global Defaults', 'default_company') + doctypes = ['Clinical Procedure', 'Inpatient Record', 'Lab Test', 'Patient Appointment', 'Patient Encounter', 'Vital Signs'] + for entry in doctypes: + if frappe.db.exists('DocType', entry): + frappe.db.sql("update `tab{dt}` set company = '{company}' where ifnull(company, '') = ''".format(dt=entry, company=company))