style: update/standardize rename_doc usage

This commit is contained in:
Gavin D'souza
2019-12-11 09:36:17 +05:30
parent 5a31e22892
commit 1e4ea466d3
9 changed files with 27 additions and 30 deletions

View File

@@ -4,19 +4,18 @@
from __future__ import unicode_literals
import frappe
from frappe.model.rename_doc import rename_doc
from frappe.model.utils.rename_field import rename_field
def execute():
# Rename and reload the Land Unit and Linked Land Unit doctypes
if frappe.db.table_exists('Land Unit') and not frappe.db.table_exists('Location'):
rename_doc('DocType', 'Land Unit', 'Location', force=True)
frappe.rename_doc('DocType', 'Land Unit', 'Location', force=True)
frappe.reload_doc('assets', 'doctype', 'location')
if frappe.db.table_exists('Linked Land Unit') and not frappe.db.table_exists('Linked Location'):
rename_doc('DocType', 'Linked Land Unit', 'Linked Location', force=True)
frappe.rename_doc('DocType', 'Linked Land Unit', 'Linked Location', force=True)
frappe.reload_doc('assets', 'doctype', 'linked_location')

View File

@@ -3,9 +3,9 @@
from __future__ import unicode_literals
import frappe
from frappe.model.rename_doc import rename_doc
def execute():
if frappe.db.table_exists("Asset Adjustment") and not frappe.db.table_exists("Asset Value Adjustment"):
rename_doc('DocType', 'Asset Adjustment', 'Asset Value Adjustment', force=True)
frappe.rename_doc('DocType', 'Asset Adjustment', 'Asset Value Adjustment', force=True)
frappe.reload_doc('assets', 'doctype', 'asset_value_adjustment')

View File

@@ -2,9 +2,8 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
from frappe.model.rename_doc import rename_doc
import frappe
def execute():
rename_doc('DocType', 'Health Insurance', 'Employee Health Insurance', force=True)
frappe.rename_doc('DocType', 'Health Insurance', 'Employee Health Insurance', force=True)
frappe.reload_doc('hr', 'doctype', 'employee_health_insurance')

View File

@@ -1,6 +1,5 @@
from __future__ import unicode_literals
import frappe
from frappe.model.rename_doc import rename_doc
from frappe.model.utils.rename_field import rename_field
from frappe.modules import scrub, get_doctype_module
@@ -37,7 +36,7 @@ doc_rename_map = {
def execute():
for dt in doc_rename_map:
if frappe.db.exists('DocType', dt):
rename_doc('DocType', dt, doc_rename_map[dt], force=True)
frappe.rename_doc('DocType', dt, doc_rename_map[dt], force=True)
for dn in field_rename_map:
if frappe.db.exists('DocType', dn):

View File

@@ -2,18 +2,17 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
from frappe.model.rename_doc import rename_doc
from frappe.model.utils.rename_field import rename_field
import frappe
from frappe.model.utils.rename_field import rename_field
def execute():
rename_doc('DocType', 'Production Order', 'Work Order', force=True)
frappe.rename_doc('DocType', 'Production Order', 'Work Order', force=True)
frappe.reload_doc('manufacturing', 'doctype', 'work_order')
rename_doc('DocType', 'Production Order Item', 'Work Order Item', force=True)
frappe.rename_doc('DocType', 'Production Order Item', 'Work Order Item', force=True)
frappe.reload_doc('manufacturing', 'doctype', 'work_order_item')
rename_doc('DocType', 'Production Order Operation', 'Work Order Operation', force=True)
frappe.rename_doc('DocType', 'Production Order Operation', 'Work Order Operation', force=True)
frappe.reload_doc('manufacturing', 'doctype', 'work_order_operation')
frappe.reload_doc('projects', 'doctype', 'timesheet')

View File

@@ -1,6 +1,5 @@
from __future__ import unicode_literals
import frappe
from frappe.model.rename_doc import rename_doc
from frappe.model.utils.rename_field import rename_field
from frappe import _
from frappe.utils.nestedset import rebuild_tree
@@ -9,7 +8,7 @@ def execute():
if frappe.db.table_exists("Supplier Group"):
frappe.reload_doc('setup', 'doctype', 'supplier_group')
elif frappe.db.table_exists("Supplier Type"):
rename_doc("DocType", "Supplier Type", "Supplier Group", force=True)
frappe.rename_doc("DocType", "Supplier Type", "Supplier Group", force=True)
frappe.reload_doc('setup', 'doctype', 'supplier_group')
frappe.reload_doc("accounts", "doctype", "pricing_rule")
frappe.reload_doc("accounts", "doctype", "tax_rule")

View File

@@ -3,7 +3,6 @@
from __future__ import unicode_literals
import frappe
from frappe.model.rename_doc import rename_doc
doctypes = {
'Price Discount Slab': 'Promotional Scheme Price Discount',
@@ -16,6 +15,6 @@ doctypes = {
def execute():
for old_doc, new_doc in doctypes.items():
if not frappe.db.table_exists(new_doc) and frappe.db.table_exists(old_doc):
rename_doc('DocType', old_doc, new_doc)
frappe.rename_doc('DocType', old_doc, new_doc)
frappe.reload_doc("accounts", "doctype", frappe.scrub(new_doc))
frappe.delete_doc("DocType", old_doc)