Fixed negative stock validation message for translation and fixed test cases

This commit is contained in:
Nabin Hait 2016-12-16 15:30:43 +05:30
parent 9277f3250d
commit 3fe99559ef
2 changed files with 17 additions and 3 deletions

View File

@ -87,8 +87,9 @@ class StockController(AccountsController):
def validate_negative_stock(self, sle): def validate_negative_stock(self, sle):
if sle.qty_after_transaction < 0 and sle.actual_qty < 0: if sle.qty_after_transaction < 0 and sle.actual_qty < 0:
frappe.throw(_("For the Item {item}, valuation rate not found for warehouse {warehouse}. To be able to do accounting entries (for booking expenses), we need valuation rate for item {item}. Please create an incoming stock transaction, on or before {posting_date} {posting_time}, and then try submiting {current_document}").format(item=sle.item_code, warehouse=sle.warehouse, frappe.throw(_("For the Item {0}, valuation rate not found for warehouse {1}. To be able to do accounting entries (for booking expenses), we need valuation rate for item {2}. Please create an incoming stock transaction, on or before {3} {4}, and then try submiting {5}")
posting_date=sle.posting_date, posting_time=sle.posting_time, current_document=self.name)) .format(sle.item_code, sle.warehouse,
sle.item_code, sle.posting_date, sle.posting_time, self.name))
def get_voucher_details(self, default_expense_account, default_cost_center, sle_map): def get_voucher_details(self, default_expense_account, default_cost_center, sle_map):
if self.doctype == "Stock Reconciliation": if self.doctype == "Stock Reconciliation":

View File

@ -8,7 +8,7 @@ import unittest
from erpnext.stock.doctype.item.test_item import get_total_projected_qty from erpnext.stock.doctype.item.test_item import get_total_projected_qty
from erpnext.selling.doctype.sales_order.sales_order \ from erpnext.selling.doctype.sales_order.sales_order \
import make_material_request, make_delivery_note, make_sales_invoice, WarehouseRequired import make_material_request, make_delivery_note, make_sales_invoice, WarehouseRequired
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
from frappe.tests.test_permissions import set_user_permission_doctypes from frappe.tests.test_permissions import set_user_permission_doctypes
class TestSalesOrder(unittest.TestCase): class TestSalesOrder(unittest.TestCase):
@ -86,6 +86,7 @@ class TestSalesOrder(unittest.TestCase):
self.assertEquals(so.get("items")[0].delivered_qty, 9) self.assertEquals(so.get("items")[0].delivered_qty, 9)
def test_reserved_qty_for_partial_delivery(self): def test_reserved_qty_for_partial_delivery(self):
make_stock_entry(target="_Test Warehouse - _TC", qty=10, rate=100)
existing_reserved_qty = get_reserved_qty() existing_reserved_qty = get_reserved_qty()
so = make_sales_order() so = make_sales_order()
@ -113,6 +114,7 @@ class TestSalesOrder(unittest.TestCase):
self.assertEqual(get_reserved_qty(), existing_reserved_qty) self.assertEqual(get_reserved_qty(), existing_reserved_qty)
def test_reserved_qty_for_over_delivery(self): def test_reserved_qty_for_over_delivery(self):
make_stock_entry(target="_Test Warehouse - _TC", qty=10, rate=100)
# set over-delivery tolerance # set over-delivery tolerance
frappe.db.set_value('Item', "_Test Item", 'tolerance', 50) frappe.db.set_value('Item', "_Test Item", 'tolerance', 50)
@ -137,6 +139,8 @@ class TestSalesOrder(unittest.TestCase):
self.assertEqual(total_projected_qty, item_doc_after_cancel.total_projected_qty) self.assertEqual(total_projected_qty, item_doc_after_cancel.total_projected_qty)
def test_reserved_qty_for_over_delivery_via_sales_invoice(self): def test_reserved_qty_for_over_delivery_via_sales_invoice(self):
make_stock_entry(target="_Test Warehouse - _TC", qty=10, rate=100)
# set over-delivery tolerance # set over-delivery tolerance
frappe.db.set_value('Item', "_Test Item", 'tolerance', 50) frappe.db.set_value('Item', "_Test Item", 'tolerance', 50)
@ -172,6 +176,10 @@ class TestSalesOrder(unittest.TestCase):
self.assertEqual(so.per_delivered, 0) self.assertEqual(so.per_delivered, 0)
def test_reserved_qty_for_partial_delivery_with_packing_list(self): def test_reserved_qty_for_partial_delivery_with_packing_list(self):
make_stock_entry(target="_Test Warehouse - _TC", qty=10, rate=100)
make_stock_entry(item="_Test Item Home Desktop 100", target="_Test Warehouse - _TC", qty=10, rate=100)
existing_reserved_qty_item1 = get_reserved_qty("_Test Item") existing_reserved_qty_item1 = get_reserved_qty("_Test Item")
existing_reserved_qty_item2 = get_reserved_qty("_Test Item Home Desktop 100") existing_reserved_qty_item2 = get_reserved_qty("_Test Item Home Desktop 100")
@ -217,6 +225,9 @@ class TestSalesOrder(unittest.TestCase):
self.assertEqual(get_reserved_qty("_Test Item Home Desktop 100"), existing_reserved_qty_item2) self.assertEqual(get_reserved_qty("_Test Item Home Desktop 100"), existing_reserved_qty_item2)
def test_reserved_qty_for_over_delivery_with_packing_list(self): def test_reserved_qty_for_over_delivery_with_packing_list(self):
make_stock_entry(target="_Test Warehouse - _TC", qty=10, rate=100)
make_stock_entry(item="_Test Item Home Desktop 100", target="_Test Warehouse - _TC", qty=10, rate=100)
# set over-delivery tolerance # set over-delivery tolerance
frappe.db.set_value('Item', "_Test Product Bundle Item", 'tolerance', 50) frappe.db.set_value('Item', "_Test Product Bundle Item", 'tolerance', 50)
@ -351,6 +362,8 @@ class TestSalesOrder(unittest.TestCase):
from erpnext.stock.doctype.item.test_item import make_item from erpnext.stock.doctype.item.test_item import make_item
from erpnext.buying.doctype.purchase_order.purchase_order import update_status from erpnext.buying.doctype.purchase_order.purchase_order import update_status
make_stock_entry(target="_Test Warehouse - _TC", qty=10, rate=100)
po_item = make_item("_Test Item for Drop Shipping", {"is_stock_item": 1, "delivered_by_supplier": 1, po_item = make_item("_Test Item for Drop Shipping", {"is_stock_item": 1, "delivered_by_supplier": 1,
'default_supplier': '_Test Supplier', 'default_supplier': '_Test Supplier',
"expense_account": "_Test Account Cost for Goods Sold - _TC", "expense_account": "_Test Account Cost for Goods Sold - _TC",