Merge pull request #52950 from frappe/mergify/bp/version-16-hotfix/pr-52507

refactor: toggle for UTM parameters (backport #52507)
This commit is contained in:
ruthra kumar
2026-02-25 15:10:30 +05:30
committed by GitHub
10 changed files with 162 additions and 87 deletions

View File

@@ -159,15 +159,16 @@
"language", "language",
"column_break_84", "column_break_84",
"select_print_heading", "select_print_heading",
"utm_analytics_section",
"utm_source",
"utm_medium",
"column_break_bhao",
"utm_campaign",
"more_information", "more_information",
"inter_company_invoice_reference", "inter_company_invoice_reference",
"customer_group", "customer_group",
"is_discounted", "is_discounted",
"col_break23", "col_break23",
"utm_source",
"utm_campaign",
"utm_medium",
"column_break_gpiw",
"status", "status",
"more_info", "more_info",
"debit_to", "debit_to",
@@ -1541,10 +1542,6 @@
"fieldtype": "Check", "fieldtype": "Check",
"label": "Update Billed Amount in Delivery Note" "label": "Update Billed Amount in Delivery Note"
}, },
{
"fieldname": "column_break_gpiw",
"fieldtype": "Column Break"
},
{ {
"fieldname": "utm_medium", "fieldname": "utm_medium",
"fieldtype": "Link", "fieldtype": "Link",
@@ -1612,12 +1609,22 @@
"no_copy": 1, "no_copy": 1,
"options": "Item Wise Tax Detail", "options": "Item Wise Tax Detail",
"print_hide": 1 "print_hide": 1
},
{
"collapsible": 1,
"fieldname": "utm_analytics_section",
"fieldtype": "Section Break",
"label": "UTM Analytics"
},
{
"fieldname": "column_break_bhao",
"fieldtype": "Column Break"
} }
], ],
"icon": "fa fa-file-text", "icon": "fa fa-file-text",
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2026-01-29 21:20:51.376875", "modified": "2026-02-10 14:23:07.181782",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "POS Invoice", "name": "POS Invoice",

View File

@@ -12,9 +12,6 @@
"disabled", "disabled",
"column_break_9", "column_break_9",
"warehouse", "warehouse",
"utm_source",
"utm_campaign",
"utm_medium",
"company_address", "company_address",
"section_break_15", "section_break_15",
"applicable_for_users", "applicable_for_users",
@@ -61,7 +58,13 @@
"accounting_dimensions_section", "accounting_dimensions_section",
"cost_center", "cost_center",
"dimension_col_break", "dimension_col_break",
"project" "project",
"utm_analytics_section",
"utm_source",
"column_break_tvls",
"utm_campaign",
"column_break_xygw",
"utm_medium"
], ],
"fields": [ "fields": [
{ {
@@ -430,6 +433,20 @@
"fieldname": "allow_partial_payment", "fieldname": "allow_partial_payment",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Allow Partial Payment" "label": "Allow Partial Payment"
},
{
"fieldname": "column_break_tvls",
"fieldtype": "Column Break"
},
{
"fieldname": "column_break_xygw",
"fieldtype": "Column Break"
},
{
"collapsible": 1,
"fieldname": "utm_analytics_section",
"fieldtype": "Section Break",
"label": "Campaign"
} }
], ],
"grid_page_length": 50, "grid_page_length": 50,
@@ -458,7 +475,7 @@
"link_fieldname": "pos_profile" "link_fieldname": "pos_profile"
} }
], ],
"modified": "2025-06-24 11:19:19.834905", "modified": "2026-02-10 14:24:48.597412",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "POS Profile", "name": "POS Profile",

View File

@@ -219,16 +219,17 @@
"column_break_140", "column_break_140",
"to_date", "to_date",
"update_auto_repeat_reference", "update_auto_repeat_reference",
"utm_analytics_section",
"utm_source",
"utm_medium",
"column_break_ixxw",
"utm_campaign",
"utm_content",
"more_information", "more_information",
"status", "status",
"remarks", "remarks",
"customer_group", "customer_group",
"column_break_imbx", "column_break_imbx",
"utm_source",
"utm_campaign",
"utm_medium",
"utm_content",
"col_break23",
"is_internal_customer", "is_internal_customer",
"represents_company", "represents_company",
"inter_company_invoice_reference", "inter_company_invoice_reference",
@@ -1632,13 +1633,6 @@
"no_copy": 1, "no_copy": 1,
"read_only": 1 "read_only": 1
}, },
{
"fieldname": "col_break23",
"fieldtype": "Column Break",
"hide_days": 1,
"hide_seconds": 1,
"width": "50%"
},
{ {
"default": "Draft", "default": "Draft",
"fieldname": "status", "fieldname": "status",
@@ -2313,6 +2307,16 @@
{ {
"fieldname": "column_break_rdks", "fieldname": "column_break_rdks",
"fieldtype": "Column Break" "fieldtype": "Column Break"
},
{
"fieldname": "column_break_ixxw",
"fieldtype": "Column Break"
},
{
"collapsible": 1,
"fieldname": "utm_analytics_section",
"fieldtype": "Section Break",
"label": "UTM Analytics"
} }
], ],
"grid_page_length": 50, "grid_page_length": 50,
@@ -2326,7 +2330,7 @@
"link_fieldname": "consolidated_invoice" "link_fieldname": "consolidated_invoice"
} }
], ],
"modified": "2026-02-23 14:29:00.301842", "modified": "2026-02-10 11:59:07.819903",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Sales Invoice", "name": "Sales Invoice",

View File

@@ -52,13 +52,12 @@
"country", "country",
"column_break2", "column_break2",
"contact_html", "contact_html",
"section_break_analytics", "utm_analytics_section",
"utm_source", "utm_source",
"utm_content", "utm_medium",
"column_break_gkxo", "column_break_gkxo",
"utm_campaign", "utm_campaign",
"column_break_gqka", "utm_content",
"utm_medium",
"qualification_tab", "qualification_tab",
"qualification_status", "qualification_status",
"column_break_64", "column_break_64",
@@ -504,10 +503,6 @@
"fieldname": "column_break_gkxo", "fieldname": "column_break_gkxo",
"fieldtype": "Column Break" "fieldtype": "Column Break"
}, },
{
"fieldname": "column_break_gqka",
"fieldtype": "Column Break"
},
{ {
"fieldname": "utm_content", "fieldname": "utm_content",
"fieldtype": "Data", "fieldtype": "Data",
@@ -537,7 +532,8 @@
"options": "UTM Campaign" "options": "UTM Campaign"
}, },
{ {
"fieldname": "section_break_analytics", "collapsible": 1,
"fieldname": "utm_analytics_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Analytics" "label": "Analytics"
} }
@@ -547,7 +543,7 @@
"idx": 5, "idx": 5,
"image_field": "image", "image_field": "image",
"links": [], "links": [],
"modified": "2025-06-26 11:02:01.158901", "modified": "2026-02-10 14:36:37.157961",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "CRM", "module": "CRM",
"name": "Lead", "name": "Lead",

View File

@@ -44,13 +44,12 @@
"column_break_17", "column_break_17",
"opportunity_amount", "opportunity_amount",
"base_opportunity_amount", "base_opportunity_amount",
"section_break_analytics", "utm_analytics_section",
"utm_source", "utm_source",
"utm_content", "utm_medium",
"column_break_emai", "column_break_emai",
"utm_campaign", "utm_campaign",
"column_break_whcu", "utm_content",
"utm_medium",
"more_info", "more_info",
"company", "company",
"transaction_date", "transaction_date",
@@ -629,15 +628,6 @@
"options": "UTM Campaign", "options": "UTM Campaign",
"print_hide": 1 "print_hide": 1
}, },
{
"fieldname": "section_break_analytics",
"fieldtype": "Section Break",
"label": "Analytics"
},
{
"fieldname": "column_break_whcu",
"fieldtype": "Column Break"
},
{ {
"fieldname": "utm_medium", "fieldname": "utm_medium",
"fieldtype": "Link", "fieldtype": "Link",
@@ -650,13 +640,19 @@
"fieldtype": "Data", "fieldtype": "Data",
"label": "Content", "label": "Content",
"print_hide": 1 "print_hide": 1
},
{
"collapsible": 1,
"fieldname": "utm_analytics_section",
"fieldtype": "Section Break",
"label": "Analytics"
} }
], ],
"grid_page_length": 50, "grid_page_length": 50,
"icon": "fa fa-info-sign", "icon": "fa fa-info-sign",
"idx": 195, "idx": 195,
"links": [], "links": [],
"modified": "2025-08-11 13:35:39.476016", "modified": "2026-02-10 14:36:01.387984",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "CRM", "module": "CRM",
"name": "Opportunity", "name": "Opportunity",

View File

@@ -123,19 +123,20 @@
"competitors", "competitors",
"column_break_117", "column_break_117",
"order_lost_reason", "order_lost_reason",
"utm_analytics_section",
"utm_source",
"utm_medium",
"column_break_fozg",
"utm_campaign",
"utm_content",
"additional_info_section", "additional_info_section",
"status", "status",
"customer_group", "customer_group",
"territory", "territory",
"column_break_108", "column_break_108",
"utm_source",
"utm_campaign",
"utm_medium",
"utm_content",
"column_break4",
"opportunity", "opportunity",
"supplier_quotation",
"enq_det", "enq_det",
"supplier_quotation",
"connections_tab" "connections_tab"
], ],
"fields": [ "fields": [
@@ -862,13 +863,6 @@
"oldfieldtype": "Small Text", "oldfieldtype": "Small Text",
"print_hide": 1 "print_hide": 1
}, },
{
"fieldname": "column_break4",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_hide": 1,
"width": "50%"
},
{ {
"default": "Draft", "default": "Draft",
"fieldname": "status", "fieldname": "status",
@@ -1117,13 +1111,23 @@
"no_copy": 1, "no_copy": 1,
"options": "Item Wise Tax Detail", "options": "Item Wise Tax Detail",
"print_hide": 1 "print_hide": 1
},
{
"fieldname": "column_break_fozg",
"fieldtype": "Column Break"
},
{
"collapsible": 1,
"fieldname": "utm_analytics_section",
"fieldtype": "Section Break",
"label": "UTM Analytics"
} }
], ],
"icon": "fa fa-shopping-cart", "icon": "fa fa-shopping-cart",
"idx": 82, "idx": 82,
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2026-01-29 21:18:48.836168", "modified": "2026-02-06 17:34:22.170032",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Selling", "module": "Selling",
"name": "Quotation", "name": "Quotation",

View File

@@ -161,17 +161,18 @@
"column_break4", "column_break4",
"select_print_heading", "select_print_heading",
"language", "language",
"utm_analytics_section",
"utm_source",
"utm_medium",
"column_break_ijxt",
"utm_campaign",
"utm_content",
"additional_info_section", "additional_info_section",
"is_internal_customer", "is_internal_customer",
"po_no", "po_no",
"po_date", "po_date",
"represents_company", "represents_company",
"column_break_yvzv", "column_break_yvzv",
"utm_source",
"utm_campaign",
"utm_medium",
"utm_content",
"column_break_152",
"inter_company_order_reference", "inter_company_order_reference",
"party_account_currency", "party_account_currency",
"connections_tab" "connections_tab"
@@ -1567,10 +1568,6 @@
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Additional Info" "label": "Additional Info"
}, },
{
"fieldname": "column_break_152",
"fieldtype": "Column Break"
},
{ {
"fieldname": "incoterm", "fieldname": "incoterm",
"fieldtype": "Link", "fieldtype": "Link",
@@ -1717,6 +1714,16 @@
"hide_days": 1, "hide_days": 1,
"hide_seconds": 1, "hide_seconds": 1,
"label": "Additional Discount" "label": "Additional Discount"
},
{
"fieldname": "column_break_ijxt",
"fieldtype": "Column Break"
},
{
"collapsible": 1,
"fieldname": "utm_analytics_section",
"fieldtype": "Section Break",
"label": "UTM Analytics"
} }
], ],
"grid_page_length": 50, "grid_page_length": 50,
@@ -1724,7 +1731,7 @@
"idx": 105, "idx": 105,
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2026-02-23 14:25:56.665392", "modified": "2026-02-10 11:55:52.796522",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Selling", "module": "Selling",
"name": "Sales Order", "name": "Sales Order",

View File

@@ -41,6 +41,8 @@
"allow_zero_qty_in_quotation", "allow_zero_qty_in_quotation",
"allow_zero_qty_in_sales_order", "allow_zero_qty_in_sales_order",
"set_zero_rate_for_expired_batch", "set_zero_rate_for_expired_batch",
"section_break_avhb",
"enable_utm",
"experimental_section", "experimental_section",
"use_legacy_js_reactivity", "use_legacy_js_reactivity",
"subcontracting_inward_tab", "subcontracting_inward_tab",
@@ -305,6 +307,19 @@
"fieldname": "enable_tracking_sales_commissions", "fieldname": "enable_tracking_sales_commissions",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Enable tracking sales commissions" "label": "Enable tracking sales commissions"
},
{
"fieldname": "section_break_avhb",
"fieldtype": "Section Break",
"label": "Analytics"
},
{
"default": "0",
"description": "Enable Urchin Tracking Module parameters in Quotation, Sales Order, Sales Invoice, POS Invoice, Lead, and Delivery Note.",
"documentation_url": "https://en.wikipedia.org/wiki/UTM_parameters",
"fieldname": "enable_utm",
"fieldtype": "Check",
"label": "Enable UTM"
} }
], ],
"grid_page_length": 50, "grid_page_length": 50,
@@ -314,7 +329,7 @@
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"issingle": 1, "issingle": 1,
"links": [], "links": [],
"modified": "2026-02-04 16:16:57.618127", "modified": "2026-02-12 10:38:34.605126",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Selling", "module": "Selling",
"name": "Selling Settings", "name": "Selling Settings",

View File

@@ -10,6 +10,17 @@ from frappe.custom.doctype.property_setter.property_setter import make_property_
from frappe.model.document import Document from frappe.model.document import Document
from frappe.utils import cint from frappe.utils import cint
UTM_DOCTYPES = [
"Lead",
"Quotation",
"POS Invoice",
"POS Profile",
"Opportunity",
"Sales Order",
"Sales Invoice",
"Delivery Note",
]
class SellingSettings(Document): class SellingSettings(Document):
# begin: auto-generated types # begin: auto-generated types
@@ -38,6 +49,7 @@ class SellingSettings(Document):
enable_cutoff_date_on_bulk_delivery_note_creation: DF.Check enable_cutoff_date_on_bulk_delivery_note_creation: DF.Check
enable_discount_accounting: DF.Check enable_discount_accounting: DF.Check
enable_tracking_sales_commissions: DF.Check enable_tracking_sales_commissions: DF.Check
enable_utm: DF.Check
fallback_to_default_price_list: DF.Check fallback_to_default_price_list: DF.Check
hide_tax_id: DF.Check hide_tax_id: DF.Check
maintain_same_rate_action: DF.Literal["Stop", "Warn"] maintain_same_rate_action: DF.Literal["Stop", "Warn"]
@@ -84,6 +96,9 @@ class SellingSettings(Document):
if old_doc.enable_tracking_sales_commissions != self.enable_tracking_sales_commissions: if old_doc.enable_tracking_sales_commissions != self.enable_tracking_sales_commissions:
toggle_tracking_sales_commissions_section(not self.enable_tracking_sales_commissions) toggle_tracking_sales_commissions_section(not self.enable_tracking_sales_commissions)
if old_doc.enable_utm != self.enable_utm:
toggle_utm_analytics_section(not self.enable_utm)
def validate_fallback_to_default_price_list(self): def validate_fallback_to_default_price_list(self):
if ( if (
self.fallback_to_default_price_list self.fallback_to_default_price_list
@@ -195,3 +210,14 @@ def toggle_tracking_sales_commissions_section(hide):
create_property_setter_for_hiding_field(doctype, "commission_section", hide) create_property_setter_for_hiding_field(doctype, "commission_section", hide)
if meta.has_field("sales_team_section"): if meta.has_field("sales_team_section"):
create_property_setter_for_hiding_field(doctype, "sales_team_section", hide) create_property_setter_for_hiding_field(doctype, "sales_team_section", hide)
def toggle_utm_analytics_section(hide):
from erpnext.accounts.doctype.accounts_settings.accounts_settings import (
create_property_setter_for_hiding_field,
)
for doctype in UTM_DOCTYPES:
meta = frappe.get_meta(doctype)
if meta.has_field("utm_analytics_section"):
create_property_setter_for_hiding_field(doctype, "utm_analytics_section", hide)

View File

@@ -156,17 +156,18 @@
"column_break_88", "column_break_88",
"select_print_heading", "select_print_heading",
"language", "language",
"utm_analytics_section",
"utm_source",
"utm_medium",
"column_break_neoj",
"utm_campaign",
"utm_content",
"more_info", "more_info",
"is_internal_customer", "is_internal_customer",
"represents_company", "represents_company",
"inter_company_reference", "inter_company_reference",
"customer_group", "customer_group",
"territory", "territory",
"column_break_pxls",
"utm_source",
"utm_campaign",
"utm_medium",
"utm_content",
"column_break5", "column_break5",
"excise_page", "excise_page",
"instructions", "instructions",
@@ -1366,10 +1367,6 @@
"options": "Delivery Trip", "options": "Delivery Trip",
"print_hide": 1 "print_hide": 1
}, },
{
"fieldname": "column_break_pxls",
"fieldtype": "Column Break"
},
{ {
"fieldname": "utm_medium", "fieldname": "utm_medium",
"fieldtype": "Link", "fieldtype": "Link",
@@ -1438,7 +1435,13 @@
"options": "Company:company:default_currency" "options": "Company:company:default_currency"
}, },
{ {
"fieldname": "column_break_ydwe", "collapsible": 1,
"fieldname": "utm_analytics_section",
"fieldtype": "Section Break",
"label": "UTM Analytics"
},
{
"fieldname": "column_break_neoj",
"fieldtype": "Column Break" "fieldtype": "Column Break"
} }
], ],
@@ -1446,7 +1449,7 @@
"idx": 146, "idx": 146,
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2026-02-23 23:05:39.097097", "modified": "2026-02-10 14:35:08.523130",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Delivery Note", "name": "Delivery Note",