Best Python code snippet using localstack_python
merge_land_unit_with_location.py
Source:merge_land_unit_with_location.py
...5from frappe.model.rename_doc import rename_doc6from frappe.model.utils.rename_field import rename_field7def execute():8 # Rename and reload the Land Unit and Linked Land Unit doctypes9 if frappe.db.table_exists('Land Unit') and not frappe.db.table_exists('Location'):10 rename_doc('DocType', 'Land Unit', 'Location', force=True)11 frappe.reload_doc('assets', 'doctype', 'location')12 if frappe.db.table_exists('Linked Land Unit') and not frappe.db.table_exists('Linked Location'):13 rename_doc('DocType', 'Linked Land Unit', 'Linked Location', force=True)14 frappe.reload_doc('assets', 'doctype', 'linked_location')15 if not frappe.db.table_exists('Crop Cycle'):16 frappe.reload_doc('agriculture', 'doctype', 'crop_cycle')17 # Rename the fields in related doctypes18 if 'linked_land_unit' in frappe.db.get_table_columns('Crop Cycle'):19 rename_field('Crop Cycle', 'linked_land_unit', 'linked_location')20 if 'land_unit' in frappe.db.get_table_columns('Linked Location'):21 rename_field('Linked Location', 'land_unit', 'location')22 if not frappe.db.exists("Location", "All Land Units"):23 frappe.get_doc({"doctype": "Location", "is_group": True, "location_name": "All Land Units"}).insert(ignore_permissions=True)24 if frappe.db.table_exists('Land Unit'):25 land_units = frappe.get_all('Land Unit', fields=['*'], order_by='lft')26 for land_unit in land_units:27 if not frappe.db.exists('Location', land_unit.get('land_unit_name')):28 frappe.get_doc({29 'doctype': 'Location',30 'location_name': land_unit.get('land_unit_name'),31 'parent_location': land_unit.get('parent_land_unit') or "All Land Units",32 'is_container': land_unit.get('is_container'),33 'is_group': land_unit.get('is_group'),34 'latitude': land_unit.get('latitude'),35 'longitude': land_unit.get('longitude'),36 'area': land_unit.get('area'),37 'location': land_unit.get('location'),38 'lft': land_unit.get('lft'),39 'rgt': land_unit.get('rgt')40 }).insert(ignore_permissions=True)41 # Delete the Land Unit and Linked Land Unit doctypes42 if frappe.db.table_exists('Land Unit'):43 frappe.delete_doc('DocType', 'Land Unit', force=1)44 if frappe.db.table_exists('Linked Land Unit'):...
rename_region_mater_regions.py
Source:rename_region_mater_regions.py
1import frappe2def execute():3 frappe.errprint("renaming regions master to Regions")4 if frappe.db.table_exists("tabRegion Master"):5 frappe.rename_doc("DocType", "Region Master", "Regions")6 if frappe.db.table_exists("tabZone Master"):7 frappe.rename_doc("DocType", "Zone Master", "Zones")8 if frappe.db.table_exists("tabGroup Church Master"):9 frappe.rename_doc("DocType", "Group Church Master", "Group Churches")10 if frappe.db.table_exists("tabChurch Master"):11 frappe.rename_doc("DocType", "Church Master", "Churches")12 if frappe.db.table_exists("tabPCF Master"):13 frappe.rename_doc("DocType", "PCF Master", "PCFs")14 if frappe.db.table_exists("tabSenior Cell Master"):15 frappe.rename_doc("DocType", "Senior Cell Master", "Senior Cells")16 if frappe.db.table_exists("tabCell Master"):17 frappe.rename_doc("DocType", "Cell Master", "Cells")18 if frappe.db.table_exists("tabFoundation School Exam Master"):19 frappe.rename_doc("DocType", "Foundation School Exam Master", "Foundation School Exams")20 if frappe.db.table_exists("tabFS Grade Master"):21 frappe.rename_doc("DocType", "FS Grade Master", "Foundation School Grades")22 if frappe.db.table_exists("tabPartnership Arm"):...
rename_masters.py
Source:rename_masters.py
1import frappe2def execute():3 frappe.errprint("renaming master")4 if frappe.db.table_exists("tabRegion Master"):5 frappe.rename_doc("DocType", "Region Master", "Regions")6 if frappe.db.table_exists("tabZone Master"):7 frappe.rename_doc("DocType", "Zone Master", "Zones")8 if frappe.db.table_exists("tabGroup Church Master"):9 frappe.rename_doc("DocType", "Group Church Master", "Group Churches")10 if frappe.db.table_exists("tabChurch Master"):11 frappe.rename_doc("DocType", "Church Master", "Churches")12 if frappe.db.table_exists("tabPCF Master"):13 frappe.rename_doc("DocType", "PCF Master", "PCFs")14 if frappe.db.table_exists("tabSenior Cell Master"):15 frappe.rename_doc("DocType", "Senior Cell Master", "Senior Cells")16 if frappe.db.table_exists("tabCell Master"):17 frappe.rename_doc("DocType", "Cell Master", "Cells")18 if frappe.db.table_exists("tabFoundation School Exam Master"):19 frappe.rename_doc("DocType", "Foundation School Exam Master", "Foundation School Exams")20 if frappe.db.table_exists("tabFS Grade Master"):21 frappe.rename_doc("DocType", "FS Grade Master", "Foundation School Grades")22 if frappe.db.table_exists("tabPartnership Arm"):...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!