fix: Manually link_fields from flags before rename_doc
This commit is contained in:
parent
ac99c719bc
commit
102afe7de1
@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe.model.utils.rename_field import rename_field
|
from frappe.model.utils.rename_field import rename_field
|
||||||
|
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
if frappe.db.exists('DocType', 'Lab Test') and frappe.db.exists('DocType', 'Lab Test Template'):
|
if frappe.db.exists('DocType', 'Lab Test') and frappe.db.exists('DocType', 'Lab Test Template'):
|
||||||
# rename child doctypes
|
# rename child doctypes
|
||||||
@ -17,7 +18,12 @@ def execute():
|
|||||||
frappe.reload_doc('healthcare', 'doctype', 'lab_test_template')
|
frappe.reload_doc('healthcare', 'doctype', 'lab_test_template')
|
||||||
|
|
||||||
for old_dt, new_dt in doctypes.items():
|
for old_dt, new_dt in doctypes.items():
|
||||||
if not frappe.db.table_exists(new_dt) and frappe.db.table_exists(old_dt):
|
frappe.flags.link_fields = {}
|
||||||
|
should_rename = (
|
||||||
|
frappe.db.table_exists(old_dt)
|
||||||
|
and not frappe.db.table_exists(new_dt)
|
||||||
|
)
|
||||||
|
if should_rename:
|
||||||
frappe.reload_doc('healthcare', 'doctype', frappe.scrub(old_dt))
|
frappe.reload_doc('healthcare', 'doctype', frappe.scrub(old_dt))
|
||||||
frappe.rename_doc('DocType', old_dt, new_dt, force=True)
|
frappe.rename_doc('DocType', old_dt, new_dt, force=True)
|
||||||
frappe.reload_doc('healthcare', 'doctype', frappe.scrub(new_dt))
|
frappe.reload_doc('healthcare', 'doctype', frappe.scrub(new_dt))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user