From 55da1ff98adf86ed3abeb3efc4df4deeb898871f Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 17 Jul 2013 12:36:07 +0530 Subject: [PATCH] [fix] [patch] check in_list_view for Custom DocTypes --- .../p05_custom_doctypes_in_list_view.py | 21 +++++++++++++++++++ patches/patch_list.py | 1 + 2 files changed, 22 insertions(+) create mode 100644 patches/july_2013/p05_custom_doctypes_in_list_view.py diff --git a/patches/july_2013/p05_custom_doctypes_in_list_view.py b/patches/july_2013/p05_custom_doctypes_in_list_view.py new file mode 100644 index 0000000000..769e47ae3f --- /dev/null +++ b/patches/july_2013/p05_custom_doctypes_in_list_view.py @@ -0,0 +1,21 @@ +import webnotes +from webnotes.model import no_value_fields + +def execute(): + for dt in webnotes.conn.sql("""select name from `tabDocType` where custom=1"""): + dtbean = webnotes.bean("DocType", dt) + + if any((df.in_list_view for df in dtbean.doclist.get({"doctype": "DocField", "parent": dt}))): + continue + + i = 0 + for df in dtbean.doclist.get({"doctype": "DocField", "parent": dt}): + if i > 5: + break + + if df.fieldtype not in no_value_fields: + df.in_list_view = 1 + i += 1 + + if i > 0: + dtbean.save() \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index d6f4424219..70349808aa 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -252,4 +252,5 @@ patch_list = [ "patches.july_2013.p03_cost_center_company", "execute:webnotes.bean('Style Settings').save() #2013-07-16", "patches.july_2013.p04_merge_duplicate_leads", + "patches.july_2013.p05_custom_doctypes_in_list_view", ] \ No newline at end of file