From 906a4bd398f229d677f23674ac5c70998dc91a84 Mon Sep 17 00:00:00 2001 From: khushi8112 Date: Mon, 6 Oct 2025 17:24:52 +0530 Subject: [PATCH] feat(patch): set total budget amount on budget doctype --- erpnext/patches.txt | 2 +- erpnext/patches/v16_0/set_total_budget_amount.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 erpnext/patches/v16_0/set_total_budget_amount.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 51d4f66b9bb..a894f8cb44a 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -448,4 +448,4 @@ erpnext.patches.v16_0.update_serial_batch_entries erpnext.patches.v16_0.set_company_wise_warehouses erpnext.patches.v16_0.set_valuation_method_on_companies erpnext.patches.v15_0.migrate_old_item_wise_tax_detail_data_to_table - +erpnext.patches.v16_0.set_total_budget_amount diff --git a/erpnext/patches/v16_0/set_total_budget_amount.py b/erpnext/patches/v16_0/set_total_budget_amount.py new file mode 100644 index 00000000000..163f0f17274 --- /dev/null +++ b/erpnext/patches/v16_0/set_total_budget_amount.py @@ -0,0 +1,16 @@ +import frappe + + +def execute(): + if frappe.db.has_column("Budget", "total_budget_amount"): + frappe.db.sql( + """ + UPDATE `tabBudget` b + SET b.total_budget_amount = ( + SELECT SUM(ba.budget_amount) + FROM `tabBudget Account` ba + WHERE ba.parent = b.name + ) + WHERE IFNULL(b.total_budget_amount, 0) = 0 + """ + )