mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 18:59:08 +00:00
refactor(test): make stock reconciliation deterministic
This commit is contained in:
@@ -36,14 +36,16 @@ from erpnext.tests.utils import ERPNextTestSuite
|
|||||||
class TestStockReconciliation(ERPNextTestSuite, StockTestMixin):
|
class TestStockReconciliation(ERPNextTestSuite, StockTestMixin):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
create_batch_or_serial_no_items()
|
|
||||||
super().setUpClass()
|
super().setUpClass()
|
||||||
frappe.db.set_single_value("Stock Settings", "allow_negative_stock", 1)
|
|
||||||
|
|
||||||
def tearDown(self):
|
def setUp(self):
|
||||||
|
frappe.db.set_single_value("Stock Settings", "allow_negative_stock", 1)
|
||||||
frappe.local.future_sle = {}
|
frappe.local.future_sle = {}
|
||||||
frappe.flags.pop("dont_execute_stock_reposts", None)
|
frappe.flags.pop("dont_execute_stock_reposts", None)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
frappe.db.rollback()
|
||||||
|
|
||||||
def test_reco_for_fifo(self):
|
def test_reco_for_fifo(self):
|
||||||
self._test_reco_sle_gle("FIFO")
|
self._test_reco_sle_gle("FIFO")
|
||||||
|
|
||||||
@@ -525,8 +527,6 @@ class TestStockReconciliation(ERPNextTestSuite, StockTestMixin):
|
|||||||
"""
|
"""
|
||||||
from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note
|
from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note
|
||||||
|
|
||||||
frappe.db.rollback()
|
|
||||||
|
|
||||||
# repost will make this test useless, qty should update in realtime without reposts
|
# repost will make this test useless, qty should update in realtime without reposts
|
||||||
frappe.flags.dont_execute_stock_reposts = True
|
frappe.flags.dont_execute_stock_reposts = True
|
||||||
|
|
||||||
@@ -552,7 +552,6 @@ class TestStockReconciliation(ERPNextTestSuite, StockTestMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(old_bin_qty + 1, new_bin_qty)
|
self.assertEqual(old_bin_qty + 1, new_bin_qty)
|
||||||
frappe.db.rollback()
|
|
||||||
|
|
||||||
def test_valid_batch(self):
|
def test_valid_batch(self):
|
||||||
create_batch_item_with_batch("Testing Batch Item 1", "001")
|
create_batch_item_with_batch("Testing Batch Item 1", "001")
|
||||||
@@ -620,6 +619,7 @@ class TestStockReconciliation(ERPNextTestSuite, StockTestMixin):
|
|||||||
"doctype": "Serial No",
|
"doctype": "Serial No",
|
||||||
"item_code": item_code,
|
"item_code": item_code,
|
||||||
"serial_no": "SR-CREATED-SR-NO",
|
"serial_no": "SR-CREATED-SR-NO",
|
||||||
|
"company": self.companies[0].name,
|
||||||
}
|
}
|
||||||
).insert()
|
).insert()
|
||||||
|
|
||||||
@@ -1850,37 +1850,6 @@ def insert_existing_sle(warehouse, item_code="_Test Item"):
|
|||||||
return se1, se2, se3
|
return se1, se2, se3
|
||||||
|
|
||||||
|
|
||||||
def create_batch_or_serial_no_items():
|
|
||||||
create_warehouse(
|
|
||||||
"_Test Warehouse for Stock Reco1",
|
|
||||||
{"is_group": 0, "parent_warehouse": "_Test Warehouse Group - _TC"},
|
|
||||||
)
|
|
||||||
|
|
||||||
create_warehouse(
|
|
||||||
"_Test Warehouse for Stock Reco2",
|
|
||||||
{"is_group": 0, "parent_warehouse": "_Test Warehouse Group - _TC"},
|
|
||||||
)
|
|
||||||
|
|
||||||
serial_item_doc = create_item("Stock-Reco-Serial-Item-1", is_stock_item=1)
|
|
||||||
if not serial_item_doc.has_serial_no:
|
|
||||||
serial_item_doc.has_serial_no = 1
|
|
||||||
serial_item_doc.serial_no_series = "SRSI.####"
|
|
||||||
serial_item_doc.save(ignore_permissions=True)
|
|
||||||
|
|
||||||
serial_item_doc = create_item("Stock-Reco-Serial-Item-2", is_stock_item=1)
|
|
||||||
if not serial_item_doc.has_serial_no:
|
|
||||||
serial_item_doc.has_serial_no = 1
|
|
||||||
serial_item_doc.serial_no_series = "SRSII.####"
|
|
||||||
serial_item_doc.save(ignore_permissions=True)
|
|
||||||
|
|
||||||
batch_item_doc = create_item("Stock-Reco-batch-Item-1", is_stock_item=1)
|
|
||||||
if not batch_item_doc.has_batch_no:
|
|
||||||
batch_item_doc.has_batch_no = 1
|
|
||||||
batch_item_doc.create_new_batch = 1
|
|
||||||
serial_item_doc.batch_number_series = "BASR.#####"
|
|
||||||
batch_item_doc.save(ignore_permissions=True)
|
|
||||||
|
|
||||||
|
|
||||||
def create_stock_reconciliation(**args):
|
def create_stock_reconciliation(**args):
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
sr = frappe.new_doc("Stock Reconciliation")
|
sr = frappe.new_doc("Stock Reconciliation")
|
||||||
|
|||||||
@@ -1369,6 +1369,18 @@ class ERPNextTestSuite(unittest.TestCase):
|
|||||||
"is_group": 0,
|
"is_group": 0,
|
||||||
"parent_warehouse": "_Test Warehouse Group - _TC",
|
"parent_warehouse": "_Test Warehouse Group - _TC",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"company": "_Test Company",
|
||||||
|
"doctype": "Warehouse",
|
||||||
|
"warehouse_name": "_Test Warehouse for Stock Reco1",
|
||||||
|
"is_group": 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"company": "_Test Company",
|
||||||
|
"doctype": "Warehouse",
|
||||||
|
"warehouse_name": "_Test Warehouse for Stock Reco2",
|
||||||
|
"is_group": 0,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
cls.warehouse = []
|
cls.warehouse = []
|
||||||
for x in records:
|
for x in records:
|
||||||
@@ -2175,6 +2187,37 @@ class ERPNextTestSuite(unittest.TestCase):
|
|||||||
"is_stock_item": 1,
|
"is_stock_item": 1,
|
||||||
"stock_uom": "_Test UOM",
|
"stock_uom": "_Test UOM",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Item",
|
||||||
|
"item_code": "Stock-Reco-Serial-Item-1",
|
||||||
|
"item_name": "Stock-Reco-Serial-Item-1",
|
||||||
|
"is_stock_item": 1,
|
||||||
|
"item_group": "All Item Groups",
|
||||||
|
"stock_uom": "Nos",
|
||||||
|
"has_serial_no": 1,
|
||||||
|
"serial_no_series": "SRSI.#####",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Item",
|
||||||
|
"item_code": "Stock-Reco-Serial-Item-2",
|
||||||
|
"item_name": "Stock-Reco-Serial-Item-2",
|
||||||
|
"is_stock_item": 1,
|
||||||
|
"item_group": "All Item Groups",
|
||||||
|
"stock_uom": "Nos",
|
||||||
|
"has_serial_no": 1,
|
||||||
|
"serial_no_series": "SRSII.#####",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Item",
|
||||||
|
"item_code": "Stock-Reco-batch-Item-1",
|
||||||
|
"item_name": "Stock-Reco-batch-Item-1",
|
||||||
|
"is_stock_item": 1,
|
||||||
|
"item_group": "All Item Groups",
|
||||||
|
"stock_uom": "Nos",
|
||||||
|
"has_batch_no": 1,
|
||||||
|
"batch_number_series": "BASR.#####",
|
||||||
|
"create_new_batch": 1,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
cls.item = []
|
cls.item = []
|
||||||
for x in records:
|
for x in records:
|
||||||
|
|||||||
Reference in New Issue
Block a user