Merge branch 'develop' of https://github.com/frappe/erpnext into show_address_in_online_pos
diff --git a/README.md b/README.md
index 74ea7fc..3d11089 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,10 @@
-# ERPNext - ERP made simple
+<div align="center">
+ <img src="https://github.com/frappe/design/blob/master/logos/erpnext-logo.svg" height="128">
+ <h2>ERPNext</h2>
+ <p align="center">
+ <p>ERP made simple</p>
+ </p>
+</div>
[](https://travis-ci.org/frappe/erpnext) [](https://gitter.im/frappe/erpnext?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py
index d065b09..fb3182e 100644
--- a/erpnext/stock/doctype/item/test_item.py
+++ b/erpnext/stock/doctype/item/test_item.py
@@ -80,7 +80,6 @@
}
make_test_objects("Item Price")
- print(frappe.get_all("Item Price"))
details = get_item_details({
"item_code": "_Test Item",
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 80afd49..7560e8a 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -274,14 +274,15 @@
self.set_actual_qty()
self.calculate_rate_and_amount()
- def calculate_rate_and_amount(self, force=False, update_finished_item_rate=True):
+ def calculate_rate_and_amount(self, force=False,
+ update_finished_item_rate=True, raise_error_if_no_rate=True):
self.set_basic_rate(force, update_finished_item_rate)
self.distribute_additional_costs()
self.update_valuation_rate()
self.set_total_incoming_outgoing_value()
self.set_total_amount()
- def set_basic_rate(self, force=False, update_finished_item_rate=True):
+ def set_basic_rate(self, force=False, update_finished_item_rate=True, raise_error_if_no_rate=True):
"""get stock and incoming rate on posting date"""
raw_material_cost = 0.0
scrap_material_cost = 0.0
@@ -294,7 +295,7 @@
# get basic rate
if not d.bom_no:
if (not flt(d.basic_rate) and not d.allow_zero_valuation_rate) or d.s_warehouse or force:
- basic_rate = flt(get_incoming_rate(args), self.precision("basic_rate", d))
+ basic_rate = flt(get_incoming_rate(args, raise_error_if_no_rate), self.precision("basic_rate", d))
if basic_rate > 0:
d.basic_rate = basic_rate
@@ -306,7 +307,8 @@
if d.bom_no:
if not flt(d.basic_rate) and not d.allow_zero_valuation_rate and \
getattr(self, "pro_doc", frappe._dict()).scrap_warehouse == d.t_warehouse:
- basic_rate = flt(get_incoming_rate(args), self.precision("basic_rate", d))
+ basic_rate = flt(get_incoming_rate(args, raise_error_if_no_rate),
+ self.precision("basic_rate", d))
if basic_rate > 0:
d.basic_rate = basic_rate
d.basic_amount = flt(flt(d.transfer_qty) * flt(d.basic_rate), d.precision("basic_amount"))
@@ -600,7 +602,8 @@
if self.pro_doc and not self.pro_doc.skip_transfer:
item["from_warehouse"] = self.pro_doc.wip_warehouse
#Get Reserve Warehouse from PO
- item["from_warehouse"] = item_wh.get(item.item_code) if self.purchase_order and self.purpose=="Subcontract" else ""
+ if self.purchase_order and self.purpose=="Subcontract":
+ item["from_warehouse"] = item_wh.get(item.item_code)
item["to_warehouse"] = self.to_warehouse if self.purpose=="Subcontract" else ""
self.add_to_stock_entry_detail(item_dict)
@@ -622,7 +625,7 @@
self.load_items_from_bom()
self.set_actual_qty()
- self.calculate_rate_and_amount()
+ self.calculate_rate_and_amount(raise_error_if_no_rate=False)
def set_production_order_details(self):
if not getattr(self, "pro_doc", None):
diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
index b590822..b2f85d0 100644
--- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
@@ -557,12 +557,13 @@
production_order.submit()
make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=50, basic_rate=100)
+ make_stock_entry(item_code="_Test Item 2", target="_Test Warehouse - _TC", qty=50, basic_rate=20)
stock_entry = _make_stock_entry(production_order.name, "Manufacture", 1)
rm_cost = 0
for d in stock_entry.get("items"):
- if d.s_warehouse:
+ if d.item_code != "_Test FG Item 2":
rm_cost += flt(d.amount)
fg_cost = filter(lambda x: x.item_code=="_Test FG Item 2", stock_entry.get("items"))[0].amount
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index 647c9fa..b5a2d78 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -430,7 +430,7 @@
}, previous_sle, as_dict=1, debug=debug)
def get_valuation_rate(item_code, warehouse, voucher_type, voucher_no,
- allow_zero_rate=False, currency=None, company=None):
+ allow_zero_rate=False, currency=None, company=None, raise_error_if_no_rate=True):
# Get valuation rate from last sle for the same item and warehouse
if not company:
company = erpnext.get_default_company()
@@ -465,7 +465,7 @@
dict(item_code=item_code, buying=1, currency=currency),
'price_list_rate')
- if not allow_zero_rate and not valuation_rate \
+ if not allow_zero_rate and not valuation_rate and raise_error_if_no_rate \
and cint(erpnext.is_perpetual_inventory_enabled(company)):
frappe.local.message_log = []
frappe.throw(_("Valuation rate not found for the Item {0}, which is required to do accounting entries for {1} {2}. If the item is transacting as a zero valuation rate item in the {1}, please mention that in the {1} Item table. Otherwise, please create an incoming stock transaction for the item or mention valuation rate in the Item record, and then try submiting/cancelling this entry").format(item_code, voucher_type, voucher_no))
diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py
index 9b2fcb7..49d0ec6 100644
--- a/erpnext/stock/utils.py
+++ b/erpnext/stock/utils.py
@@ -123,7 +123,7 @@
frappe.msgprint(_("Item {0} ignored since it is not a stock item").format(args.get("item_code")))
@frappe.whitelist()
-def get_incoming_rate(args):
+def get_incoming_rate(args, raise_error_if_no_rate=True):
"""Get Incoming Rate based on valuation method"""
from erpnext.stock.stock_ledger import get_previous_sle, get_valuation_rate
if isinstance(args, basestring):
@@ -146,7 +146,8 @@
voucher_no = args.get('voucher_no') or args.get('name')
in_rate = get_valuation_rate(args.get('item_code'), args.get('warehouse'),
args.get('voucher_type'), voucher_no, args.get('allow_zero_valuation'),
- currency=erpnext.get_company_currency(args.get('company')), company=args.get('company'))
+ currency=erpnext.get_company_currency(args.get('company')), company=args.get('company'),
+ raise_error_if_no_rate=True)
return in_rate