From d389014e579a743f80a7388590c12cc2d76602b6 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 24 Jun 2026 12:57:31 +0530 Subject: [PATCH 1/3] feat(accounts): add configurable job timeout for Process Period Closing Voucher Adds a `pcv_job_timeout` Int field (default 3600s) to Accounts Settings so admins can tune the enqueue timeout for PCV background jobs without a code change. All three `frappe.enqueue` calls in `process_period_closing_voucher.py` now read this value at runtime. Co-Authored-By: Claude Sonnet 4.6 (cherry picked from commit 13b6c4a165db29d95d05cdcd01d79cdeaca0accc) --- .../doctype/accounts_settings/accounts_settings.json | 8 ++++++++ .../process_period_closing_voucher.py | 10 +++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index 57e3c090488..cf847de2187 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -86,6 +86,7 @@ "period_closing_settings_section", "ignore_account_closing_balance", "use_legacy_controller_for_pcv", + "pcv_job_timeout", "column_break_25", "reports_tab", "remarks_section", @@ -611,6 +612,13 @@ "fieldtype": "Check", "label": "Use legacy controller for Period Closing Voucher" }, + { + "default": "3600", + "description": "Timeout (in seconds) for each background job enqueued by Process Period Closing Voucher", + "fieldname": "pcv_job_timeout", + "fieldtype": "Int", + "label": "PCV Job Timeout (seconds)" + }, { "description": "Users with this role will be notified if the asset depreciation gets failed", "fieldname": "role_to_notify_on_depreciation_failure", diff --git a/erpnext/accounts/doctype/process_period_closing_voucher/process_period_closing_voucher.py b/erpnext/accounts/doctype/process_period_closing_voucher/process_period_closing_voucher.py index bd8b2fd1db0..d5e10be7fdd 100644 --- a/erpnext/accounts/doctype/process_period_closing_voucher/process_period_closing_voucher.py +++ b/erpnext/accounts/doctype/process_period_closing_voucher/process_period_closing_voucher.py @@ -95,6 +95,8 @@ def start_pcv_processing(docname: str): frappe.has_permission("Process Payment Reconciliation", "write", doc=docname, throw=True) frappe.db.set_value("Process Period Closing Voucher", docname, "status", "Running") + timeout = frappe.db.get_single_value("Accounts Settings", "pcv_job_timeout") or 3600 + ppcvd = qb.DocType("Process Period Closing Voucher Detail") if normal_balances := ( qb.from_(ppcvd) @@ -121,7 +123,7 @@ def start_pcv_processing(docname: str): frappe.enqueue( method="erpnext.accounts.doctype.process_period_closing_voucher.process_period_closing_voucher.process_individual_date", queue="long", - timeout="3600", + timeout=timeout, is_async=True, enqueue_after_commit=True, docname=docname, @@ -247,6 +249,8 @@ def get_gle_for_closing_account(pcv, dimension_balance, dimensions): @frappe.whitelist() def schedule_next_date(docname: str): + timeout = frappe.db.get_single_value("Accounts Settings", "pcv_job_timeout") or 3600 + ppcvd = qb.DocType("Process Period Closing Voucher Detail") if to_process := ( qb.from_(ppcvd) @@ -272,7 +276,7 @@ def schedule_next_date(docname: str): frappe.enqueue( method="erpnext.accounts.doctype.process_period_closing_voucher.process_period_closing_voucher.process_individual_date", queue="long", - timeout="3600", + timeout=timeout, is_async=True, enqueue_after_commit=True, docname=docname, @@ -302,7 +306,7 @@ def schedule_next_date(docname: str): frappe.enqueue( method="erpnext.accounts.doctype.process_period_closing_voucher.process_period_closing_voucher.summarize_and_post_ledger_entries", queue="long", - timeout="3600", + timeout=timeout, is_async=True, job_name=job_name, enqueue_after_commit=True, From 66b28cf45623548623a395b600e7e35df8c41f9e Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 24 Jun 2026 13:01:42 +0530 Subject: [PATCH 2/3] refactor: patch, display depends on and json changes (cherry picked from commit 3da7eefebb37bb1f1e6cc4c7c0c2add735e0e2c5) # Conflicts: # erpnext/accounts/doctype/accounts_settings/accounts_settings.json # erpnext/accounts/doctype/accounts_settings/accounts_settings.py # erpnext/patches.txt --- .../doctype/accounts_settings/accounts_settings.json | 5 +++++ .../accounts/doctype/accounts_settings/accounts_settings.py | 5 +++++ erpnext/patches.txt | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index cf847de2187..768c254c7f6 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -614,6 +614,7 @@ }, { "default": "3600", + "depends_on": "eval: !doc.use_legacy_controller_for_pcv", "description": "Timeout (in seconds) for each background job enqueued by Process Period Closing Voucher", "fieldname": "pcv_job_timeout", "fieldtype": "Int", @@ -756,7 +757,11 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], +<<<<<<< HEAD "modified": "2026-06-15 18:26:50.778723", +======= + "modified": "2026-06-24 12:59:41.868865", +>>>>>>> 3da7eefebb (refactor: patch, display depends on and json changes) "modified_by": "Administrator", "module": "Accounts", "name": "Accounts Settings", diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py index 716bd8a0719..9b4c16848b8 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py @@ -90,6 +90,11 @@ class AccountsSettings(Document): make_payment_via_journal_entry: DF.Check merge_similar_account_heads: DF.Check over_billing_allowance: DF.Currency +<<<<<<< HEAD +======= + pcv_job_timeout: DF.Int + preview_mode: DF.Check +>>>>>>> 3da7eefebb (refactor: patch, display depends on and json changes) receivable_payable_fetch_method: DF.Literal["Buffered Cursor", "UnBuffered Cursor"] receivable_payable_remarks_length: DF.Int reconciliation_queue_size: DF.Int diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 4f129c918f0..f28ca0faf6b 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -484,3 +484,8 @@ erpnext.patches.v16_0.set_not_applicable_on_german_item_tax_templates erpnext.patches.v16_0.clear_procedures_from_receivable_report erpnext.patches.v16_0.migrate_address_contact_custom_fields erpnext.patches.v16_0.drop_redundant_serial_no_index_from_sabb +<<<<<<< HEAD +======= +erpnext.patches.v16_0.set_default_close_opportunity_after_days +execute:frappe.db.set_single_value("Accounts Settings", "pcv_job_timeout", 3600) +>>>>>>> 3da7eefebb (refactor: patch, display depends on and json changes) From 267086153b052dac996eeff2e258b15383797f32 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 24 Jun 2026 15:08:04 +0530 Subject: [PATCH 3/3] chore: resolve conflicts --- .../accounts/doctype/accounts_settings/accounts_settings.json | 4 ---- .../accounts/doctype/accounts_settings/accounts_settings.py | 4 ---- erpnext/patches.txt | 4 ---- 3 files changed, 12 deletions(-) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index 768c254c7f6..9381ad2ff18 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -757,11 +757,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], -<<<<<<< HEAD - "modified": "2026-06-15 18:26:50.778723", -======= "modified": "2026-06-24 12:59:41.868865", ->>>>>>> 3da7eefebb (refactor: patch, display depends on and json changes) "modified_by": "Administrator", "module": "Accounts", "name": "Accounts Settings", diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py index 9b4c16848b8..e76281687ab 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py @@ -90,11 +90,7 @@ class AccountsSettings(Document): make_payment_via_journal_entry: DF.Check merge_similar_account_heads: DF.Check over_billing_allowance: DF.Currency -<<<<<<< HEAD -======= pcv_job_timeout: DF.Int - preview_mode: DF.Check ->>>>>>> 3da7eefebb (refactor: patch, display depends on and json changes) receivable_payable_fetch_method: DF.Literal["Buffered Cursor", "UnBuffered Cursor"] receivable_payable_remarks_length: DF.Int reconciliation_queue_size: DF.Int diff --git a/erpnext/patches.txt b/erpnext/patches.txt index f28ca0faf6b..5bd41a2fece 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -484,8 +484,4 @@ erpnext.patches.v16_0.set_not_applicable_on_german_item_tax_templates erpnext.patches.v16_0.clear_procedures_from_receivable_report erpnext.patches.v16_0.migrate_address_contact_custom_fields erpnext.patches.v16_0.drop_redundant_serial_no_index_from_sabb -<<<<<<< HEAD -======= -erpnext.patches.v16_0.set_default_close_opportunity_after_days execute:frappe.db.set_single_value("Accounts Settings", "pcv_job_timeout", 3600) ->>>>>>> 3da7eefebb (refactor: patch, display depends on and json changes)