diff --git a/erpnext/accounts/doctype/bank_statement_import/bank_statement_import.py b/erpnext/accounts/doctype/bank_statement_import/bank_statement_import.py index 2c74f812e0e..51b5e26f330 100644 --- a/erpnext/accounts/doctype/bank_statement_import/bank_statement_import.py +++ b/erpnext/accounts/doctype/bank_statement_import/bank_statement_import.py @@ -331,7 +331,7 @@ def add_bank_account(data, bank_account): bank_account_loc = loc for row in data[1:]: - if bank_account_loc: + if bank_account_loc is not None: row[bank_account_loc] = bank_account else: row.append(bank_account) diff --git a/erpnext/accounts/doctype/bank_transaction_rule/bank_transaction_rule.py b/erpnext/accounts/doctype/bank_transaction_rule/bank_transaction_rule.py index aa311483eae..ddbc39c5c9a 100644 --- a/erpnext/accounts/doctype/bank_transaction_rule/bank_transaction_rule.py +++ b/erpnext/accounts/doctype/bank_transaction_rule/bank_transaction_rule.py @@ -157,12 +157,9 @@ class BankTransactionRule(Document): """ Delete the matched rule from the bank transaction """ - try: - frappe.db.set_value( - "Bank Transaction", {"matched_transaction_rule": self.name}, "matched_transaction_rule", None - ) - except Exception: - pass + frappe.db.set_value( + "Bank Transaction", {"matched_transaction_rule": self.name}, "matched_transaction_rule", None + ) def after_delete(self): """ diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py index f8c3113a714..a957e246553 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.py +++ b/erpnext/accounts/doctype/payment_request/payment_request.py @@ -459,6 +459,11 @@ class PaymentRequest(Document): else: return True except Exception: + frappe.log_error( + title=f"Payment Gateway validation failed: {self.payment_gateway}", + reference_doctype=self.doctype, + reference_name=self.name, + ) return False def set_payment_request_url(self): diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py index f67a3861826..16340362c85 100644 --- a/erpnext/accounts/doctype/pricing_rule/utils.py +++ b/erpnext/accounts/doctype/pricing_rule/utils.py @@ -89,7 +89,11 @@ def filter_pricing_rule_based_on_condition(pricing_rules, doc=None): if frappe.safe_eval(pricing_rule.condition, None, doc.as_dict()): filtered_pricing_rules.append(pricing_rule) except Exception: - pass + frappe.log_error( + title=f"Pricing Rule condition failed to evaluate: {pricing_rule.name}", + reference_doctype="Pricing Rule", + reference_name=pricing_rule.name, + ) else: filtered_pricing_rules.append(pricing_rule) else: diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py index dff423b36b4..510da22ada1 100644 --- a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py +++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py @@ -403,12 +403,7 @@ def get_recipients_and_cc(customer, doc): if doc.primary_mandatory and clist.primary_email: for email in clist.primary_email.split(","): recipients.append(email.strip()) - cc = [] - if doc.cc_to != "": - try: - cc = [frappe.get_value("User", user.cc, "email") for user in doc.cc_to] - except Exception: - pass + cc = [email for user in doc.cc_to if (email := frappe.get_value("User", user.cc, "email"))] return recipients, cc diff --git a/erpnext/buying/doctype/request_for_quotation/mapper.py b/erpnext/buying/doctype/request_for_quotation/mapper.py index 71015e16058..643f4824fe7 100644 --- a/erpnext/buying/doctype/request_for_quotation/mapper.py +++ b/erpnext/buying/doctype/request_for_quotation/mapper.py @@ -64,27 +64,24 @@ def create_supplier_quotation(doc: str | Document | dict): ): frappe.throw(_("Not Permitted"), frappe.PermissionError) - try: - sq_doc = frappe.get_doc( - { - "doctype": "Supplier Quotation", - "supplier": doc.get("supplier"), - "terms": doc.get("terms"), - "company": doc.get("company"), - "currency": doc.get("currency") - or get_party_account_currency("Supplier", doc.get("supplier"), doc.get("company")), - "buying_price_list": doc.get("buying_price_list") - or frappe.db.get_single_value("Buying Settings", "buying_price_list"), - } - ) - add_items(sq_doc, doc.get("supplier"), doc.get("items")) - sq_doc.flags.ignore_permissions = True - sq_doc.run_method("set_missing_values") - sq_doc.save() - frappe.msgprint(_("Supplier Quotation {0} Created").format(sq_doc.name)) - return sq_doc.name - except Exception: - return None + sq_doc = frappe.get_doc( + { + "doctype": "Supplier Quotation", + "supplier": doc.get("supplier"), + "terms": doc.get("terms"), + "company": doc.get("company"), + "currency": doc.get("currency") + or get_party_account_currency("Supplier", doc.get("supplier"), doc.get("company")), + "buying_price_list": doc.get("buying_price_list") + or frappe.db.get_single_value("Buying Settings", "buying_price_list"), + } + ) + add_items(sq_doc, doc.get("supplier"), doc.get("items")) + sq_doc.flags.ignore_permissions = True + sq_doc.run_method("set_missing_values") + sq_doc.save() + frappe.msgprint(_("Supplier Quotation {0} Created").format(sq_doc.name)) + return sq_doc.name def add_items(sq_doc, supplier, items):