refactor: no copy on summary table and more validations

This commit is contained in:
ruthra kumar
2024-02-05 10:42:59 +05:30
parent 2dbe68a09d
commit 55e93b3fe1
2 changed files with 12 additions and 5 deletions

View File

@@ -34,6 +34,7 @@
"fieldname": "doctypes",
"fieldtype": "Table",
"label": "Summary",
"no_copy": 1,
"options": "Transaction Deletion Record Details",
"read_only": 1
},
@@ -126,7 +127,7 @@
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2024-02-05 10:25:28.462255",
"modified": "2024-02-05 10:36:34.229864",
"modified_by": "Administrator",
"module": "Setup",
"name": "Transaction Deletion Record",

View File

@@ -6,7 +6,7 @@ import frappe
from frappe import _, qb
from frappe.desk.notifications import clear_notifications
from frappe.model.document import Document
from frappe.utils import cint, create_batch, get_link_to_form
from frappe.utils import cint, comma_and, create_batch, get_link_to_form
class TransactionDeletionRecord(Document):
@@ -59,11 +59,16 @@ class TransactionDeletionRecord(Document):
def before_submit(self):
if queued_docs := frappe.db.get_all(
"Transaction Deletion Record", filters={"company": self.company, "status": "Queued"}
"Transaction Deletion Record",
filters={"company": self.company, "status": ("in", ["Running", "Queued"]), "docstatus": 1},
pluck="name",
):
frappe.throw(
_("There is another document: {0} Queued. Cannot queue multi docs for one company.").format(
self.queued_docs
_(
"Cannot queue multi docs for one company. {0} is already queued/running for company: {1}"
).format(
comma_and([get_link_to_form("Transaction Deletion Record", x) for x in queued_docs]),
frappe.bold(self.company),
)
)
@@ -80,6 +85,7 @@ class TransactionDeletionRecord(Document):
def before_save(self):
self.status = ""
self.doctypes.clear()
self.reset_task_flags()
def on_submit(self):