diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 7c287d38cb..a2d0eb2698 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -254,7 +254,10 @@ Cypress.Commands.add("awesomebar", (text) => { Cypress.Commands.add("new_form", (doctype) => { let dt_in_route = doctype.toLowerCase().replace(/ /g, "-"); cy.visit(`/app/${dt_in_route}/new`); - cy.get("body").should("have.attr", "data-route", `Form/${doctype}/new-${dt_in_route}-1`); + cy.get("body").should(($body) => { + const dataRoute = $body.attr("data-route"); + expect(dataRoute).to.match(new RegExp(`^Form/${doctype}/new-${dt_in_route}-`)); + }); cy.get("body").should("have.attr", "data-ajax-state", "complete"); }); diff --git a/frappe/desk/form/save.py b/frappe/desk/form/save.py index e3ef2ba70b..795a7deeb9 100644 --- a/frappe/desk/form/save.py +++ b/frappe/desk/form/save.py @@ -17,9 +17,7 @@ def savedocs(doc, action): """save / submit / update doclist""" doc = frappe.get_doc(json.loads(doc)) capture_doc(doc, action) - if doc.doctype not in ["DocType", "File"] and doc.name.startswith( - "new-" + doc.doctype.lower().replace(" ", "-") - ): + if doc.get("__islocal") and doc.name.startswith("new-" + doc.doctype.lower().replace(" ", "-")): # required to relink missing attachments if they exist. doc.__temporary_name = doc.name set_local_name(doc)