Merge pull request #27921 from barredterra/redirect-after-rename
feat: redirect to new record after rename
This commit is contained in:
commit
22a64461aa
2 changed files with 17 additions and 0 deletions
|
|
@ -229,6 +229,15 @@ def rename_doc(
|
|||
indicator="green",
|
||||
)
|
||||
|
||||
# let people watching the old form know that it has been renamed
|
||||
frappe.publish_realtime(
|
||||
event="doc_rename",
|
||||
message={"doctype": doctype, "old": old, "new": new},
|
||||
doctype=doctype,
|
||||
docname=old,
|
||||
after_commit=True,
|
||||
)
|
||||
|
||||
return new
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -333,6 +333,14 @@ frappe.ui.form.Form = class FrappeForm {
|
|||
$(document).on("rename", (ev, dt, old_name, new_name) => {
|
||||
if (dt == this.doctype) this.rename_notify(dt, old_name, new_name);
|
||||
});
|
||||
|
||||
frappe.realtime.on("doc_rename", (data) => {
|
||||
// the current form has been renamed by some backend process
|
||||
if (data.doctype == this.doctype && data.old == this.docname) {
|
||||
// the current form does not exist anymore, route to the new one
|
||||
frappe.set_route("Form", this.doctype, data.new);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setup_file_drop() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue