[Enhancement] Sales and Purchase Default UOM (#10929)
Option for specifying an optional default Sales and Purchase UOM at the item master level.
diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json
index b168631..525321c 100644
--- a/erpnext/stock/doctype/item/item.json
+++ b/erpnext/stock/doctype/item/item.json
@@ -1479,6 +1479,37 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "fieldname": "purchase_uom",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Default Purchase Unit of Measure",
+ "length": 0,
+ "no_copy": 0,
+ "options": "UOM",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
"default": "0.00",
"depends_on": "is_stock_item",
"description": "",
@@ -2075,6 +2106,37 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "fieldname": "sales_uom",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Default Sales Unit of Measure",
+ "length": 0,
+ "no_copy": 0,
+ "options": "UOM",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
"default": "0",
"description": "Publish Item to hub.erpnext.com",
"fieldname": "publish_in_hub",
@@ -3143,7 +3205,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 1,
- "modified": "2017-07-06 18:28:36.645217",
+ "modified": "2017-09-27 14:08:02.948326",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item",
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index 72a83c6..0b92c25 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -164,6 +164,16 @@
warehouse = user_default_warehouse or item.default_warehouse or args.warehouse
+ #Set the UOM to the Default Sales UOM or Default Purchase UOM if configured in the Item Master
+ if args.get('doctype') in ['Quotation', 'Sales Order', 'Delivery Note', 'Sales Invoice']:
+ uom = item.sales_uom if item.sales_uom else item.stock_uom
+ elif args.get('doctype') in ['Purchase Order', 'Purchase Receipt', 'Purchase Invoice']:
+ uom = item.purchase_uom if item.purchase_uom else item.stock_uom
+ else:
+ uom = item.stock_uom
+
+ args.uom = uom
+
out = frappe._dict({
"item_code": item.name,
"item_name": item.item_name,
@@ -178,7 +188,7 @@
"batch_no": None,
"item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in
item.get("taxes")))),
- "uom": item.stock_uom,
+ "uom": uom,
"min_order_qty": flt(item.min_order_qty) if args.doctype == "Material Request" else "",
"qty": args.qty or 1.0,
"stock_qty": args.qty or 1.0,