From edc93ab6aae421bdec9bcb5dc1a385af169fc279 Mon Sep 17 00:00:00 2001 From: Maharshi Patel Date: Thu, 13 Oct 2022 12:00:30 +0530 Subject: [PATCH] fix: pricing rule item group uom Handle use case where pricing rule is applied on item group and user have selected UOM. pricing rule was applied on all UOM's even after specifying UOM. i have added condition in sql to fix this. --- erpnext/accounts/doctype/pricing_rule/utils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py index 1f29d732ba5..11ae540efa2 100644 --- a/erpnext/accounts/doctype/pricing_rule/utils.py +++ b/erpnext/accounts/doctype/pricing_rule/utils.py @@ -121,6 +121,12 @@ def _get_pricing_rules(apply_on, args, values): values["variant_of"] = args.variant_of elif apply_on_field == "item_group": item_conditions = _get_tree_conditions(args, "Item Group", child_doc, False) + if args.get("uom", None): + item_conditions += ( + " and ({child_doc}.uom='{item_uom}' or IFNULL({child_doc}.uom, '')='')".format( + child_doc=child_doc, item_uom=args.get("uom") + ) + ) conditions += get_other_conditions(conditions, values, args) warehouse_conditions = _get_tree_conditions(args, "Warehouse", "`tabPricing Rule`")