fix: customer code max characters limit issue (#32177)
diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json
index 76cb31d..247140b 100644
--- a/erpnext/stock/doctype/item/item.json
+++ b/erpnext/stock/doctype/item/item.json
@@ -795,7 +795,7 @@
},
{
"fieldname": "customer_code",
- "fieldtype": "Data",
+ "fieldtype": "Small Text",
"hidden": 1,
"label": "Customer Code",
"no_copy": 1,
@@ -910,7 +910,7 @@
"image_field": "image",
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2022-06-15 09:02:06.177691",
+ "modified": "2022-09-12 15:00:10.130340",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item",
diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py
index 3366c73..89da721 100644
--- a/erpnext/stock/doctype/item/test_item.py
+++ b/erpnext/stock/doctype/item/test_item.py
@@ -778,6 +778,14 @@
item.has_batch_no = 1
item.save()
+ def test_customer_codes_length(self):
+ """Check if item code with special characters are allowed."""
+ item = make_item(properties={"item_code": "Test Item Code With Special Characters"})
+ for row in range(3):
+ item.append("customer_items", {"ref_code": frappe.generate_hash("", 120)})
+ item.save()
+ self.assertTrue(len(item.customer_code) > 140)
+
def set_item_variant_settings(fields):
doc = frappe.get_doc("Item Variant Settings")