From 226aafa8cf1d84a2ed51fb30af726b166c394762 Mon Sep 17 00:00:00 2001 From: Jatin3128 Date: Mon, 2 Mar 2026 07:35:54 +0530 Subject: [PATCH] feat: add setting to hide Subscription references across doctypes --- .../accounts_settings/accounts_settings.json | 8 ++++++ .../accounts_settings/accounts_settings.py | 11 ++++++++ .../doctype/journal_entry/journal_entry.json | 12 ++++----- .../doctype/payment_entry/payment_entry.json | 16 ++++++------ .../payment_request/payment_request.json | 4 +-- .../payment_request/payment_request.py | 2 +- .../doctype/pos_invoice/pos_invoice.json | 15 ++++++----- .../purchase_invoice/purchase_invoice.json | 11 ++++++-- .../doctype/sales_invoice/sales_invoice.json | 11 ++++++-- .../purchase_order/purchase_order.json | 14 +++++----- .../supplier_quotation.json | 14 +++++----- erpnext/hooks.py | 2 ++ .../selling/doctype/quotation/quotation.json | 12 ++++----- .../doctype/sales_order/sales_order.json | 26 +++++++++---------- .../doctype/delivery_note/delivery_note.json | 12 ++++----- 15 files changed, 103 insertions(+), 67 deletions(-) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index ee734184452..c97cd3ef2ef 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -16,6 +16,7 @@ "invoicing_features_section", "check_supplier_invoice_uniqueness", "automatically_fetch_payment_terms", + "enable_subscription", "column_break_17", "enable_common_party_accounting", "allow_multi_currency_invoices_against_single_party_account", @@ -688,6 +689,13 @@ "fieldname": "enable_accounting_dimensions", "fieldtype": "Check", "label": "Enable Accounting Dimensions" + }, + { + "default": "1", + "description": "Enable Subscription tracking in invoice", + "fieldname": "enable_subscription", + "fieldtype": "Check", + "label": "Enable Subscription" } ], "grid_page_length": 50, diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py index e75b8ad1710..1bdba08fb75 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py @@ -72,6 +72,7 @@ class AccountsSettings(Document): enable_immutable_ledger: DF.Check enable_loyalty_point_program: DF.Check enable_party_matching: DF.Check + enable_subscription: DF.Check exchange_gain_loss_posting_date: DF.Literal["Invoice", "Payment", "Reconciliation Date"] fetch_valuation_rate_for_internal_transaction: DF.Check general_ledger_remarks_length: DF.Int @@ -135,6 +136,10 @@ class AccountsSettings(Document): toggle_loyalty_point_program_section(not self.enable_loyalty_point_program) clear_cache = True + if old_doc.enable_subscription != self.enable_subscription: + toggle_subscription_sections(not self.enable_subscription) + clear_cache = True + if clear_cache: frappe.clear_cache() @@ -215,6 +220,12 @@ def toggle_loyalty_point_program_section(hide): create_property_setter_for_hiding_field(doctype, "loyalty_points_redemption", hide) +def toggle_subscription_sections(hide): + subscription_doctypes = frappe.get_hooks("subscription_doctypes") + for doctype in subscription_doctypes: + create_property_setter_for_hiding_field(doctype, "subscription_section", hide) + + def create_property_setter_for_hiding_field(doctype, field_name, hide): make_property_setter( doctype, diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.json b/erpnext/accounts/doctype/journal_entry/journal_entry.json index 0856f41bb09..c55f8d1860f 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.json +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.json @@ -39,7 +39,7 @@ "clearance_date", "column_break_oizh", "user_remark", - "subscription_section", + "auto_repeat_section", "auto_repeat", "tax_withholding_tab", "section_tax_withholding_entry", @@ -475,11 +475,6 @@ "options": "Stock Entry", "read_only": 1 }, - { - "fieldname": "subscription_section", - "fieldtype": "Section Break", - "label": "Subscription" - }, { "allow_on_submit": 1, "fieldname": "auto_repeat", @@ -651,6 +646,11 @@ "fieldname": "tax_withholding_tab", "fieldtype": "Tab Break", "label": "Tax Withholding" + }, + { + "fieldname": "auto_repeat_section", + "fieldtype": "Section Break", + "label": "Auto Repeat" } ], "icon": "fa fa-file-text", diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.json b/erpnext/accounts/doctype/payment_entry/payment_entry.json index afa508781d8..5500e1b3e07 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.json +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.json @@ -89,6 +89,7 @@ "remarks", "base_in_words", "is_opening", + "title", "column_break_16", "letter_head", "print_heading", @@ -96,10 +97,9 @@ "bank_account_no", "payment_order", "in_words", - "subscription_section", - "auto_repeat", "amended_from", - "title" + "auto_repeat_section", + "auto_repeat" ], "fields": [ { @@ -503,11 +503,6 @@ "print_hide": 1, "read_only": 1 }, - { - "fieldname": "subscription_section", - "fieldtype": "Section Break", - "label": "Subscription Section" - }, { "allow_on_submit": 1, "fieldname": "auto_repeat", @@ -781,6 +776,11 @@ "fieldname": "override_tax_withholding_entries", "fieldtype": "Check", "label": "Edit Tax Withholding Entries" + }, + { + "fieldname": "auto_repeat_section", + "fieldtype": "Section Break", + "label": "Auto Repeat" } ], "grid_page_length": 50, diff --git a/erpnext/accounts/doctype/payment_request/payment_request.json b/erpnext/accounts/doctype/payment_request/payment_request.json index 8fcf1f2f41f..17d8b74aa14 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.json +++ b/erpnext/accounts/doctype/payment_request/payment_request.json @@ -183,7 +183,7 @@ "depends_on": "eval:doc.is_a_subscription", "fieldname": "subscription_section", "fieldtype": "Section Break", - "label": "Subscription Section" + "label": "Subscription" }, { "fieldname": "subscription_plans", @@ -478,7 +478,7 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2026-01-13 12:53:00.963274", + "modified": "2026-02-27 19:11:03.308896", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Request", diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py index 81ddd1de537..ddac9f6fd1b 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.py +++ b/erpnext/accounts/doctype/payment_request/payment_request.py @@ -102,8 +102,8 @@ class PaymentRequest(Document): subscription_plans: DF.Table[SubscriptionPlanDetail] swift_number: DF.ReadOnly | None transaction_date: DF.Date | None - # end: auto-generated types + def on_discard(self): self.db_set("status", "Cancelled") diff --git a/erpnext/accounts/doctype/pos_invoice/pos_invoice.json b/erpnext/accounts/doctype/pos_invoice/pos_invoice.json index ff57c811c58..c8fc266b012 100644 --- a/erpnext/accounts/doctype/pos_invoice/pos_invoice.json +++ b/erpnext/accounts/doctype/pos_invoice/pos_invoice.json @@ -187,7 +187,7 @@ "subscription_section", "from_date", "to_date", - "column_break_140", + "auto_repeat_section", "auto_repeat", "update_auto_repeat_reference", "against_income_account" @@ -1462,7 +1462,7 @@ { "fieldname": "subscription_section", "fieldtype": "Section Break", - "label": "Subscription Section" + "label": "Subscription" }, { "allow_on_submit": 1, @@ -1480,10 +1480,6 @@ "no_copy": 1, "print_hide": 1 }, - { - "fieldname": "column_break_140", - "fieldtype": "Column Break" - }, { "allow_on_submit": 1, "fieldname": "auto_repeat", @@ -1619,12 +1615,17 @@ { "fieldname": "column_break_bhao", "fieldtype": "Column Break" + }, + { + "fieldname": "auto_repeat_section", + "fieldtype": "Section Break", + "label": "Auto Repeat" } ], "icon": "fa fa-file-text", "is_submittable": 1, "links": [], - "modified": "2026-02-10 14:23:07.181782", + "modified": "2026-03-02 07:32:47.667810", "modified_by": "Administrator", "module": "Accounts", "name": "POS Invoice", diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json index d2021e0f9a4..b5b99131383 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -181,11 +181,12 @@ "unrealized_profit_loss_account", "subscription_section", "subscription", - "auto_repeat", - "update_auto_repeat_reference", "column_break_114", "from_date", "to_date", + "automation_section", + "auto_repeat", + "update_auto_repeat_reference", "printing_settings", "letter_head", "group_same_items", @@ -1686,6 +1687,12 @@ "fieldname": "totals_section", "fieldtype": "Section Break", "label": "Totals" + }, + { + "collapsible": 1, + "fieldname": "automation_section", + "fieldtype": "Section Break", + "label": "Automation" } ], "grid_page_length": 50, diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json index a76568eab2e..8c2ad3adc09 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -214,10 +214,11 @@ "language", "subscription_section", "subscription", - "from_date", - "auto_repeat", "column_break_140", + "from_date", "to_date", + "automation_section", + "auto_repeat", "update_auto_repeat_reference", "utm_analytics_section", "utm_source", @@ -2321,6 +2322,12 @@ { "fieldname": "column_break_rdks", "fieldtype": "Column Break" + }, + { + "collapsible": 1, + "fieldname": "automation_section", + "fieldtype": "Section Break", + "label": "Automation" } ], "grid_page_length": 50, diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.json b/erpnext/buying/doctype/purchase_order/purchase_order.json index d5b2beea6f6..5c791467458 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.json +++ b/erpnext/buying/doctype/purchase_order/purchase_order.json @@ -148,7 +148,7 @@ "column_break_86", "select_print_heading", "language", - "subscription_section", + "auto_repeat_section", "from_date", "to_date", "column_break_97", @@ -1025,12 +1025,6 @@ "label": "Print Language", "print_hide": 1 }, - { - "collapsible": 1, - "fieldname": "subscription_section", - "fieldtype": "Section Break", - "label": "Auto Repeat" - }, { "allow_on_submit": 1, "fieldname": "from_date", @@ -1321,6 +1315,12 @@ "fieldtype": "Time", "label": "Time", "mandatory_depends_on": "is_internal_supplier" + }, + { + "collapsible": 1, + "fieldname": "auto_repeat_section", + "fieldtype": "Section Break", + "label": "Auto Repeat" } ], "grid_page_length": 50, diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json index 1328d8aebdc..bb1c048301e 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json @@ -111,7 +111,7 @@ "column_break_85", "select_print_heading", "language", - "subscription_section", + "auto_repeat_section", "auto_repeat", "update_auto_repeat_reference", "more_info", @@ -736,11 +736,6 @@ "print_hide": 1, "read_only": 1 }, - { - "fieldname": "subscription_section", - "fieldtype": "Section Break", - "label": "Auto Repeat" - }, { "fieldname": "auto_repeat", "fieldtype": "Link", @@ -940,6 +935,11 @@ "no_copy": 1, "options": "Item Wise Tax Detail", "print_hide": 1 + }, + { + "fieldname": "auto_repeat_section", + "fieldtype": "Section Break", + "label": "Auto Repeat" } ], "grid_page_length": 50, @@ -948,7 +948,7 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2026-01-29 21:23:13.778468", + "modified": "2026-02-27 18:05:50.121391", "modified_by": "Administrator", "module": "Buying", "name": "Supplier Quotation", diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 12bbf689b37..93463f49d16 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -590,6 +590,8 @@ accounting_dimension_doctypes = [ "Advance Taxes and Charges", ] +subscription_doctypes = ["Sales Invoice", "Purchase Invoice", "Payment Request", "POS Invoice"] + get_matching_queries = ( "erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool.get_matching_queries" ) diff --git a/erpnext/selling/doctype/quotation/quotation.json b/erpnext/selling/doctype/quotation/quotation.json index 9bb4e599691..a791c7f4538 100644 --- a/erpnext/selling/doctype/quotation/quotation.json +++ b/erpnext/selling/doctype/quotation/quotation.json @@ -111,7 +111,7 @@ "tc_name", "terms", "more_info_tab", - "subscription_section", + "auto_repeat_section", "auto_repeat", "update_auto_repeat_reference", "print_settings", @@ -813,11 +813,6 @@ "print_hide": 1, "read_only": 1 }, - { - "fieldname": "subscription_section", - "fieldtype": "Section Break", - "label": "Auto Repeat" - }, { "fieldname": "auto_repeat", "fieldtype": "Link", @@ -1130,6 +1125,11 @@ "fieldname": "utm_analytics_section", "fieldtype": "Section Break", "label": "UTM Analytics" + }, + { + "fieldname": "auto_repeat_section", + "fieldtype": "Section Break", + "label": "Auto Repeat" } ], "icon": "fa fa-shopping-cart", diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json index 87816741728..3109fd0e36e 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.json +++ b/erpnext/selling/doctype/sales_order/sales_order.json @@ -151,7 +151,7 @@ "loyalty_points", "column_break_116", "loyalty_amount", - "subscription_section", + "auto_repeat_section", "from_date", "to_date", "column_break_108", @@ -1372,18 +1372,6 @@ "options": "Sales Team", "print_hide": 1 }, - { - "allow_on_submit": 1, - "collapsible": 1, - "fieldname": "subscription_section", - "fieldtype": "Section Break", - "hide_days": 1, - "hide_seconds": 1, - "label": "Auto Repeat", - "no_copy": 1, - "print_hide": 1, - "read_only": 1 - }, { "allow_on_submit": 1, "fieldname": "from_date", @@ -1742,6 +1730,18 @@ "hidden": 1, "label": "Ignore Default Payment Terms Template", "read_only": 1 + }, + { + "allow_on_submit": 1, + "collapsible": 1, + "fieldname": "auto_repeat_section", + "fieldtype": "Section Break", + "hide_days": 1, + "hide_seconds": 1, + "label": "Auto Repeat", + "no_copy": 1, + "print_hide": 1, + "read_only": 1 } ], "grid_page_length": 50, diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.json b/erpnext/stock/doctype/delivery_note/delivery_note.json index af777527133..f110e0fe32c 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.json +++ b/erpnext/stock/doctype/delivery_note/delivery_note.json @@ -147,7 +147,7 @@ "total_commission", "section_break1", "sales_team", - "subscription_section", + "auto_repeat_section", "auto_repeat", "printing_details", "letter_head", @@ -1115,11 +1115,6 @@ "oldfieldname": "instructions", "oldfieldtype": "Text" }, - { - "fieldname": "subscription_section", - "fieldtype": "Section Break", - "label": "Subscription Section" - }, { "fieldname": "auto_repeat", "fieldtype": "Link", @@ -1450,6 +1445,11 @@ { "fieldname": "column_break_ydwe", "fieldtype": "Column Break" + }, + { + "fieldname": "auto_repeat_section", + "fieldtype": "Section Break", + "label": "Auto Repeat" } ], "icon": "fa fa-truck",