[minor] minor fixes in pricing_rule and set_missing_value
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
index 3f8018f..5af0d9f 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
@@ -23,6 +23,8 @@
self.validate_price_or_discount()
self.validate_max_discount()
+ if not self.margin_type: self.margin_rate_or_amount = 0.0
+
def validate_mandatory(self):
for field in ["apply_on", "applicable_for"]:
tocheck = frappe.scrub(self.get(field) or "")
@@ -143,7 +145,7 @@
})
if args.ignore_pricing_rule or not args.item_code:
- if frappe.db.exists(args.doctype, args.name) or args.get("pricing_rule"):
+ if args.get("pricing_rule"):
item_details = remove_pricing_rule(args, item_details)
return item_details
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index bcdfe5f..742e59b 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -199,9 +199,8 @@
if stock_qty != len(item.get('serial_no').split('\n')):
item.set(fieldname, value)
- elif fieldname in ["conversion_factor", "price_list_rate"]:
- if for_validate and not item.get(fieldname):
- item.set(fieldname, value)
+ elif fieldname == "conversion_factor" and not item.get("conversion_factor"):
+ item.set(fieldname, value)
if ret.get("pricing_rule"):
# if user changed the discount percentage then set user's discount percentage ?
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index d84a4fc..eec789a 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -570,7 +570,7 @@
item.stock_qty = flt(item.qty * item.conversion_factor, precision("stock_qty", item));
refresh_field("stock_qty", item.name, item.parentfield);
this.toggle_conversion_factor(item);
- this.apply_price_list();
+ this.apply_price_list(item, true);
}
},
@@ -581,7 +581,6 @@
},
qty: function(doc, cdt, cdn) {
- this.apply_pricing_rule(frappe.get_doc(cdt, cdn), true);
this.conversion_factor(doc, cdt, cdn);
},