From 132fecf3002b0fad4485ff906ce6f5adbf79473a Mon Sep 17 00:00:00 2001 From: Sanket322 Date: Fri, 13 Dec 2024 17:44:44 +0530 Subject: [PATCH] fix: show error message instead of throw --- india_compliance/gst_india/utils/__init__.py | 24 +++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/india_compliance/gst_india/utils/__init__.py b/india_compliance/gst_india/utils/__init__.py index ae838bbad..44e7b7119 100644 --- a/india_compliance/gst_india/utils/__init__.py +++ b/india_compliance/gst_india/utils/__init__.py @@ -940,22 +940,24 @@ def validate_invoice_number(doc, throw=True): if not throw: return is_valid_length and is_valid_format + title = _("Invalid GST Transaction Name") + if not is_valid_length: - frappe.throw( - _( - "Transaction Name must be 16 characters or fewer to meet GST requirements" - ), - title=_("Invalid GST Transaction Name"), + message = _( + "Transaction Name must be 16 characters or fewer to meet GST requirements" ) + if doc.doctype == "Purchase Invoice": + frappe.msgprint(message, title=title) + return + + frappe.throw(message, title=title) if not is_valid_format: - frappe.throw( - _( - "Transaction Name should start with an alphanumeric character and can" - " only contain alphanumeric characters, dash (-) and slash (/) to meet GST requirements" - ), - title=_("Invalid GST Transaction Name"), + message = _( + "Transaction Name should start with an alphanumeric character and can" + " only contain alphanumeric characters, dash (-) and slash (/) to meet GST requirements" ) + frappe.throw(message, title=title) def handle_server_errors(settings, doc, document_type, error):