From 8e2221178b00f8f148ad38bb90a6928ade9bdc23 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Fri, 23 May 2025 14:24:50 +0530 Subject: [PATCH] refactor: patch old contract with full party name --- erpnext/patches.txt | 1 + .../patches/v14_0/update_full_name_in_contract.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 erpnext/patches/v14_0/update_full_name_in_contract.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 143ec05455d..3f27e4ce26a 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -415,3 +415,4 @@ erpnext.patches.v15_0.set_grand_total_to_default_mop execute:frappe.db.set_single_value("Accounts Settings", "use_new_budget_controller", True) erpnext.patches.v15_0.rename_group_by_to_categorize_by_in_custom_reports erpnext.patches.v15_0.remove_agriculture_roles +erpnext.patches.v14_0.update_full_name_in_contract diff --git a/erpnext/patches/v14_0/update_full_name_in_contract.py b/erpnext/patches/v14_0/update_full_name_in_contract.py new file mode 100644 index 00000000000..19ee055ad12 --- /dev/null +++ b/erpnext/patches/v14_0/update_full_name_in_contract.py @@ -0,0 +1,15 @@ +import frappe +from frappe import qb + + +def execute(): + con = qb.DocType("Contract") + for c in ( + qb.from_(con) + .select(con.name, con.party_type, con.party_name) + .where(con.party_full_name.isnull()) + .run(as_dict=True) + ): + field = c.party_type.lower() + "_name" + if res := frappe.db.get_value(c.party_type, c.party_name, field): + frappe.db.set_value("Contract", c.name, "party_full_name", res)