fix: add patch for List View Settings Rename

This commit is contained in:
hasnain2808@gmail.com 2021-01-21 13:10:06 +05:30
parent aead9aef26
commit 619a4adfd5
2 changed files with 22 additions and 0 deletions

View file

@ -318,3 +318,4 @@ frappe.patches.v13_0.remove_custom_link
execute:frappe.delete_doc("DocType", "Footer Item")
frappe.patches.v13_0.replace_field_target_with_open_in_new_tab
frappe.patches.v13_0.delete_package_publish_tool
frappe.patches.v13_0.rename_list_view_setting_to_list_view_settings

View file

@ -0,0 +1,21 @@
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
if frappe.db.table_exists('List View Setting'):
existing_list_view_settings = frappe.get_all('List View Settings', as_list=True)
for list_view_setting in frappe.get_all('List View Setting', fields = ['disable_count', 'disable_sidebar_stats', 'disable_auto_refresh', 'name']):
name = list_view_setting.pop('name')
if name not in [x[0] for x in existing_list_view_settings]:
list_view_setting['doctype'] = 'List View Settings'
list_view_settings = frappe.get_doc(list_view_setting)
# setting name here is necessary because autoname is set as prompt
list_view_settings.name = name
list_view_settings.insert()
frappe.delete_doc("DocType", "List View Setting", force=True)
frappe.db.commit()
frappe.db.sql("DROP TABLE IF EXISTS `tabList View Setting`")