def test_item_merging(self): create_item("Test Item for Merging 1") create_item("Test Item for Merging 2") make_stock_entry(item_code="Test Item for Merging 1", target="_Test Warehouse - _TC", qty=1, rate=100) make_stock_entry(item_code="Test Item for Merging 2", target="_Test Warehouse 1 - _TC", qty=1, rate=100) rename_doc("Item", "Test Item for Merging 1", "Test Item for Merging 2", merge=True) self.assertFalse(dataent.db.exists("Item", "Test Item for Merging 1")) self.assertTrue( dataent.db.get_value( "Bin", { "item_code": "Test Item for Merging 2", "warehouse": "_Test Warehouse - _TC" })) self.assertTrue( dataent.db.get_value( "Bin", { "item_code": "Test Item for Merging 2", "warehouse": "_Test Warehouse 1 - _TC" }))
def execute(): for dt in doc_rename_map: if dataent.db.exists('DocType', dt): rename_doc('DocType', dt, doc_rename_map[dt], force=True) for dn in field_rename_map: if dataent.db.exists('DocType', dn): dataent.reload_doc(get_doctype_module(dn), "doctype", scrub(dn)) for dt, field_list in field_rename_map.items(): if dataent.db.exists('DocType', dt): for field in field_list: if dataent.db.has_column(dt, field[0]): rename_field(dt, field[0], field[1]) if dataent.db.exists('DocType', 'Practitioner Service Unit Schedule'): if dataent.db.has_column('Practitioner Service Unit Schedule', 'parentfield'): dataent.db.sql(""" update `tabPractitioner Service Unit Schedule` set parentfield = 'practitioner_schedules' where parentfield = 'physician_schedules' and parenttype = 'Healthcare Practitioner' """) if dataent.db.exists("DocType", "Healthcare Practitioner"): dataent.reload_doc("healthcare", "doctype", "healthcare_practitioner") dataent.reload_doc("healthcare", "doctype", "practitioner_service_unit_schedule") if dataent.db.has_column('Healthcare Practitioner', 'physician_schedule'): for doc in dataent.get_all('Healthcare Practitioner'): _doc = dataent.get_doc('Healthcare Practitioner', doc.name) if _doc.physician_schedule: _doc.append('practitioner_schedules', {'schedule': _doc.physician_schedule}) _doc.save()
def execute(): if dataent.db.table_exists( "Asset Adjustment" ) and not dataent.db.table_exists("Asset Value Adjustment"): rename_doc('DocType', 'Asset Adjustment', 'Asset Value Adjustment', force=True) dataent.reload_doc('assets', 'doctype', 'asset_value_adjustment')
def execute(): if dataent.db.table_exists( "Email Alert Recipient" ) and not dataent.db.table_exists("Notification Recipient"): rename_doc('DocType', 'Email Alert Recipient', 'Notification Recipient') dataent.reload_doc('email', 'doctype', 'notification_recipient') if dataent.db.table_exists( "Email Alert") and not dataent.db.table_exists("Notification"): rename_doc('DocType', 'Email Alert', 'Notification') dataent.reload_doc('email', 'doctype', 'notification')
def test_warehouse_merging(self): set_perpetual_inventory(1) create_warehouse("Test Warehouse for Merging 1") create_warehouse("Test Warehouse for Merging 2") make_stock_entry(item_code="_Test Item", target="Test Warehouse for Merging 1 - _TC", qty=1, rate=100) make_stock_entry(item_code="_Test Item", target="Test Warehouse for Merging 2 - _TC", qty=1, rate=100) existing_bin_qty = (cint( dataent.db.get_value( "Bin", { "item_code": "_Test Item", "warehouse": "Test Warehouse for Merging 1 - _TC" }, "actual_qty")) + cint( dataent.db.get_value( "Bin", { "item_code": "_Test Item", "warehouse": "Test Warehouse for Merging 2 - _TC" }, "actual_qty"))) rename_doc("Warehouse", "Test Warehouse for Merging 1 - _TC", "Test Warehouse for Merging 2 - _TC", merge=True) self.assertFalse( dataent.db.exists("Warehouse", "Test Warehouse for Merging 1 - _TC")) bin_qty = dataent.db.get_value( "Bin", { "item_code": "_Test Item", "warehouse": "Test Warehouse for Merging 2 - _TC" }, "actual_qty") self.assertEqual(bin_qty, existing_bin_qty) self.assertTrue( dataent.db.get_value( "Warehouse", filters={"account": "Test Warehouse for Merging 2 - _TC"}))
def execute(): if dataent.db.table_exists("Supplier Group"): dataent.reload_doc('setup', 'doctype', 'supplier_group') elif dataent.db.table_exists("Supplier Type"): rename_doc("DocType", "Supplier Type", "Supplier Group", force=True) dataent.reload_doc('setup', 'doctype', 'supplier_group') dataent.reload_doc("accounts", "doctype", "pricing_rule") dataent.reload_doc("accounts", "doctype", "tax_rule") dataent.reload_doc("buying", "doctype", "buying_settings") dataent.reload_doc("buying", "doctype", "supplier") rename_field("Supplier Group", "supplier_type", "supplier_group_name") rename_field("Supplier", "supplier_type", "supplier_group") rename_field("Buying Settings", "supplier_type", "supplier_group") rename_field("Pricing Rule", "supplier_type", "supplier_group") rename_field("Tax Rule", "supplier_type", "supplier_group") build_tree()
def execute(): rename_doc('DocType', 'Production Order', 'Work Order', force=True) dataent.reload_doc('manufacturing', 'doctype', 'work_order') rename_doc('DocType', 'Production Order Item', 'Work Order Item', force=True) dataent.reload_doc('manufacturing', 'doctype', 'work_order_item') rename_doc('DocType', 'Production Order Operation', 'Work Order Operation', force=True) dataent.reload_doc('manufacturing', 'doctype', 'work_order_operation') dataent.reload_doc('projects', 'doctype', 'timesheet') dataent.reload_doc('stock', 'doctype', 'stock_entry') rename_field("Timesheet", "production_order", "work_order") rename_field("Stock Entry", "production_order", "work_order") dataent.rename_doc("Report", "Production Orders in Progress", "Work Orders in Progress", force=True) dataent.rename_doc("Report", "Completed Production Orders", "Completed Work Orders", force=True) dataent.rename_doc("Report", "Open Production Orders", "Open Work Orders", force=True) dataent.rename_doc("Report", "Issued Items Against Production Order", "Issued Items Against Work Order", force=True) dataent.rename_doc("Report", "Production Order Stock Report", "Work Order Stock Report", force=True) dataent.db.sql("""update `tabDesktop Icon` \ set label='Work Order', module_name='Work Order' \ where label='Production Order'""") dataent.db.sql("""update `tabDesktop Icon` \ set link='List/Work Order' \ where link='List/Production Order'""")
def test_warehouse_renaming(self): set_perpetual_inventory(1) create_warehouse("Test Warehouse for Renaming 1") account = get_inventory_account("_Test Company", "Test Warehouse for Renaming 1 - _TC") self.assertTrue( dataent.db.get_value("Warehouse", filters={"account": account})) # Rename with abbr if dataent.db.exists("Warehouse", "Test Warehouse for Renaming 2 - _TC"): dataent.delete_doc("Warehouse", "Test Warehouse for Renaming 2 - _TC") rename_doc("Warehouse", "Test Warehouse for Renaming 1 - _TC", "Test Warehouse for Renaming 2 - _TC") self.assertTrue( dataent.db.get_value( "Warehouse", filters={"account": "Test Warehouse for Renaming 1 - _TC"})) # Rename without abbr if dataent.db.exists("Warehouse", "Test Warehouse for Renaming 3 - _TC"): dataent.delete_doc("Warehouse", "Test Warehouse for Renaming 3 - _TC") rename_doc("Warehouse", "Test Warehouse for Renaming 2 - _TC", "Test Warehouse for Renaming 3") self.assertTrue( dataent.db.get_value( "Warehouse", filters={"account": "Test Warehouse for Renaming 1 - _TC"})) # Another rename with multiple dashes if dataent.db.exists("Warehouse", "Test - Warehouse - Company - _TC"): dataent.delete_doc("Warehouse", "Test - Warehouse - Company - _TC") rename_doc("Warehouse", "Test Warehouse for Renaming 3 - _TC", "Test - Warehouse - Company")
def execute(): rename_doc('DocType', 'Health Insurance', 'Employee Health Insurance', force=True) dataent.reload_doc('hr', 'doctype', 'employee_health_insurance')
def execute(): if dataent.db.table_exists( "Standard Reply" ) and not dataent.db.table_exists("Email Template"): rename_doc('DocType', 'Standard Reply', 'Email Template') dataent.reload_doc('email', 'doctype', 'email_template')
def execute(): # Rename and reload the Land Unit and Linked Land Unit doctypes if dataent.db.table_exists( 'Land Unit') and not dataent.db.table_exists('Location'): rename_doc('DocType', 'Land Unit', 'Location', force=True) dataent.reload_doc('assets', 'doctype', 'location') if dataent.db.table_exists( 'Linked Land Unit' ) and not dataent.db.table_exists('Linked Location'): rename_doc('DocType', 'Linked Land Unit', 'Linked Location', force=True) dataent.reload_doc('assets', 'doctype', 'linked_location') if not dataent.db.table_exists('Crop Cycle'): dataent.reload_doc('agriculture', 'doctype', 'crop_cycle') # Rename the fields in related doctypes if 'linked_land_unit' in dataent.db.get_table_columns('Crop Cycle'): rename_field('Crop Cycle', 'linked_land_unit', 'linked_location') if 'land_unit' in dataent.db.get_table_columns('Linked Location'): rename_field('Linked Location', 'land_unit', 'location') if not dataent.db.exists("Location", "All Land Units"): dataent.get_doc({ "doctype": "Location", "is_group": True, "location_name": "All Land Units" }).insert(ignore_permissions=True) if dataent.db.table_exists('Land Unit'): land_units = dataent.get_all('Land Unit', fields=['*'], order_by='lft') for land_unit in land_units: if not dataent.db.exists('Location', land_unit.get('land_unit_name')): dataent.get_doc({ 'doctype': 'Location', 'location_name': land_unit.get('land_unit_name'), 'parent_location': land_unit.get('parent_land_unit') or "All Land Units", 'is_container': land_unit.get('is_container'), 'is_group': land_unit.get('is_group'), 'latitude': land_unit.get('latitude'), 'longitude': land_unit.get('longitude'), 'area': land_unit.get('area'), 'location': land_unit.get('location'), 'lft': land_unit.get('lft'), 'rgt': land_unit.get('rgt') }).insert(ignore_permissions=True) # dataent.db.sql("""update `tabDesktop Icon` set label='Location', module_name='Location' where label='Land Unit'""") dataent.db.sql( """update `tabDesktop Icon` set link='List/Location' where link='List/Land Unit'""" ) # Delete the Land Unit and Linked Land Unit doctypes if dataent.db.table_exists('Land Unit'): dataent.delete_doc('DocType', 'Land Unit', force=1) if dataent.db.table_exists('Linked Land Unit'): dataent.delete_doc('DocType', 'Linked Land Unit', force=1)
def execute(): if dataent.db.exists("DocType", "Google Maps") and not dataent.db.exists( "DocType", "Google Maps Settings"): rename_doc('DocType', 'Google Maps', 'Google Maps Settings') dataent.reload_doc('integrations', 'doctype', 'google_maps_settings')
def execute(): if dataent.db.table_exists( "Workflow Action" ) and not dataent.db.table_exists("Workflow Action Master"): rename_doc('DocType', 'Workflow Action', 'Workflow Action Master') dataent.reload_doc('workflow', 'doctype', 'workflow_action_master')