refactor: add category field to uom (backport #54290) (#54325)

* refactor: add category field to uom (#54290)

(cherry picked from commit e04a2e6da2)

# Conflicts:
#	erpnext/patches.txt

* chore: resolve conflicts

---------

Co-authored-by: Mihir Kandoi <kandoimihir@gmail.com>
This commit is contained in:
mergify[bot]
2026-04-16 10:16:28 +00:00
committed by GitHub
parent b487f69b59
commit ead7744f81
7 changed files with 547 additions and 249 deletions

View File

@@ -13,6 +13,7 @@
"common_code",
"description",
"column_break_obth",
"category",
"enabled",
"must_be_whole_number"
],
@@ -60,12 +61,21 @@
{
"fieldname": "column_break_obth",
"fieldtype": "Column Break"
},
{
"allow_in_quick_entry": 1,
"fieldname": "category",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Category",
"options": "UOM Category"
}
],
"icon": "fa fa-compass",
"idx": 1,
"links": [],
"modified": "2025-08-21 18:59:27.900209",
"modified": "2026-04-14 21:20:16.983514",
"modified_by": "Administrator",
"module": "Setup",
"name": "UOM",

View File

@@ -14,6 +14,7 @@ class UOM(Document):
if TYPE_CHECKING:
from frappe.types import DF
category: DF.Link | None
common_code: DF.Data | None
description: DF.SmallText | None
enabled: DF.Check

File diff suppressed because it is too large Load Diff

View File

@@ -390,6 +390,9 @@ def add_uom_data():
open(frappe.get_app_path("erpnext", "setup", "setup_wizard", "data", "uom_data.json")).read()
)
for d in uoms:
if d.get("category") and not frappe.db.exists("UOM Category", d.get("category")):
frappe.get_doc({"doctype": "UOM Category", "category_name": d.get("category")}).db_insert()
if not frappe.db.exists("UOM", d.get("uom_name")):
doc = frappe.new_doc("UOM")
doc.update(d)
@@ -402,9 +405,6 @@ def add_uom_data():
).read()
)
for d in uom_conversions:
if not frappe.db.exists("UOM Category", d.get("category")):
frappe.get_doc({"doctype": "UOM Category", "category_name": d.get("category")}).db_insert()
if not frappe.db.exists(
"UOM Conversion Factor",
{"from_uom": d.get("from_uom"), "to_uom": d.get("to_uom")},