From 0863c1e05c361acf8d6d61f911bdc512f4f70327 Mon Sep 17 00:00:00 2001 From: pandiyan Date: Mon, 27 Jul 2026 13:18:31 +0530 Subject: [PATCH] fix: stop storing raw title template on subcontracting orders subcontracting order and subcontracting inward order carry a hidden title field defaulting to "{supplier_name}" / "{customer_name}", while their title_field points at supplier_name / customer_name. document. set_title_field() substitutes the template only when title_field is "title", so every record stores the placeholder verbatim. drop the dead default and hidden flags, move title into the other info tab to match purchase order, and add a patch to repair existing rows. (cherry picked from commit 5008e6126f762b781259cfa16013f6d8f110895a) --- erpnext/patches.txt | 1 + .../v16_0/fix_subcontracting_titles.py | 28 +++++++++++++++++++ .../subcontracting_inward_order.json | 6 ++-- .../subcontracting_order.json | 6 ++-- 4 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 erpnext/patches/v16_0/fix_subcontracting_titles.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 7e2567e26e3..7be752b8694 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -493,3 +493,4 @@ erpnext.patches.v16_0.backfill_pick_list_transferred_qty erpnext.patches.v16_0.access_control_for_project_users erpnext.patches.v16_0.enable_book_stock_expense_gl_entries erpnext.patches.v16_0.rename_ar_ap_ageing_filter +erpnext.patches.v16_0.fix_subcontracting_titles diff --git a/erpnext/patches/v16_0/fix_subcontracting_titles.py b/erpnext/patches/v16_0/fix_subcontracting_titles.py new file mode 100644 index 00000000000..71c55bfc80e --- /dev/null +++ b/erpnext/patches/v16_0/fix_subcontracting_titles.py @@ -0,0 +1,28 @@ +import frappe + + +def execute(): + """ + This patch corrects the titles of the subcontracting order doctypes set to + the text strings "{customer_name}" or "{supplier_name}" instead of the + actual customer or supplier name. + + Their `title_field` never pointed at `title`, so the template default was + stored verbatim instead of being substituted. + """ + + party_fields = { + "Subcontracting Order": "supplier_name", + "Subcontracting Inward Order": "customer_name", + } + + for doctype, party_field in party_fields.items(): + if not frappe.db.has_column(doctype, "title"): + continue + + table = frappe.qb.DocType(doctype) + ( + frappe.qb.update(table) + .set(table.title, table[party_field]) + .where(table.title == f"{{{party_field}}}") + ).run() diff --git a/erpnext/subcontracting/doctype/subcontracting_inward_order/subcontracting_inward_order.json b/erpnext/subcontracting/doctype/subcontracting_inward_order/subcontracting_inward_order.json index a0b163f4271..034e98f37b6 100644 --- a/erpnext/subcontracting/doctype/subcontracting_inward_order/subcontracting_inward_order.json +++ b/erpnext/subcontracting/doctype/subcontracting_inward_order/subcontracting_inward_order.json @@ -8,7 +8,6 @@ "document_type": "Document", "engine": "InnoDB", "field_order": [ - "title", "naming_series", "sales_order", "customer", @@ -29,6 +28,7 @@ "service_items_section", "service_items", "tab_other_info", + "title", "order_status_section", "status", "per_raw_material_received", @@ -43,10 +43,8 @@ "fields": [ { "allow_on_submit": 1, - "default": "{customer_name}", "fieldname": "title", "fieldtype": "Data", - "hidden": 1, "label": "Title", "no_copy": 1, "print_hide": 1 @@ -306,7 +304,7 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2026-02-26 17:16:21.697846", + "modified": "2026-07-27 11:20:14.512336", "modified_by": "Administrator", "module": "Subcontracting", "name": "Subcontracting Inward Order", diff --git a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.json b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.json index d0223a3acd2..317dd3fd71d 100644 --- a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.json +++ b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.json @@ -8,7 +8,6 @@ "document_type": "Document", "engine": "InnoDB", "field_order": [ - "title", "naming_series", "purchase_order", "supplier", @@ -55,6 +54,7 @@ "additional_costs", "total_additional_costs", "tab_other_info", + "title", "order_status_section", "status", "column_break_39", @@ -69,10 +69,8 @@ "fields": [ { "allow_on_submit": 1, - "default": "{supplier_name}", "fieldname": "title", "fieldtype": "Data", - "hidden": 1, "label": "Title", "no_copy": 1, "print_hide": 1 @@ -494,7 +492,7 @@ "icon": "fa fa-file-text", "is_submittable": 1, "links": [], - "modified": "2025-11-14 10:31:40.682892", + "modified": "2026-07-27 11:20:14.512336", "modified_by": "Administrator", "module": "Subcontracting", "name": "Subcontracting Order",