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)

# Conflicts:
#	erpnext/subcontracting/doctype/subcontracting_inward_order/subcontracting_inward_order.json
#	erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.json
This commit is contained in:
pandiyan
2026-07-27 13:18:31 +05:30
committed by Mergify
parent ceb677844f
commit 6896710d02
4 changed files with 406 additions and 3 deletions

View File

@@ -444,3 +444,4 @@ erpnext.patches.v16_0.crm_settings_handle_allowed_users_for_frappe_crm
erpnext.patches.v16_0.backfill_pick_list_transferred_qty
erpnext.patches.v16_0.access_control_for_project_users
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

@@ -0,0 +1,372 @@
{
"actions": [],
"allow_auto_repeat": 1,
"allow_import": 1,
"autoname": "naming_series:",
"creation": "2025-03-24 12:50:26.464612",
"doctype": "DocType",
"document_type": "Document",
"engine": "InnoDB",
"field_order": [
"naming_series",
"sales_order",
"customer",
"customer_name",
"currency",
"column_break_7",
"company",
"transaction_date",
"customer_warehouse",
"amended_from",
"items_section",
"set_delivery_warehouse",
"items",
"raw_materials_received_section",
"received_items",
"scrap_items_generated_section",
"secondary_items",
"service_items_section",
"service_items",
"tab_other_info",
"title",
"order_status_section",
"status",
"per_raw_material_received",
"per_produced",
"per_delivered",
"column_break_39",
"per_raw_material_returned",
"per_process_loss",
"per_returned",
"tab_connections"
],
"fields": [
{
"allow_on_submit": 1,
"fieldname": "title",
"fieldtype": "Data",
"label": "Title",
"no_copy": 1,
"print_hide": 1
},
{
"fieldname": "naming_series",
"fieldtype": "Select",
"label": "Series",
"no_copy": 1,
"options": "SCI-ORD-.YYYY.-",
"print_hide": 1,
"reqd": 1,
"set_only_once": 1
},
{
"fieldname": "sales_order",
"fieldtype": "Link",
"label": "Subcontracting Sales Order",
"options": "Sales Order",
"reqd": 1
},
{
"bold": 1,
"fieldname": "customer",
"fieldtype": "Link",
"in_global_search": 1,
"in_standard_filter": 1,
"label": "Customer",
"options": "Customer",
"print_hide": 1,
"read_only": 1,
"reqd": 1,
"search_index": 1
},
{
"bold": 1,
"fetch_from": "customer.customer_name",
"fieldname": "customer_name",
"fieldtype": "Data",
"in_global_search": 1,
"label": "Customer Name",
"read_only": 1,
"reqd": 1
},
{
"fieldname": "column_break_7",
"fieldtype": "Column Break",
"print_width": "50%",
"width": "50%"
},
{
"fieldname": "company",
"fieldtype": "Link",
"in_standard_filter": 1,
"label": "Company",
"options": "Company",
"print_hide": 1,
"remember_last_selected_value": 1,
"reqd": 1
},
{
"default": "Today",
"fetch_from": "sales_order.transaction_date",
"fetch_if_empty": 1,
"fieldname": "transaction_date",
"fieldtype": "Date",
"in_list_view": 1,
"label": "Date",
"reqd": 1,
"search_index": 1
},
{
"fieldname": "amended_from",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Amended From",
"no_copy": 1,
"options": "Subcontracting Inward Order",
"print_hide": 1,
"read_only": 1
},
{
"allow_bulk_edit": 1,
"depends_on": "sales_order",
"fieldname": "items",
"fieldtype": "Table",
"label": "Items",
"options": "Subcontracting Inward Order Item",
"reqd": 1
},
{
"collapsible": 1,
"fieldname": "service_items_section",
"fieldtype": "Section Break",
"label": "Service Items"
},
{
"fieldname": "service_items",
"fieldtype": "Table",
"label": "Service Items",
"options": "Subcontracting Inward Order Service Item",
"read_only": 1,
"reqd": 1
},
{
"collapsible": 1,
"collapsible_depends_on": "received_items",
"depends_on": "received_items",
"fieldname": "raw_materials_received_section",
"fieldtype": "Section Break",
"label": "Raw Materials Required"
},
{
"allow_on_submit": 1,
"fieldname": "received_items",
"fieldtype": "Table",
"label": "Required Items",
"no_copy": 1,
"options": "Subcontracting Inward Order Received Item",
"print_hide": 1,
"read_only": 1
},
{
"fieldname": "order_status_section",
"fieldtype": "Section Break",
"label": "Order Status"
},
{
"default": "Draft",
"fieldname": "status",
"fieldtype": "Select",
"in_standard_filter": 1,
"label": "Status",
"no_copy": 1,
"options": "Draft\nOpen\nOngoing\nProduced\nDelivered\nReturned\nCancelled\nClosed",
"print_hide": 1,
"read_only": 1,
"reqd": 1,
"search_index": 1
},
{
"fieldname": "column_break_39",
"fieldtype": "Column Break"
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "per_delivered",
"fieldtype": "Percent",
"in_list_view": 1,
"label": "% Delivered",
"no_copy": 1,
"print_hide": 1,
"read_only": 1
},
{
"fieldname": "tab_other_info",
"fieldtype": "Tab Break",
"label": "Other Info"
},
{
"fieldname": "tab_connections",
"fieldtype": "Tab Break",
"label": "Connections",
"show_dashboard": 1
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "per_produced",
"fieldtype": "Percent",
"in_list_view": 1,
"label": "% Produced",
"no_copy": 1,
"print_hide": 1,
"read_only": 1
},
{
"fieldname": "items_section",
"fieldtype": "Section Break",
"label": "Items"
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "per_process_loss",
"fieldtype": "Percent",
"in_list_view": 1,
"label": "% Process Loss",
"no_copy": 1,
"print_hide": 1,
"read_only": 1
},
{
"fieldname": "set_delivery_warehouse",
"fieldtype": "Link",
"label": "Set Delivery Warehouse",
"no_copy": 1,
"options": "Warehouse"
},
{
"fieldname": "customer_warehouse",
"fieldtype": "Link",
"label": "Customer Warehouse",
"options": "Warehouse",
"reqd": 1
},
{
"depends_on": "secondary_items",
"fieldname": "scrap_items_generated_section",
"fieldtype": "Section Break",
"label": "Secondary Items Generated"
},
{
"fieldname": "per_returned",
"fieldtype": "Percent",
"in_list_view": 1,
"label": "% Returned",
"no_copy": 1,
"print_hide": 1,
"read_only": 1
},
{
"fieldname": "per_raw_material_returned",
"fieldtype": "Percent",
"in_list_view": 1,
"label": "% Raw Material Returned",
"no_copy": 1,
"print_hide": 1,
"read_only": 1
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "per_raw_material_received",
"fieldtype": "Percent",
"in_list_view": 1,
"label": "% Raw Material Received",
"no_copy": 1,
"print_hide": 1,
"read_only": 1
},
{
"fetch_from": "customer.default_currency",
"fieldname": "currency",
"fieldtype": "Link",
"hidden": 1,
"label": "Customer Currency",
"options": "Currency",
"read_only": 1
},
{
"fieldname": "secondary_items",
"fieldtype": "Table",
"label": "Secondary Items",
"no_copy": 1,
"options": "Subcontracting Inward Order Secondary Item"
}
],
"grid_page_length": 50,
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2026-07-27 11:20:14.512336",
"modified_by": "Administrator",
"module": "Subcontracting",
"name": "Subcontracting Inward Order",
"naming_rule": "By \"Naming Series\" field",
"owner": "Administrator",
"permissions": [
{
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Stock User",
"share": 1
},
{
"cancel": 1,
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Sales Manager",
"share": 1,
"submit": 1,
"write": 1
},
{
"cancel": 1,
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Sales User",
"share": 1,
"submit": 1,
"write": 1
},
{
"email": 1,
"export": 1,
"permlevel": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Sales Manager",
"share": 1,
"write": 1
}
],
"row_format": "Dynamic",
"search_fields": "status, transaction_date, customer",
"show_name_in_global_search": 1,
"sort_field": "creation",
"sort_order": "DESC",
"states": [],
"timeline_field": "customer",
"title_field": "customer_name",
"track_changes": 1
}

View File

@@ -8,7 +8,6 @@
"document_type": "Document",
"engine": "InnoDB",
"field_order": [
"title",
"naming_series",
"purchase_order",
"supplier",
@@ -53,6 +52,7 @@
"additional_costs",
"total_additional_costs",
"tab_other_info",
"title",
"order_status_section",
"status",
"column_break_39",
@@ -66,10 +66,8 @@
"fields": [
{
"allow_on_submit": 1,
"default": "{supplier_name}",
"fieldname": "title",
"fieldtype": "Data",
"hidden": 1,
"label": "Title",
"no_copy": 1,
"print_hide": 1
@@ -465,7 +463,11 @@
"icon": "fa fa-file-text",
"is_submittable": 1,
"links": [],
<<<<<<< HEAD
"modified": "2024-12-06 15:21:49.924146",
=======
"modified": "2026-07-27 11:20:14.512336",
>>>>>>> 5008e6126f (fix: stop storing raw title template on subcontracting orders)
"modified_by": "Administrator",
"module": "Subcontracting",
"name": "Subcontracting Order",