From 82a85818c2ff39354405245da2e82896853ca6b2 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) # Conflicts: # erpnext/accounts/doctype/accounts_settings/accounts_settings.json (cherry picked from commit c97be8abe1b6ca1115130776b52065d6eddf914c) --- .../accounts_settings/accounts_settings.json | 16 ++++++++++++++++ .../process_period_closing_voucher.py | 10 +++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index 18a0a86fd52..bfde962fe62 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -79,6 +79,7 @@ "acc_frozen_upto", "ignore_account_closing_balance", "use_legacy_controller_for_pcv", + "pcv_job_timeout", "column_break_25", "frozen_accounts_modifier", "tab_break_dpet", @@ -635,6 +636,7 @@ "label": "Use Legacy Controller For Period Closing Voucher" }, { +<<<<<<< HEAD "fieldname": "payment_entry_settings", "fieldtype": "Section Break", "label": "Payment Entry Settings" @@ -650,6 +652,20 @@ "fieldname": "show_party_balance", "fieldtype": "Check", "label": "Show Party Balance" +======= + "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", + "fieldtype": "Link", + "label": "Role to Notify on Depreciation Failure", + "options": "Role" +>>>>>>> 13b6c4a165 (feat(accounts): add configurable job timeout for Process Period Closing Voucher) }, { "default": "30, 60, 90, 120", 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 e6a330a4d14..096b085cf0e 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 @@ -92,6 +92,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) @@ -118,7 +120,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, @@ -244,6 +246,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) @@ -269,7 +273,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, @@ -299,7 +303,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 c6c4815e8d0ddcd645e8137fe55253f63021b8a1 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 (cherry picked from commit c33d7e5d7be12f103ccae69354ab75d309af3d2d) --- .../doctype/accounts_settings/accounts_settings.json | 5 +++++ .../doctype/accounts_settings/accounts_settings.py | 5 +++++ erpnext/patches.txt | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index bfde962fe62..6dd3c5fcc6e 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -654,6 +654,7 @@ "label": "Show Party Balance" ======= "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", @@ -679,7 +680,11 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], +<<<<<<< HEAD "modified": "2026-05-18 12:16:33.679345", +======= + "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 5cd4955cdd7..69e3dde73af 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py @@ -59,7 +59,12 @@ class AccountsSettings(Document): make_payment_via_journal_entry: DF.Check merge_similar_account_heads: DF.Check over_billing_allowance: DF.Currency +<<<<<<< HEAD post_change_gl_entries: DF.Check +======= + 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 3b0ac5cf552..fb3279255e2 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -435,5 +435,15 @@ erpnext.patches.v16_0.update_order_qty_and_requested_qty_based_on_mr_and_po erpnext.patches.v16_0.depends_on_inv_dimensions erpnext.patches.v16_0.clear_procedures_from_receivable_report erpnext.patches.v16_0.migrate_address_contact_custom_fields +<<<<<<< HEAD erpnext.patches.v15_0.set_main_item_code_in_material_request_plan_item erpnext.patches.v16_0.set_posting_datetime_for_sabb_and_drop_indexes +======= +erpnext.patches.v16_0.rename_secondary_item_type_field +erpnext.patches.v16_0.submit_existing_product_bundles #1 +erpnext.patches.v16_0.migrate_subscription_generate_invoice_at +erpnext.patches.v16_0.rename_subscription_billing_period_fields +erpnext.patches.v16_0.drop_redundant_serial_no_index_from_sabb +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 2980171007161095b2fa4a0f163eb41d8b06e542 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 24 Jun 2026 15:05:41 +0530 Subject: [PATCH 3/3] chore: resolve conflicts (cherry picked from commit df3c821f98045f9ac038b1bafbd35113949db783) --- .../accounts_settings/accounts_settings.json | 16 ++-------------- .../accounts_settings/accounts_settings.py | 4 ---- erpnext/patches.txt | 9 --------- 3 files changed, 2 insertions(+), 27 deletions(-) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index 6dd3c5fcc6e..62b6d5c0b6a 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -636,7 +636,6 @@ "label": "Use Legacy Controller For Period Closing Voucher" }, { -<<<<<<< HEAD "fieldname": "payment_entry_settings", "fieldtype": "Section Break", "label": "Payment Entry Settings" @@ -652,7 +651,8 @@ "fieldname": "show_party_balance", "fieldtype": "Check", "label": "Show Party Balance" -======= + }, + { "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", @@ -660,14 +660,6 @@ "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", - "fieldtype": "Link", - "label": "Role to Notify on Depreciation Failure", - "options": "Role" ->>>>>>> 13b6c4a165 (feat(accounts): add configurable job timeout for Process Period Closing Voucher) - }, { "default": "30, 60, 90, 120", "fieldname": "default_ageing_range", @@ -680,11 +672,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], -<<<<<<< HEAD - "modified": "2026-05-18 12:16:33.679345", -======= "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 69e3dde73af..83ece261895 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py @@ -59,12 +59,8 @@ class AccountsSettings(Document): make_payment_via_journal_entry: DF.Check merge_similar_account_heads: DF.Check over_billing_allowance: DF.Currency -<<<<<<< HEAD post_change_gl_entries: DF.Check -======= 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 fb3279255e2..b48f16a7550 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -435,15 +435,6 @@ erpnext.patches.v16_0.update_order_qty_and_requested_qty_based_on_mr_and_po erpnext.patches.v16_0.depends_on_inv_dimensions erpnext.patches.v16_0.clear_procedures_from_receivable_report erpnext.patches.v16_0.migrate_address_contact_custom_fields -<<<<<<< HEAD erpnext.patches.v15_0.set_main_item_code_in_material_request_plan_item erpnext.patches.v16_0.set_posting_datetime_for_sabb_and_drop_indexes -======= -erpnext.patches.v16_0.rename_secondary_item_type_field -erpnext.patches.v16_0.submit_existing_product_bundles #1 -erpnext.patches.v16_0.migrate_subscription_generate_invoice_at -erpnext.patches.v16_0.rename_subscription_billing_period_fields -erpnext.patches.v16_0.drop_redundant_serial_no_index_from_sabb -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)