fix: refresh posting date confirmation setting

This commit is contained in:
khushi8112
2026-09-09 12:36:28 +05:30
parent db9e93306a
commit bcade8f0ba
4 changed files with 17 additions and 4 deletions

View File

@@ -222,6 +222,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:

View File

@@ -1,9 +1,15 @@
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

View File

@@ -1150,7 +1150,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(

View File

@@ -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")