Merge branch 'master' into customer-login

This commit is contained in:
Anand Doshi
2013-09-04 15:10:17 +05:30
22 changed files with 259 additions and 27 deletions

View File

@@ -52,9 +52,7 @@ class DocType(StockController):
webnotes.throw(_("Item Code cannot be changed for Serial No."), SerialNoCannotCannotChangeError)
if not self.via_stock_ledger and warehouse != self.doc.warehouse:
webnotes.throw(_("Warehouse cannot be changed for Serial No."), SerialNoCannotCannotChangeError)
if not self.doc.warehouse and self.doc.status=="Available":
self.doc.status = "Not Available"
def validate_item(self):
"""

View File

@@ -343,10 +343,14 @@ class DocType(StockController):
def update_stock_ledger(self, is_cancelled=0):
self.values = []
for d in getlist(self.doclist, 'mtn_details'):
if cstr(d.s_warehouse):
if cstr(d.s_warehouse) and not is_cancelled:
self.add_to_values(d, cstr(d.s_warehouse), -flt(d.transfer_qty), is_cancelled)
if cstr(d.t_warehouse):
self.add_to_values(d, cstr(d.t_warehouse), flt(d.transfer_qty), is_cancelled)
if cstr(d.s_warehouse) and is_cancelled:
self.add_to_values(d, cstr(d.s_warehouse), -flt(d.transfer_qty), is_cancelled)
get_obj('Stock Ledger', 'Stock Ledger').update_stock(self.values,
self.doc.amended_from and 'Yes' or 'No')

View File

@@ -648,6 +648,9 @@ class TestStockEntry(unittest.TestCase):
self.assertTrue(webnotes.conn.exists("Serial No", "ABCD"))
self.assertTrue(webnotes.conn.exists("Serial No", "EFGH"))
se.cancel()
self.assertFalse(webnotes.conn.get_value("Serial No", "ABCD", "warehouse"))
def test_serial_no_not_exists(self):
se = webnotes.bean(copy=test_records[0])
se.doc.purpose = "Material Issue"
@@ -699,6 +702,9 @@ class TestStockEntry(unittest.TestCase):
se.insert()
se.submit()
self.assertTrue(webnotes.conn.get_value("Serial No", serial_no, "warehouse"), "_Test Warehouse 1 - _TC")
se.cancel()
self.assertTrue(webnotes.conn.get_value("Serial No", serial_no, "warehouse"), "_Test Warehouse - _TC")
def test_serial_warehouse_error(self):
make_serialized_item()
@@ -720,7 +726,6 @@ class TestStockEntry(unittest.TestCase):
serial_no = get_serial_nos(se.doclist[1].serial_no)[0]
self.assertFalse(webnotes.conn.get_value("Serial No", serial_no, "warehouse"))
self.assertTrue(webnotes.conn.get_value("Serial No", serial_no, "status"), "Not Available")
def make_serialized_item():
se = webnotes.bean(copy=test_records[0])

View File

@@ -119,13 +119,14 @@ class DocType(DocListController):
if self.doc.actual_qty < 0:
if sr.doc.warehouse!=self.doc.warehouse:
webnotes.throw(_("Warehouse does not belong to Item") + \
(": %s (%s)" % (self.doc.item_code, serial_no)), SerialNoWarehouseError)
webnotes.throw(_("Serial No") + ": " + serial_no +
_(" does not belong to Warehouse") + ": " + self.doc.warehouse,
SerialNoWarehouseError)
if self.doc.voucher_type in ("Delivery Note", "Sales Invoice") \
and sr.doc.status != "Available":
webnotes.throw(_("Serial No status must be 'Available' to Deliver") + \
": " + serial_no, SerialNoStatusError)
webnotes.throw(_("Serial No status must be 'Available' to Deliver")
+ ": " + serial_no, SerialNoStatusError)
sr.doc.warehouse = None