Skip to content

Commit

Permalink
test: validate batch_no
Browse files Browse the repository at this point in the history
  • Loading branch information
noahjacob committed Jul 14, 2021
1 parent aa6a01b commit 384c9a2
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt


class TestStockReconciliation(unittest.TestCase):
@classmethod
def setUpClass(self):
Expand Down Expand Up @@ -316,6 +317,26 @@ def test_backdated_stock_reco_future_negative_stock(self):
dn2.cancel()
pr1.cancel()

def test_valid_batch(self):
create_batch_item_with_batch("Testing Batch Item 1", "001")
create_batch_item_with_batch("Testing Batch Item 2", "002")
sr = create_stock_reconciliation(item_code="Testing Batch Item 1", qty=1, rate=100, batch_no="002"
, do_not_submit=True)
self.assertRaises(frappe.ValidationError, sr.submit)

def create_batch_item_with_batch(item_name, batch_id):
batch_item_doc = create_item(item_name, 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
batch_item_doc.save(ignore_permissions=True)

if not frappe.db.exists('Batch', batch_id):
b = frappe.new_doc('Batch')
b.item = item_name
b.batch_id = batch_id
b.save()

def insert_existing_sle(warehouse):
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry

Expand Down

0 comments on commit 384c9a2

Please sign in to comment.