瀏覽代碼

Merge pull request #3975 from pratu16x7/document-get-doc-before-save

[minor] `_doc_before_save` wrapper
version-14
Rushabh Mehta 7 年之前
committed by GitHub
父節點
當前提交
4bd7f409de
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. +6
    -1
      frappe/model/document.py

+ 6
- 1
frappe/model/document.py 查看文件

@@ -328,6 +328,11 @@ class Document(BaseDocument):
and parenttype=%s and parentfield=%s""".format(df.options),
(self.name, self.doctype, fieldname))

def get_doc_before_save(self):
if not getattr(self, '_doc_before_save', None):
self._doc_before_save = frappe.get_doc(self.doctype, self.name)
return self._doc_before_save

def set_new_name(self):
"""Calls `frappe.naming.se_new_name` for parent and child docs."""
set_new_name(self)
@@ -763,7 +768,7 @@ class Document(BaseDocument):

self._doc_before_save = None
if not self.is_new() and getattr(self.meta, 'track_changes', False):
self._doc_before_save = frappe.get_doc(self.doctype, self.name)
self.get_doc_before_save()

if self.flags.ignore_validate:
return


Loading…
取消
儲存