diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py index da653cb3c50..7dd6b326fe3 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py @@ -221,6 +221,13 @@ class AccountsSettings(Document): set_allow_on_submit_for_dimension_fields(doctypes) +@frappe.whitelist(methods=["POST"]) +def get_posting_date_confirmation() -> int: + return cint( + frappe.db.get_single_value("Accounts Settings", "confirm_before_resetting_posting_date", cache=False) + ) + + def toggle_accounting_dimension_sections(hide): accounting_dimension_doctypes = frappe.get_hooks("accounting_dimension_doctypes") for doctype in accounting_dimension_doctypes: diff --git a/erpnext/accounts/doctype/accounts_settings/test_accounts_settings.py b/erpnext/accounts/doctype/accounts_settings/test_accounts_settings.py index d57bd1cc009..f6b4646b330 100644 --- a/erpnext/accounts/doctype/accounts_settings/test_accounts_settings.py +++ b/erpnext/accounts/doctype/accounts_settings/test_accounts_settings.py @@ -2,10 +2,16 @@ import unittest import frappe +from erpnext.accounts.doctype.accounts_settings.accounts_settings import get_posting_date_confirmation from erpnext.tests.utils import ERPNextTestSuite class TestAccountsSettings(ERPNextTestSuite): + def test_posting_date_confirmation_uses_current_setting(self): + for enabled in (0, 1, 0): + frappe.db.set_single_value("Accounts Settings", "confirm_before_resetting_posting_date", enabled) + self.assertEqual(get_posting_date_confirmation(), enabled) + def test_stale_days(self): cur_settings = frappe.get_doc("Accounts Settings", "Accounts Settings") cur_settings.allow_stale = 0 diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index ed28731154d..f8a78e0551a 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1132,7 +1132,10 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe if (this.frm.doc.set_posting_time) return; if (frappe.datetime.get_today() == this.frm.doc.posting_date) return; - if (!frappe.boot.sysdefaults.confirm_before_resetting_posting_date) return; + const is_confirmation_reqd = await frappe.xcall( + "erpnext.accounts.doctype.accounts_settings.accounts_settings.get_posting_date_confirmation" + ); + if (!is_confirmation_reqd) return; return new Promise((resolve, reject) => { frappe.confirm( diff --git a/erpnext/startup/boot.py b/erpnext/startup/boot.py index 0f7bb991f99..ca9fbfc3884 100644 --- a/erpnext/startup/boot.py +++ b/erpnext/startup/boot.py @@ -27,9 +27,6 @@ def boot_session(bootinfo): bootinfo.sysdefaults.disable_include_dimensions = cint( frappe.get_single_value("Accounts Settings", "disable_include_dimensions") ) - bootinfo.sysdefaults.confirm_before_resetting_posting_date = cint( - frappe.get_single_value("Accounts Settings", "confirm_before_resetting_posting_date") - ) bootinfo.sysdefaults.quotation_valid_till = cint( frappe.db.get_single_value("CRM Settings", "default_valid_till")