fix: defer DocType exports until after save response
Defer standard **DocType** file export and controller generation until after the save response is sent. This allows the client form to receive the updated document payload before dev-mode file writes trigger a web reload and prevents follow-up `TimestampMismatchError` on consecutive **DocType** saves without forcing a full page reload.
This commit is contained in:
parent
e39067bfcd
commit
5876c70f86
1 changed files with 13 additions and 4 deletions
|
|
@ -550,10 +550,19 @@ class DocType(Document):
|
||||||
and (frappe.conf.developer_mode or frappe.flags.allow_doctype_export)
|
and (frappe.conf.developer_mode or frappe.flags.allow_doctype_export)
|
||||||
)
|
)
|
||||||
if allow_doctype_export:
|
if allow_doctype_export:
|
||||||
self.export_doc()
|
|
||||||
self.make_controller_template()
|
def export_doctype_files():
|
||||||
self.set_base_class_for_controller()
|
self.export_doc()
|
||||||
self.export_types_to_controller()
|
self.make_controller_template()
|
||||||
|
self.set_base_class_for_controller()
|
||||||
|
self.export_types_to_controller()
|
||||||
|
|
||||||
|
request = getattr(frappe.local, "request", None)
|
||||||
|
# Defer file writes until after the response so the client can sync the saved doc first.
|
||||||
|
if request and hasattr(request, "after_response"):
|
||||||
|
request.after_response.add(export_doctype_files)
|
||||||
|
else:
|
||||||
|
export_doctype_files()
|
||||||
|
|
||||||
# update index
|
# update index
|
||||||
if not self.custom:
|
if not self.custom:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue