From e3ae8d5a1e6bc1251feae63f51215e9ce3c2365a Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Wed, 20 Oct 2021 22:10:21 +0530 Subject: [PATCH 1/3] fix: Move PAN field from standard doctype to fixtures for India --- erpnext/buying/doctype/supplier/supplier.json | 9 ++----- erpnext/patches.txt | 1 + .../v13_0/create_pan_field_for_india.py | 25 +++++++++++++++++++ erpnext/regional/india/setup.py | 16 ++++++++++-- .../selling/doctype/customer/customer.json | 12 +++------ 5 files changed, 45 insertions(+), 18 deletions(-) create mode 100644 erpnext/patches/v13_0/create_pan_field_for_india.py diff --git a/erpnext/buying/doctype/supplier/supplier.json b/erpnext/buying/doctype/supplier/supplier.json index 12a09cdd0ec..a57d9a92bb3 100644 --- a/erpnext/buying/doctype/supplier/supplier.json +++ b/erpnext/buying/doctype/supplier/supplier.json @@ -25,7 +25,6 @@ "column_break0", "supplier_group", "supplier_type", - "pan", "allow_purchase_invoice_creation_without_purchase_order", "allow_purchase_invoice_creation_without_purchase_receipt", "disabled", @@ -176,11 +175,6 @@ "options": "Company\nIndividual", "reqd": 1 }, - { - "fieldname": "pan", - "fieldtype": "Data", - "label": "PAN" - }, { "fieldname": "language", "fieldtype": "Link", @@ -438,11 +432,12 @@ "link_fieldname": "party" } ], - "modified": "2021-09-06 17:37:56.522233", + "modified": "2021-10-20 22:03:33.147249", "modified_by": "Administrator", "module": "Buying", "name": "Supplier", "name_case": "Title Case", + "naming_rule": "By \"Naming Series\" field", "owner": "Administrator", "permissions": [ { diff --git a/erpnext/patches.txt b/erpnext/patches.txt index e446d6be42f..9bcab5e74a3 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -310,3 +310,4 @@ erpnext.patches.v13_0.enable_scheduler_job_for_item_reposting erpnext.patches.v13_0.requeue_failed_reposts erpnext.patches.v13_0.healthcare_deprecation_warning erpnext.patches.v14_0.delete_healthcare_doctypes +erpnext.patches.v13_0.create_pan_field_for_india diff --git a/erpnext/patches/v13_0/create_pan_field_for_india.py b/erpnext/patches/v13_0/create_pan_field_for_india.py new file mode 100644 index 00000000000..e94a9d93b3b --- /dev/null +++ b/erpnext/patches/v13_0/create_pan_field_for_india.py @@ -0,0 +1,25 @@ +import frappe +from frappe.custom.doctype.custom_field.custom_field import create_custom_fields + + +def execute(): + custom_fields = { + 'Supplier': [ + { + 'fieldname': 'pan', + 'label': 'PAN', + 'fieldtype': 'Data', + 'insert_after': 'supplier_type' + } + ], + 'Customer': [ + { + 'fieldname': 'pan', + 'label': 'PAN', + 'fieldtype': 'Data', + 'insert_after': 'customer_type' + } + ] + } + + create_custom_fields(custom_fields, update=True) diff --git a/erpnext/regional/india/setup.py b/erpnext/regional/india/setup.py index afb1b07ccc4..1cbb154125f 100644 --- a/erpnext/regional/india/setup.py +++ b/erpnext/regional/india/setup.py @@ -614,11 +614,17 @@ def get_custom_fields(): fieldtype='Currency', insert_after='monthly_hra_exemption', read_only=1, depends_on='house_rent_payment_amount') ], 'Supplier': [ + { + 'fieldname': 'pan', + 'label': 'PAN', + 'fieldtype': 'Data', + 'insert_after': 'supplier_type' + }, { 'fieldname': 'gst_transporter_id', 'label': 'GST Transporter ID', 'fieldtype': 'Data', - 'insert_after': 'supplier_type', + 'insert_after': 'pan', 'depends_on': 'eval:doc.is_transporter' }, { @@ -640,11 +646,17 @@ def get_custom_fields(): } ], 'Customer': [ + { + 'fieldname': 'pan', + 'label': 'PAN', + 'fieldtype': 'Data', + 'insert_after': 'customer_type' + }, { 'fieldname': 'gst_category', 'label': 'GST Category', 'fieldtype': 'Select', - 'insert_after': 'customer_type', + 'insert_after': 'pan', 'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders', 'default': 'Unregistered' }, diff --git a/erpnext/selling/doctype/customer/customer.json b/erpnext/selling/doctype/customer/customer.json index e811435e669..fa6e932d9eb 100644 --- a/erpnext/selling/doctype/customer/customer.json +++ b/erpnext/selling/doctype/customer/customer.json @@ -16,7 +16,6 @@ "customer_name", "gender", "customer_type", - "pan", "tax_withholding_category", "default_bank_account", "lead_name", @@ -213,8 +212,7 @@ "fieldtype": "Link", "ignore_user_permissions": 1, "label": "Represents Company", - "options": "Company", - "unique": 1 + "options": "Company" }, { "depends_on": "represents_company", @@ -486,11 +484,6 @@ "fieldtype": "Check", "label": "Allow Sales Invoice Creation Without Delivery Note" }, - { - "fieldname": "pan", - "fieldtype": "Data", - "label": "PAN" - }, { "fieldname": "tax_withholding_category", "fieldtype": "Link", @@ -517,11 +510,12 @@ "link_fieldname": "party" } ], - "modified": "2021-09-06 17:38:54.196663", + "modified": "2021-10-20 22:07:52.485809", "modified_by": "Administrator", "module": "Selling", "name": "Customer", "name_case": "Title Case", + "naming_rule": "By \"Naming Series\" field", "owner": "Administrator", "permissions": [ { From cd4b20313e69affe3a5074a0c514f1a96ece0f6f Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 25 Oct 2021 11:21:55 +0530 Subject: [PATCH 2/3] fix: Test case fixes and linting issues --- erpnext/patches/v13_0/create_pan_field_for_india.py | 1 - erpnext/regional/india/utils.py | 2 +- erpnext/selling/doctype/customer/customer.json | 3 ++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/patches/v13_0/create_pan_field_for_india.py b/erpnext/patches/v13_0/create_pan_field_for_india.py index e94a9d93b3b..01d4305bc4e 100644 --- a/erpnext/patches/v13_0/create_pan_field_for_india.py +++ b/erpnext/patches/v13_0/create_pan_field_for_india.py @@ -1,4 +1,3 @@ -import frappe from frappe.custom.doctype.custom_field.custom_field import create_custom_fields diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py index 0e4128024d3..1733220c0ac 100644 --- a/erpnext/regional/india/utils.py +++ b/erpnext/regional/india/utils.py @@ -62,7 +62,7 @@ def validate_gstin_for_india(doc, method): .format(doc.gst_state_number), title=_("Invalid GSTIN")) def validate_pan_for_india(doc, method): - if doc.get('country') != 'India' or not doc.pan: + if doc.get('country') != 'India' or not doc.get('pan'): return if not PAN_NUMBER_FORMAT.match(doc.pan): diff --git a/erpnext/selling/doctype/customer/customer.json b/erpnext/selling/doctype/customer/customer.json index fa6e932d9eb..ae406306170 100644 --- a/erpnext/selling/doctype/customer/customer.json +++ b/erpnext/selling/doctype/customer/customer.json @@ -212,7 +212,8 @@ "fieldtype": "Link", "ignore_user_permissions": 1, "label": "Represents Company", - "options": "Company" + "options": "Company", + "unique": 1 }, { "depends_on": "represents_company", From 89d5e494ddbe82912a65400ebf7f7b4ff565a8b0 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Tue, 26 Oct 2021 19:51:03 +0530 Subject: [PATCH 3/3] fix: Reload customer and supplier doctype --- erpnext/patches.txt | 2 +- erpnext/patches/v13_0/create_pan_field_for_india.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 9bcab5e74a3..20e54e08e6e 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -310,4 +310,4 @@ erpnext.patches.v13_0.enable_scheduler_job_for_item_reposting erpnext.patches.v13_0.requeue_failed_reposts erpnext.patches.v13_0.healthcare_deprecation_warning erpnext.patches.v14_0.delete_healthcare_doctypes -erpnext.patches.v13_0.create_pan_field_for_india +erpnext.patches.v13_0.create_pan_field_for_india #2 diff --git a/erpnext/patches/v13_0/create_pan_field_for_india.py b/erpnext/patches/v13_0/create_pan_field_for_india.py index 01d4305bc4e..c37651aaa3b 100644 --- a/erpnext/patches/v13_0/create_pan_field_for_india.py +++ b/erpnext/patches/v13_0/create_pan_field_for_india.py @@ -1,7 +1,11 @@ +import frappe from frappe.custom.doctype.custom_field.custom_field import create_custom_fields def execute(): + frappe.reload_doc('buying', 'doctype', 'supplier', force=True) + frappe.reload_doc('selling', 'doctype', 'customer', force=True) + custom_fields = { 'Supplier': [ {