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 5008e6126f)
This commit is contained in:
pandiyan
2026-07-27 13:18:31 +05:30
committed by Mergify
parent 39d5fd84db
commit 0863c1e05c
4 changed files with 33 additions and 8 deletions

View File

@@ -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

View File

@@ -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()

View File

@@ -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",

View File

@@ -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",