[minor] calculate price list rate based on items uom
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index ecbf59d..bcdfe5f 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -186,7 +186,6 @@
ret = get_item_details(args)
-
for fieldname, value in ret.items():
if item.meta.get_field(fieldname) and value is not None:
if (item.get(fieldname) is None or fieldname in force_item_fields):
@@ -200,6 +199,10 @@
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)
+
if ret.get("pricing_rule"):
# if user changed the discount percentage then set user's discount percentage ?
item.set("discount_percentage", ret.get("discount_percentage"))
diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py
index af51f70..91f57f5 100644
--- a/erpnext/controllers/selling_controller.py
+++ b/erpnext/controllers/selling_controller.py
@@ -41,7 +41,7 @@
# set contact and address details for customer, if they are not mentioned
self.set_missing_lead_customer_details()
- self.set_price_list_and_item_details()
+ self.set_price_list_and_item_details(for_validate)
def set_missing_lead_customer_details(self):
if getattr(self, "customer", None):
@@ -60,9 +60,9 @@
posting_date=self.get('transaction_date') or self.get('posting_date'),
company=self.company))
- def set_price_list_and_item_details(self):
+ def set_price_list_and_item_details(self, for_validate):
self.set_price_list_currency("Selling")
- self.set_missing_item_details()
+ self.set_missing_item_details(for_validate=for_validate)
def apply_shipping_rule(self):
if self.shipping_rule:
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index 0355c26..362d075 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -60,6 +60,7 @@
if item.doctype in ['Quotation Item', 'Sales Order Item', 'Delivery Note Item', 'Sales Invoice Item']:
item.total_margin = self.calculate_margin(item)
+
item.rate = flt(item.total_margin * (1.0 - (item.discount_percentage / 100.0)), item.precision("rate"))\
if item.total_margin > 0 else item.rate