[Enhancement] Sales and Purchase Default UOM (#10929)

Option for specifying an optional default Sales and Purchase UOM at the item master level.
This commit is contained in:
Javier Wong 2017-09-29 17:53:08 +08:00 committed by Rushabh Mehta
parent 5510d0751d
commit bf37995745
2 changed files with 74 additions and 2 deletions

View File

@ -1473,6 +1473,37 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"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,
@ -2069,6 +2100,37 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"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,
@ -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",

View File

@ -164,6 +164,16 @@ def get_basic_details(args, item):
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 @@ def get_basic_details(args, item):
"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,