소스 검색

Merge pull request #2349 from rohitwaghchaure/rename_autoname_field

[Fix] Rename autoname field on rename of docname
version-14
Nabin Hait 8 년 전
committed by GitHub
부모
커밋
262920288e
1개의 변경된 파일9개의 추가작업 그리고 0개의 파일을 삭제
  1. +9
    -0
      frappe/model/rename_doc.py

+ 9
- 0
frappe/model/rename_doc.py 파일 보기

@@ -85,8 +85,17 @@ def rename_parent_and_child(doctype, old, new, meta):
# rename the doc
frappe.db.sql("update `tab%s` set name=%s where name=%s" % (frappe.db.escape(doctype), '%s', '%s'),
(new, old))
update_autoname_field(doctype, new, meta)
update_child_docs(old, new, meta)

def update_autoname_field(doctype, new, meta):
# update the value of the autoname field on rename of the docname
if meta.get('autoname'):
field = meta.get('autoname').split(':')
if field and field[0] == "field":
frappe.db.sql("update `tab%s` set %s=%s where name=%s" % (frappe.db.escape(doctype), field[1], '%s', '%s'),
(new, new))

def validate_rename(doctype, new, meta, merge, force, ignore_permissions):
# using for update so that it gets locked and someone else cannot edit it while this rename is going on!
exists = frappe.db.sql("select name from `tab{doctype}` where name=%s for update".format(doctype=frappe.db.escape(doctype)), new)


불러오는 중...
취소
저장