From 2ae3bd9fedbde89496e2e438b94e68da80c4db86 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 21 Jul 2022 13:54:40 +0530 Subject: [PATCH] fix: ensure defaults removed in bad frappe patch get set again (backport #31659) fix: ensure defaults removed in bad frappe patch get set again (#31659) (cherry picked from commit bf2833b8ee094497dd7d20bd3b2577c7fedb37c9) (cherry picked from commit 9071018e4ea195a24898ec29491337f91060cd13) Co-authored-by: Sagar Vora --- erpnext/patches.txt | 1 + .../patches/v13_0/reset_corrupt_defaults.py | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 erpnext/patches/v13_0/reset_corrupt_defaults.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 8e8e2b25299..15f50a791c7 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -370,3 +370,4 @@ erpnext.patches.v13_0.job_card_status_on_hold erpnext.patches.v13_0.add_cost_center_in_loans erpnext.patches.v13_0.show_india_localisation_deprecation_warning erpnext.patches.v13_0.fix_number_and_frequency_for_monthly_depreciation +erpnext.patches.v13_0.reset_corrupt_defaults diff --git a/erpnext/patches/v13_0/reset_corrupt_defaults.py b/erpnext/patches/v13_0/reset_corrupt_defaults.py new file mode 100644 index 00000000000..7a6d50f19d6 --- /dev/null +++ b/erpnext/patches/v13_0/reset_corrupt_defaults.py @@ -0,0 +1,29 @@ +import frappe + + +def execute(): + """ + This patch is needed to fix parent incorrectly set as `__2fa` because of + https://github.com/frappe/frappe/commit/a822092211533ff17ff9b92dd86f6f868ed63e2e + """ + + for doctype in ( + "Accounts Settings", + "Stock Settings", + "Selling Settings", + "Buying Settings", + "CRM Settings", + "Global Defaults", + "Healthcare Settings", + "Education Settings", + ): + try: + frappe.get_single(doctype).save() + except Exception: + pass + + try: + pos_profile = frappe.get_last_doc("POS Profile") + pos_profile.set_defaults() + except Exception: + pass