From 7ba092eaf9e94e5e92bde4475e9ece9bbb19eb9c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 1 Feb 2018 10:51:27 +0530 Subject: [PATCH 1/2] Fixes for making stock entry against Pro Order (#12721) --- erpnext/stock/doctype/item/test_item.py | 1 - erpnext/stock/doctype/stock_entry/stock_entry.py | 15 +++++++++------ .../stock/doctype/stock_entry/test_stock_entry.py | 3 ++- erpnext/stock/stock_ledger.py | 4 ++-- erpnext/stock/utils.py | 5 +++-- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py index d065b09fb7..fb3182e5b4 100644 --- a/erpnext/stock/doctype/item/test_item.py +++ b/erpnext/stock/doctype/item/test_item.py @@ -80,7 +80,6 @@ class TestItem(unittest.TestCase): } 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 80afd49f5b..7560e8a2a6 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -274,14 +274,15 @@ class StockEntry(StockController): 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 @@ class StockEntry(StockController): # 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 @@ class StockEntry(StockController): 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 @@ class StockEntry(StockController): 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 @@ class StockEntry(StockController): 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 b590822973..b2f85d0a9e 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 @@ class TestStockEntry(unittest.TestCase): 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 647c9faf02..b5a2d78d3d 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -430,7 +430,7 @@ def get_stock_ledger_entries(previous_sle, operator=None, order="desc", limit=No }, 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 @@ def get_valuation_rate(item_code, warehouse, voucher_type, voucher_no, 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 9b2fcb7088..49d0ec672a 100644 --- a/erpnext/stock/utils.py +++ b/erpnext/stock/utils.py @@ -123,7 +123,7 @@ def update_bin(args, allow_negative_stock=False, via_landed_cost_voucher=False): 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 @@ def get_incoming_rate(args): 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 From 2afa8277a7682ce227e8eff84782ed5db439b08b Mon Sep 17 00:00:00 2001 From: Raghavendra Kamath Date: Thu, 1 Feb 2018 11:53:01 +0530 Subject: [PATCH 2/2] Update Readme to add new erpnext logo (#12728) --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 74ea7fc8a5..3d11089db5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,10 @@ -# ERPNext - ERP made simple +
+ +

ERPNext

+

+

ERP made simple

+

+
[![Build Status](https://travis-ci.org/frappe/erpnext.png)](https://travis-ci.org/frappe/erpnext) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/frappe/erpnext?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)