feat: validate amended from record docstatus
This commit is contained in:
parent
0dcc6280e8
commit
35d8ff40ec
1 changed files with 8 additions and 0 deletions
|
|
@ -392,6 +392,7 @@ class Document(BaseDocument, DocRef):
|
|||
self.flags.in_insert = True
|
||||
|
||||
if self.get("amended_from"):
|
||||
self.validate_amended_from()
|
||||
self.copy_attachments_from_amended_from()
|
||||
|
||||
relink_mismatched_files(self)
|
||||
|
|
@ -480,6 +481,13 @@ class Document(BaseDocument, DocRef):
|
|||
|
||||
return self
|
||||
|
||||
def validate_amended_from(self):
|
||||
if frappe.db.get_value(self.doctype, self.get("amended_from"), "docstatus") != 2:
|
||||
message = _(
|
||||
"{0} cannot be amended because it is not cancelled. Please cancel the document before creating an amendment."
|
||||
).format(frappe.utils.get_link_to_form(self.doctype, self.get("amended_from")))
|
||||
frappe.throw(message, title=_("Amendment Not Allowed"))
|
||||
|
||||
def copy_attachments_from_amended_from(self):
|
||||
"""Copy attachments from `amended_from`"""
|
||||
from frappe.desk.form.load import get_attachments
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue