From d41e7098bda8da839ca7031a7731491e58352fcf Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Fri, 20 Mar 2026 17:05:39 +0530 Subject: [PATCH] refactor(test): move tax category custom field creation to bootstrap (cherry picked from commit 4454af8efd57b702c328dd54806858e3a3375fec) --- .../test_tax_withholding_category.py | 16 -------------- erpnext/tests/utils.py | 21 +++++++++++++++++-- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py index 66dc090f7c7..bd633c94dc9 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py @@ -18,7 +18,6 @@ class TestTaxWithholdingCategory(ERPNextTestSuite): # create relevant supplier, etc create_records() create_tax_withholding_category_records() - make_pan_no_field() def validate_tax_withholding_entries(self, doctype, docname, expected_entries): """Validate tax withholding entries for a document""" @@ -3998,18 +3997,3 @@ def create_lower_deduction_certificate( "certificate_limit": limit, } ).insert() - - -def make_pan_no_field(): - pan_field = { - "Supplier": [ - { - "fieldname": "pan", - "label": "PAN", - "fieldtype": "Data", - "translatable": 0, - } - ] - } - - create_custom_fields(pan_field, update=1) diff --git a/erpnext/tests/utils.py b/erpnext/tests/utils.py index bfc0d5d89f6..b5c8e19f648 100644 --- a/erpnext/tests/utils.py +++ b/erpnext/tests/utils.py @@ -8,6 +8,7 @@ from typing import Any, NewType import frappe from frappe import _ from frappe.core.doctype.report.report import get_report_module_dotted_path +from frappe.custom.doctype.custom_field.custom_field import create_custom_fields from frappe.tests.utils import load_test_records_for from frappe.utils import now_datetime, today @@ -246,14 +247,16 @@ class BootStrapTestData: frappe.db.commit() # nosemgrep - # Dimensions # DDL commands have implicit commit + # Dimensions self.make_dimensions() # custom doctype - # DDL commands have implicit commit self.make_custom_doctype() + # custom field + self.make_custom_field() + def update_system_settings(self): system_settings = frappe.get_doc("System Settings") system_settings.time_zone = "Asia/Kolkata" @@ -2829,6 +2832,20 @@ class BootStrapTestData: ] self.make_records(["document_type"], records) + def make_custom_field(self): + pan_field = { + "Supplier": [ + { + "fieldname": "pan", + "label": "PAN", + "fieldtype": "Data", + "translatable": 0, + } + ] + } + + create_custom_fields(pan_field, update=1) + BootStrapTestData()