mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-21 07:38:29 +00:00
refactor: add category field to uom (#54290)
This commit is contained in:
@@ -475,4 +475,5 @@ erpnext.patches.v16_0.co_by_product_patch
|
||||
erpnext.patches.v16_0.update_requested_qty_packed_item
|
||||
erpnext.patches.v16_0.remove_payables_receivables_workspace
|
||||
erpnext.patches.v16_0.depends_on_inv_dimensions
|
||||
erpnext.patches.v16_0.uom_category
|
||||
erpnext.patches.v16_0.merge_repost_settings_to_accounts_settings
|
||||
|
||||
11
erpnext/patches/v16_0/uom_category.py
Normal file
11
erpnext/patches/v16_0/uom_category.py
Normal file
@@ -0,0 +1,11 @@
|
||||
import json
|
||||
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
uom_data = json.loads(
|
||||
open(frappe.get_app_path("erpnext", "setup", "setup_wizard", "data", "uom_data.json")).read()
|
||||
)
|
||||
bulk_update_dict = {uom["uom_name"]: {"category": uom["category"]} for uom in uom_data}
|
||||
frappe.db.bulk_update("UOM", bulk_update_dict)
|
||||
@@ -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",
|
||||
|
||||
@@ -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
@@ -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")},
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
}
|
||||
],
|
||||
"links": [],
|
||||
"modified": "2024-03-27 13:10:57.525335",
|
||||
"modified": "2026-04-14 21:31:18.260962",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "UOM Category",
|
||||
@@ -34,14 +34,50 @@
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"role": "Item Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Stock Manager",
|
||||
"share": 1
|
||||
},
|
||||
{
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Stock User",
|
||||
"share": 1
|
||||
},
|
||||
{
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Sales User",
|
||||
"share": 1
|
||||
},
|
||||
{
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Sales Manager",
|
||||
"share": 1
|
||||
}
|
||||
],
|
||||
"quick_entry": 1,
|
||||
"row_format": "Dynamic",
|
||||
"sort_field": "creation",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"track_changes": 1
|
||||
}
|
||||
"states": []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user