style: update/standardize rename_doc usage
This commit is contained in:
parent
5a31e22892
commit
1e4ea466d3
@ -4,19 +4,18 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.model.rename_doc import rename_doc
|
|
||||||
from frappe.model.utils.rename_field import rename_field
|
from frappe.model.utils.rename_field import rename_field
|
||||||
|
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
# Rename and reload the Land Unit and Linked Land Unit doctypes
|
# 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'):
|
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')
|
frappe.reload_doc('assets', 'doctype', 'location')
|
||||||
|
|
||||||
if frappe.db.table_exists('Linked Land Unit') and not frappe.db.table_exists('Linked 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')
|
frappe.reload_doc('assets', 'doctype', 'linked_location')
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.model.rename_doc import rename_doc
|
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
if frappe.db.table_exists("Asset Adjustment") and not frappe.db.table_exists("Asset Value Adjustment"):
|
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')
|
frappe.reload_doc('assets', 'doctype', 'asset_value_adjustment')
|
@ -2,9 +2,8 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from frappe.model.rename_doc import rename_doc
|
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
def execute():
|
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')
|
frappe.reload_doc('hr', 'doctype', 'employee_health_insurance')
|
@ -1,6 +1,5 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.model.rename_doc import rename_doc
|
|
||||||
from frappe.model.utils.rename_field import rename_field
|
from frappe.model.utils.rename_field import rename_field
|
||||||
from frappe.modules import scrub, get_doctype_module
|
from frappe.modules import scrub, get_doctype_module
|
||||||
|
|
||||||
@ -37,7 +36,7 @@ doc_rename_map = {
|
|||||||
def execute():
|
def execute():
|
||||||
for dt in doc_rename_map:
|
for dt in doc_rename_map:
|
||||||
if frappe.db.exists('DocType', dt):
|
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:
|
for dn in field_rename_map:
|
||||||
if frappe.db.exists('DocType', dn):
|
if frappe.db.exists('DocType', dn):
|
||||||
|
@ -2,18 +2,17 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from frappe.model.rename_doc import rename_doc
|
|
||||||
from frappe.model.utils.rename_field import rename_field
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.model.utils.rename_field import rename_field
|
||||||
|
|
||||||
def execute():
|
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')
|
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')
|
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('manufacturing', 'doctype', 'work_order_operation')
|
||||||
|
|
||||||
frappe.reload_doc('projects', 'doctype', 'timesheet')
|
frappe.reload_doc('projects', 'doctype', 'timesheet')
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.model.rename_doc import rename_doc
|
|
||||||
from frappe.model.utils.rename_field import rename_field
|
from frappe.model.utils.rename_field import rename_field
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils.nestedset import rebuild_tree
|
from frappe.utils.nestedset import rebuild_tree
|
||||||
@ -9,7 +8,7 @@ def execute():
|
|||||||
if frappe.db.table_exists("Supplier Group"):
|
if frappe.db.table_exists("Supplier Group"):
|
||||||
frappe.reload_doc('setup', 'doctype', 'supplier_group')
|
frappe.reload_doc('setup', 'doctype', 'supplier_group')
|
||||||
elif frappe.db.table_exists("Supplier Type"):
|
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('setup', 'doctype', 'supplier_group')
|
||||||
frappe.reload_doc("accounts", "doctype", "pricing_rule")
|
frappe.reload_doc("accounts", "doctype", "pricing_rule")
|
||||||
frappe.reload_doc("accounts", "doctype", "tax_rule")
|
frappe.reload_doc("accounts", "doctype", "tax_rule")
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.model.rename_doc import rename_doc
|
|
||||||
|
|
||||||
doctypes = {
|
doctypes = {
|
||||||
'Price Discount Slab': 'Promotional Scheme Price Discount',
|
'Price Discount Slab': 'Promotional Scheme Price Discount',
|
||||||
@ -16,6 +15,6 @@ doctypes = {
|
|||||||
def execute():
|
def execute():
|
||||||
for old_doc, new_doc in doctypes.items():
|
for old_doc, new_doc in doctypes.items():
|
||||||
if not frappe.db.table_exists(new_doc) and frappe.db.table_exists(old_doc):
|
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.reload_doc("accounts", "doctype", frappe.scrub(new_doc))
|
||||||
frappe.delete_doc("DocType", old_doc)
|
frappe.delete_doc("DocType", old_doc)
|
||||||
|
@ -11,7 +11,6 @@ from erpnext.controllers.item_variant import (create_variant, ItemVariantExistsE
|
|||||||
InvalidItemAttributeValueError, get_variant)
|
InvalidItemAttributeValueError, get_variant)
|
||||||
from erpnext.stock.doctype.item.item import StockExistsForTemplate, InvalidBarcode
|
from erpnext.stock.doctype.item.item import StockExistsForTemplate, InvalidBarcode
|
||||||
from erpnext.stock.doctype.item.item import get_uom_conv_factor
|
from erpnext.stock.doctype.item.item import get_uom_conv_factor
|
||||||
from frappe.model.rename_doc import rename_doc
|
|
||||||
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
||||||
from erpnext.stock.get_item_details import get_item_details
|
from erpnext.stock.get_item_details import get_item_details
|
||||||
|
|
||||||
@ -348,7 +347,7 @@ class TestItem(unittest.TestCase):
|
|||||||
make_stock_entry(item_code="Test Item for Merging 2", target="_Test Warehouse 1 - _TC",
|
make_stock_entry(item_code="Test Item for Merging 2", target="_Test Warehouse 1 - _TC",
|
||||||
qty=1, rate=100)
|
qty=1, rate=100)
|
||||||
|
|
||||||
rename_doc("Item", "Test Item for Merging 1", "Test Item for Merging 2", merge=True)
|
frappe.rename_doc("Item", "Test Item for Merging 1", "Test Item for Merging 2", merge=True)
|
||||||
|
|
||||||
self.assertFalse(frappe.db.exists("Item", "Test Item for Merging 1"))
|
self.assertFalse(frappe.db.exists("Item", "Test Item for Merging 1"))
|
||||||
|
|
||||||
|
@ -1,18 +1,22 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from frappe.model.rename_doc import rename_doc
|
|
||||||
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
import unittest
|
||||||
|
|
||||||
|
import frappe
|
||||||
from frappe.utils import cint
|
from frappe.utils import cint
|
||||||
from erpnext import set_perpetual_inventory
|
|
||||||
from frappe.test_runner import make_test_records
|
from frappe.test_runner import make_test_records
|
||||||
from erpnext.accounts.doctype.account.test_account import get_inventory_account, create_account
|
|
||||||
|
|
||||||
import erpnext
|
import erpnext
|
||||||
import frappe
|
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
||||||
import unittest
|
from erpnext import set_perpetual_inventory
|
||||||
|
from erpnext.accounts.doctype.account.test_account import get_inventory_account, create_account
|
||||||
|
|
||||||
|
|
||||||
test_records = frappe.get_test_records('Warehouse')
|
test_records = frappe.get_test_records('Warehouse')
|
||||||
|
|
||||||
|
|
||||||
class TestWarehouse(unittest.TestCase):
|
class TestWarehouse(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
if not frappe.get_value('Item', '_Test Item'):
|
if not frappe.get_value('Item', '_Test Item'):
|
||||||
@ -41,7 +45,7 @@ class TestWarehouse(unittest.TestCase):
|
|||||||
# Rename with abbr
|
# Rename with abbr
|
||||||
if frappe.db.exists("Warehouse", "Test Warehouse for Renaming 2 - _TC"):
|
if frappe.db.exists("Warehouse", "Test Warehouse for Renaming 2 - _TC"):
|
||||||
frappe.delete_doc("Warehouse", "Test Warehouse for Renaming 2 - _TC")
|
frappe.delete_doc("Warehouse", "Test Warehouse for Renaming 2 - _TC")
|
||||||
rename_doc("Warehouse", "Test Warehouse for Renaming 1 - _TC", "Test Warehouse for Renaming 2 - _TC")
|
frappe.rename_doc("Warehouse", "Test Warehouse for Renaming 1 - _TC", "Test Warehouse for Renaming 2 - _TC")
|
||||||
|
|
||||||
self.assertTrue(frappe.db.get_value("Warehouse",
|
self.assertTrue(frappe.db.get_value("Warehouse",
|
||||||
filters={"account": "Test Warehouse for Renaming 1 - _TC"}))
|
filters={"account": "Test Warehouse for Renaming 1 - _TC"}))
|
||||||
@ -50,7 +54,7 @@ class TestWarehouse(unittest.TestCase):
|
|||||||
if frappe.db.exists("Warehouse", "Test Warehouse for Renaming 3 - _TC"):
|
if frappe.db.exists("Warehouse", "Test Warehouse for Renaming 3 - _TC"):
|
||||||
frappe.delete_doc("Warehouse", "Test Warehouse for Renaming 3 - _TC")
|
frappe.delete_doc("Warehouse", "Test Warehouse for Renaming 3 - _TC")
|
||||||
|
|
||||||
rename_doc("Warehouse", "Test Warehouse for Renaming 2 - _TC", "Test Warehouse for Renaming 3")
|
frappe.rename_doc("Warehouse", "Test Warehouse for Renaming 2 - _TC", "Test Warehouse for Renaming 3")
|
||||||
|
|
||||||
self.assertTrue(frappe.db.get_value("Warehouse",
|
self.assertTrue(frappe.db.get_value("Warehouse",
|
||||||
filters={"account": "Test Warehouse for Renaming 1 - _TC"}))
|
filters={"account": "Test Warehouse for Renaming 1 - _TC"}))
|
||||||
@ -58,7 +62,7 @@ class TestWarehouse(unittest.TestCase):
|
|||||||
# Another rename with multiple dashes
|
# Another rename with multiple dashes
|
||||||
if frappe.db.exists("Warehouse", "Test - Warehouse - Company - _TC"):
|
if frappe.db.exists("Warehouse", "Test - Warehouse - Company - _TC"):
|
||||||
frappe.delete_doc("Warehouse", "Test - Warehouse - Company - _TC")
|
frappe.delete_doc("Warehouse", "Test - Warehouse - Company - _TC")
|
||||||
rename_doc("Warehouse", "Test Warehouse for Renaming 3 - _TC", "Test - Warehouse - Company")
|
frappe.rename_doc("Warehouse", "Test Warehouse for Renaming 3 - _TC", "Test - Warehouse - Company")
|
||||||
|
|
||||||
def test_warehouse_merging(self):
|
def test_warehouse_merging(self):
|
||||||
set_perpetual_inventory(1)
|
set_perpetual_inventory(1)
|
||||||
@ -78,7 +82,7 @@ class TestWarehouse(unittest.TestCase):
|
|||||||
{"item_code": "_Test Item", "warehouse": "Test Warehouse for Merging 2 - _TC"}, "actual_qty"))
|
{"item_code": "_Test Item", "warehouse": "Test Warehouse for Merging 2 - _TC"}, "actual_qty"))
|
||||||
)
|
)
|
||||||
|
|
||||||
rename_doc("Warehouse", "Test Warehouse for Merging 1 - _TC",
|
frappe.rename_doc("Warehouse", "Test Warehouse for Merging 1 - _TC",
|
||||||
"Test Warehouse for Merging 2 - _TC", merge=True)
|
"Test Warehouse for Merging 2 - _TC", merge=True)
|
||||||
|
|
||||||
self.assertFalse(frappe.db.exists("Warehouse", "Test Warehouse for Merging 1 - _TC"))
|
self.assertFalse(frappe.db.exists("Warehouse", "Test Warehouse for Merging 1 - _TC"))
|
||||||
|
Loading…
Reference in New Issue
Block a user