It seems surprising that a feature available in version-11 is gone in version-12 as usual. There seems to be multiple issues with pricing rule based on Item Group.
- The javascript would not return the UOM for Item Groups which don’t have items in it. Since Item Group is a tree structure there is bound to be groups without items and with their descendants having items. Now the code in question here is as below, which only considers that the Item Groups should have items associated with them but fails to consider the parent child relation in a tree structure of Item Group.
@frappe.whitelist()
@frappe.validate_and_sanitize_search_inputs
def get_item_uoms(doctype, txt, searchfield, start, page_len, filters):
items = [filters.get('value')]
if filters.get('apply_on') != 'Item Code':
field = frappe.scrub(filters.get('apply_on'))
items = [d.name for d in frappe.db.get_all("Item", filters={field: filters.get('value')})]
return frappe.get_all('UOM Conversion Detail', filters={
'parent': ('in', items),
'uom': ("like", "{0}%".format(txt))
}, fields = ["distinct uom"], as_list=1)
- The second issue is that the application of the Pricing Rule based on Item Group does not consider the parent-child relationship and if we apply a pricing rule on parent group it should apply to the child group unless specified otherwise.
Anyone facing such issues on the pricing rule front since this feature was a very old feature of erpnext and with advent of v12 its gone.