[minor] minor fixes in pricing_rule and set_missing_value

This commit is contained in:
mbauskar 2017-04-18 10:20:40 +05:30 committed by Nabin Hait
parent 9e9d242a24
commit 8f3cc81302
3 changed files with 6 additions and 6 deletions

View File

@ -23,6 +23,8 @@ class PricingRule(Document):
self.validate_price_or_discount() self.validate_price_or_discount()
self.validate_max_discount() self.validate_max_discount()
if not self.margin_type: self.margin_rate_or_amount = 0.0
def validate_mandatory(self): def validate_mandatory(self):
for field in ["apply_on", "applicable_for"]: for field in ["apply_on", "applicable_for"]:
tocheck = frappe.scrub(self.get(field) or "") tocheck = frappe.scrub(self.get(field) or "")
@ -143,7 +145,7 @@ def get_pricing_rule_for_item(args):
}) })
if args.ignore_pricing_rule or not args.item_code: 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) item_details = remove_pricing_rule(args, item_details)
return item_details return item_details

View File

@ -199,8 +199,7 @@ class AccountsController(TransactionBase):
if stock_qty != len(item.get('serial_no').split('\n')): if stock_qty != len(item.get('serial_no').split('\n')):
item.set(fieldname, value) item.set(fieldname, value)
elif fieldname in ["conversion_factor", "price_list_rate"]: elif fieldname == "conversion_factor" and not item.get("conversion_factor"):
if for_validate and not item.get(fieldname):
item.set(fieldname, value) item.set(fieldname, value)
if ret.get("pricing_rule"): if ret.get("pricing_rule"):

View File

@ -570,7 +570,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
item.stock_qty = flt(item.qty * item.conversion_factor, precision("stock_qty", item)); item.stock_qty = flt(item.qty * item.conversion_factor, precision("stock_qty", item));
refresh_field("stock_qty", item.name, item.parentfield); refresh_field("stock_qty", item.name, item.parentfield);
this.toggle_conversion_factor(item); this.toggle_conversion_factor(item);
this.apply_price_list(); this.apply_price_list(item, true);
} }
}, },
@ -581,7 +581,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
}, },
qty: function(doc, cdt, cdn) { qty: function(doc, cdt, cdn) {
this.apply_pricing_rule(frappe.get_doc(cdt, cdn), true);
this.conversion_factor(doc, cdt, cdn); this.conversion_factor(doc, cdt, cdn);
}, },