mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 03:39:11 +00:00
[Serial No] Major updates, code cleanup, "In Store" is now "Available". Serial No can only be created via Stock Entry / Purchase Receipt. Serial No can be auto created using Series if mentioned in Item master
This commit is contained in:
@@ -181,7 +181,12 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
set_dynamic_labels: function() {
|
||||
this._super();
|
||||
this.hide_fields(this.frm.doc);
|
||||
},
|
||||
|
||||
entries_on_form_rendered: function(doc, grid_row) {
|
||||
erpnext.setup_serial_no(grid_row)
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// for backward compatibility: combine new and previous states
|
||||
|
||||
@@ -65,9 +65,6 @@ class DocType(SellingController):
|
||||
self.validate_write_off_account()
|
||||
|
||||
if cint(self.doc.update_stock):
|
||||
sl = get_obj('Stock Ledger')
|
||||
sl.validate_serial_no(self, 'entries')
|
||||
sl.validate_serial_no(self, 'packing_details')
|
||||
self.validate_item_code()
|
||||
self.update_current_stock()
|
||||
self.validate_delivery_note()
|
||||
@@ -84,15 +81,9 @@ class DocType(SellingController):
|
||||
"delivery_note_details")
|
||||
|
||||
def on_submit(self):
|
||||
if cint(self.doc.update_stock) == 1:
|
||||
sl_obj = get_obj("Stock Ledger")
|
||||
sl_obj.validate_serial_no_warehouse(self, 'entries')
|
||||
sl_obj.validate_serial_no_warehouse(self, 'packing_details')
|
||||
|
||||
sl_obj.update_serial_record(self, 'entries', is_submit = 1, is_incoming = 0)
|
||||
sl_obj.update_serial_record(self, 'packing_details', is_submit = 1, is_incoming = 0)
|
||||
|
||||
if cint(self.doc.update_stock) == 1:
|
||||
self.update_stock_ledger(update_stock=1)
|
||||
self.update_serial_nos()
|
||||
else:
|
||||
# Check for Approving Authority
|
||||
if not self.doc.recurring_id:
|
||||
@@ -120,11 +111,8 @@ class DocType(SellingController):
|
||||
|
||||
def on_cancel(self):
|
||||
if cint(self.doc.update_stock) == 1:
|
||||
sl = get_obj('Stock Ledger')
|
||||
sl.update_serial_record(self, 'entries', is_submit = 0, is_incoming = 0)
|
||||
sl.update_serial_record(self, 'packing_details', is_submit = 0, is_incoming = 0)
|
||||
|
||||
self.update_stock_ledger(update_stock = -1)
|
||||
self.update_serial_nos(cancel = True)
|
||||
|
||||
sales_com_obj = get_obj(dt = 'Sales Common')
|
||||
sales_com_obj.check_stop_sales_order(self)
|
||||
@@ -489,10 +477,6 @@ class DocType(SellingController):
|
||||
|
||||
def make_packing_list(self):
|
||||
get_obj('Sales Common').make_packing_list(self,'entries')
|
||||
sl = get_obj('Stock Ledger')
|
||||
sl.scrub_serial_nos(self)
|
||||
sl.scrub_serial_nos(self, 'packing_details')
|
||||
|
||||
|
||||
def on_update(self):
|
||||
if cint(self.doc.update_stock) == 1:
|
||||
|
||||
@@ -644,7 +644,61 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
count = no_of_months == 12 and 3 or 13
|
||||
for i in xrange(count):
|
||||
base_si = _test(i)
|
||||
|
||||
def test_serialized(self):
|
||||
from stock.doctype.stock_entry.test_stock_entry import make_serialized_item
|
||||
from stock.doctype.stock_ledger_entry.stock_ledger_entry import get_serial_nos
|
||||
|
||||
se = make_serialized_item()
|
||||
serial_nos = get_serial_nos(se.doclist[1].serial_no)
|
||||
|
||||
si = webnotes.bean(copy=test_records[0])
|
||||
si.doc.update_stock = 1
|
||||
si.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||
si.doclist[1].qty = 1
|
||||
si.doclist[1].serial_no = serial_nos[0]
|
||||
si.insert()
|
||||
si.submit()
|
||||
|
||||
self.assertEquals(webnotes.conn.get_value("Serial No", serial_nos[0], "status"), "Delivered")
|
||||
self.assertFalse(webnotes.conn.get_value("Serial No", serial_nos[0], "warehouse"))
|
||||
self.assertEquals(webnotes.conn.get_value("Serial No", serial_nos[0],
|
||||
"delivery_document_no"), si.doc.name)
|
||||
|
||||
return si
|
||||
|
||||
def test_serialized_cancel(self):
|
||||
from stock.doctype.stock_ledger_entry.stock_ledger_entry import get_serial_nos
|
||||
si = self.test_serialized()
|
||||
si.cancel()
|
||||
|
||||
serial_nos = get_serial_nos(si.doclist[1].serial_no)
|
||||
|
||||
self.assertEquals(webnotes.conn.get_value("Serial No", serial_nos[0], "status"), "Available")
|
||||
self.assertEquals(webnotes.conn.get_value("Serial No", serial_nos[0], "warehouse"), "_Test Warehouse - _TC")
|
||||
self.assertFalse(webnotes.conn.get_value("Serial No", serial_nos[0],
|
||||
"delivery_document_no"))
|
||||
|
||||
def test_serialize_status(self):
|
||||
from stock.doctype.stock_ledger_entry.stock_ledger_entry import SerialNoStatusError, get_serial_nos
|
||||
from stock.doctype.stock_entry.test_stock_entry import make_serialized_item
|
||||
|
||||
se = make_serialized_item()
|
||||
serial_nos = get_serial_nos(se.doclist[1].serial_no)
|
||||
|
||||
sr = webnotes.bean("Serial No", serial_nos[0])
|
||||
sr.doc.status = "Not Available"
|
||||
sr.save()
|
||||
|
||||
si = webnotes.bean(copy=test_records[0])
|
||||
si.doc.update_stock = 1
|
||||
si.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||
si.doclist[1].qty = 1
|
||||
si.doclist[1].serial_no = serial_nos[0]
|
||||
si.insert()
|
||||
|
||||
self.assertRaises(SerialNoStatusError, si.submit)
|
||||
|
||||
test_dependencies = ["Journal Voucher", "POS Setting", "Contact", "Address"]
|
||||
|
||||
test_records = [
|
||||
|
||||
Reference in New Issue
Block a user