Move related property setters to custom field property

This commit is contained in:
Nabin Hait 2014-01-10 16:28:41 +05:30
parent f3ded044e0
commit 03463ef73b
3 changed files with 36 additions and 0 deletions

0
patches/1401/__init__.py Normal file
View File

View File

@ -0,0 +1,35 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
import webnotes
from webnotes.model.meta import get_field
def execute():
webnotes.reload_doc("core", "doctype", "custom_field")
custom_fields = {}
for cf in webnotes.conn.sql("""select dt, fieldname from `tabCustom Field`""", as_dict=1):
custom_fields.setdefault(cf.dt, []).append(cf.fieldname)
delete_list = []
for ps in webnotes.conn.sql("""select * from `tabProperty Setter`""", as_dict=1):
if ps.field_name in custom_fields.get(ps.doc_type, []):
if ps.property == "previous_field":
property_name = "insert_after"
field_meta = get_field(ps.doc_type, ps.value)
property_value = field_meta.label if field_meta else ""
else:
property_name = ps.property
property_value =ps.value
webnotes.conn.sql("""update `tabCustom Field`
set %s=%s where dt=%s and fieldname=%s""" % (property_name, '%s', '%s', '%s'),
(property_value, ps.doc_type, ps.field_name))
delete_list.append(ps.name)
if delete_list:
webnotes.conn.sql("""delete from `tabProperty Setter` where name in (%s)""" %
', '.join(['%s']*len(delete_list)), tuple(delete_list))

View File

@ -263,4 +263,5 @@ patch_list = [
"patches.1311.p08_email_digest_recipients",
"execute:webnotes.delete_doc('DocType', 'Warehouse Type')",
"patches.1312.p02_update_item_details_in_item_price",
"patches.1401.p01_move_related_property_setters_to_custom_field",
]