瀏覽代碼

Merge pull request #2758 from mbauskar/custom-field-fix

[fixes] update db schema while updating the customizations
version-14
Nabin Hait 8 年之前
committed by GitHub
父節點
當前提交
89673b17f0
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. +6
    -0
      frappe/modules/utils.py

+ 6
- 0
frappe/modules/utils.py 查看文件

@@ -101,6 +101,7 @@ def sync_customizations_for_doctype(data):
from frappe.core.doctype.doctype.doctype import validate_fields_for_doctype

doctype = data['doctype']
update_schema = False

def sync(key, custom_doctype, doctype_fieldname):
frappe.db.sql('delete from `tab{0}` where `{1}`=%s'.format(custom_doctype, doctype_fieldname),
@@ -113,6 +114,7 @@ def sync_customizations_for_doctype(data):

if data['custom_fields']:
sync('custom_fields', 'Custom Field', 'dt')
update_schema = True

if data['property_setters']:
sync('property_setters', 'Property Setter', 'doc_type')
@@ -123,6 +125,10 @@ def sync_customizations_for_doctype(data):
print 'Updating customizations for {0}'.format(doctype)
validate_fields_for_doctype(doctype)

if update_schema and not frappe.db.get_value('DocType', doctype, 'issingle'):
from frappe.model.db_schema import updatedb
updatedb(doctype)

def scrub(txt):
return frappe.scrub(txt)



Loading…
取消
儲存