test: create and cancel sr no with stock reco
This commit is contained in:
parent
203f0086f8
commit
4fa93e246e
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import add_days, flt, nowdate, nowtime, random_string
|
from frappe.utils import add_days, cstr, flt, nowdate, nowtime, random_string
|
||||||
|
|
||||||
from erpnext.accounts.utils import get_stock_and_account_balance
|
from erpnext.accounts.utils import get_stock_and_account_balance
|
||||||
from erpnext.stock.doctype.item.test_item import create_item
|
from erpnext.stock.doctype.item.test_item import create_item
|
||||||
@ -439,8 +439,8 @@ class TestStockReconciliation(ERPNextTestCase):
|
|||||||
self.assertRaises(frappe.ValidationError, sr.submit)
|
self.assertRaises(frappe.ValidationError, sr.submit)
|
||||||
|
|
||||||
def test_serial_no_cancellation(self):
|
def test_serial_no_cancellation(self):
|
||||||
|
|
||||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
|
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
|
||||||
|
|
||||||
item = create_item("Stock-Reco-Serial-Item-9", is_stock_item=1)
|
item = create_item("Stock-Reco-Serial-Item-9", is_stock_item=1)
|
||||||
if not item.has_serial_no:
|
if not item.has_serial_no:
|
||||||
item.has_serial_no = 1
|
item.has_serial_no = 1
|
||||||
@ -466,6 +466,31 @@ class TestStockReconciliation(ERPNextTestCase):
|
|||||||
self.assertEqual(len(active_sr_no), 10)
|
self.assertEqual(len(active_sr_no), 10)
|
||||||
|
|
||||||
|
|
||||||
|
def test_serial_no_creation_and_inactivation(self):
|
||||||
|
item = create_item("_TestItemCreatedWithStockReco", is_stock_item=1)
|
||||||
|
if not item.has_serial_no:
|
||||||
|
item.has_serial_no = 1
|
||||||
|
item.save()
|
||||||
|
|
||||||
|
item_code = item.name
|
||||||
|
warehouse = "_Test Warehouse - _TC"
|
||||||
|
|
||||||
|
sr = create_stock_reconciliation(item_code=item.name, warehouse=warehouse,
|
||||||
|
serial_no="SR-CREATED-SR-NO", qty=1, do_not_submit=True, rate=100)
|
||||||
|
sr.save()
|
||||||
|
self.assertEqual(cstr(sr.items[0].current_serial_no), "")
|
||||||
|
sr.submit()
|
||||||
|
|
||||||
|
active_sr_no = frappe.get_all("Serial No",
|
||||||
|
filters={"item_code": item_code, "warehouse": warehouse, "status": "Active"})
|
||||||
|
self.assertEqual(len(active_sr_no), 1)
|
||||||
|
|
||||||
|
sr.cancel()
|
||||||
|
active_sr_no = frappe.get_all("Serial No",
|
||||||
|
filters={"item_code": item_code, "warehouse": warehouse, "status": "Active"})
|
||||||
|
self.assertEqual(len(active_sr_no), 0)
|
||||||
|
|
||||||
|
|
||||||
def create_batch_item_with_batch(item_name, batch_id):
|
def create_batch_item_with_batch(item_name, batch_id):
|
||||||
batch_item_doc = create_item(item_name, is_stock_item=1)
|
batch_item_doc = create_item(item_name, is_stock_item=1)
|
||||||
if not batch_item_doc.has_batch_no:
|
if not batch_item_doc.has_batch_no:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user