From dd39d24da098fc78b80f323bc64606c3b6fe7426 Mon Sep 17 00:00:00 2001 From: priyanshshah2442 Date: Wed, 11 Jun 2025 17:47:52 +0530 Subject: [PATCH] fix: unpack non-iterable NoneType object error (cherry picked from commit 7d940faa4f80837270dbf83280e5351aee3fd31d) --- ...ncorrect_additional_discount_percentage.py | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/erpnext/patches/v15_0/unset_incorrect_additional_discount_percentage.py b/erpnext/patches/v15_0/unset_incorrect_additional_discount_percentage.py index 40be90f1396..6ea6c9399b7 100644 --- a/erpnext/patches/v15_0/unset_incorrect_additional_discount_percentage.py +++ b/erpnext/patches/v15_0/unset_incorrect_additional_discount_percentage.py @@ -12,16 +12,7 @@ from erpnext.accounts.report.calculated_discount_mismatch.calculated_discount_mi def execute(): # run this patch only if erpnext version before update is v15.64.0 or higher - version, git_branch = frappe.db.get_value( - "Installed Application", - {"app_name": "erpnext"}, - ["app_version", "git_branch"], - ) - - semantic_version = get_semantic_version(version) - if semantic_version and ( - semantic_version.major < 15 or (git_branch == "version-15" and semantic_version.minor < 64) - ): + if not should_run_patch(): return for doctype in AFFECTED_DOCTYPES: @@ -85,3 +76,24 @@ def get_semantic_version(version): return Version(version) except Exception: pass + + +def should_run_patch(): + installed_app = frappe.db.get_value( + "Installed Application", + {"app_name": "erpnext"}, + ["app_version", "git_branch"], + ) + + if not installed_app: + return True + + version, git_branch = installed_app + semantic_version = get_semantic_version(version) + if not semantic_version: + return True + + return not ( + semantic_version.major < 15 + or (git_branch == "version-15" and semantic_version.major == 15 and semantic_version.minor < 64) + )