From c35271aef500a82d454498e9b76a59d3ad8a0673 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 10 Aug 2018 19:01:04 +0530 Subject: [PATCH] fix(various) --- .../accounts/doctype/pricing_rule/pricing_rule.py | 12 ++++++------ erpnext/controllers/selling_controller.py | 7 ++++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index 0979854920..a44ac00f5b 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -237,14 +237,14 @@ def remove_pricing_rules(item_list): def get_pricing_rules(args): def _get_tree_conditions(parenttype, allow_blank=True): field = frappe.scrub(parenttype) - if not frappe.flags.tree_conditions: - frappe.flags.tree_conditions = {} - key = (parenttype, args[field], ) - if key in frappe.flags.tree_conditions: - return frappe.flags.tree_conditions[key] - condition = "" if args.get(field): + if not frappe.flags.tree_conditions: + frappe.flags.tree_conditions = {} + key = (parenttype, args[field], ) + if key in frappe.flags.tree_conditions: + return frappe.flags.tree_conditions[key] + try: lft, rgt = frappe.db.get_value(parenttype, args[field], ["lft", "rgt"]) except TypeError: diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index b9efe53819..419afe1c72 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -139,10 +139,11 @@ class SellingController(StockController): def validate_max_discount(self): for d in self.get("items"): - discount = flt(frappe.get_cached_value("Item", d.item_code, "max_discount")) + if d.item_code: + discount = flt(frappe.get_cached_value("Item", d.item_code, "max_discount")) - if discount and flt(d.discount_percentage) > discount: - frappe.throw(_("Maximum discount for Item {0} is {1}%").format(d.item_code, discount)) + if discount and flt(d.discount_percentage) > discount: + frappe.throw(_("Maximum discount for Item {0} is {1}%").format(d.item_code, discount)) def set_qty_as_per_stock_uom(self): for d in self.get("items"):