[stock entry] [test] fixes in test cases
diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py
index 1861179..87f73c1 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/accounts/doctype/sales_invoice/sales_invoice.py
@@ -157,7 +157,7 @@
# fetch pos details, if they are not fetched
if cint(self.doc.is_pos):
self.set_pos_fields(for_validate=True)
-
+
def update_time_log_batch(self, sales_invoice):
for d in self.doclist.get({"doctype":"Sales Invoice Item"}):
if d.time_log_batch:
diff --git a/stock/doctype/stock_entry/test_stock_entry.py b/stock/doctype/stock_entry/test_stock_entry.py
index 7c406f8..c3ce2d7 100644
--- a/stock/doctype/stock_entry/test_stock_entry.py
+++ b/stock/doctype/stock_entry/test_stock_entry.py
@@ -25,6 +25,8 @@
where item_code='_Test Item'""")
self.assertTrue(mr_name)
+
+ webnotes.conn.set_default("company", self.old_default_company)
def test_warehouse_company_validation(self):
from stock.doctype.stock_ledger_entry.stock_ledger_entry import InvalidWarehouseCompany
@@ -71,7 +73,7 @@
webnotes.defaults.set_global_default("auto_inventory_accounting", 0)
def test_material_issue_gl_entry(self):
- webnotes.conn.sql("delete from `tabStock Ledger Entry`")
+ self._clear_stock()
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
mr = webnotes.bean(copy=test_records[0])
@@ -111,9 +113,10 @@
)
webnotes.defaults.set_global_default("auto_inventory_accounting", 0)
+ webnotes.conn.set_default("company", self.old_default_company)
def test_material_transfer_gl_entry(self):
- webnotes.conn.sql("delete from `tabStock Ledger Entry`")
+ self._clear_stock()
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
mr = webnotes.bean(copy=test_records[0])
@@ -145,6 +148,7 @@
self.assertFalse(gl_entries)
webnotes.defaults.set_global_default("auto_inventory_accounting", 0)
+ webnotes.conn.set_default("company", self.old_default_company)
def check_stock_ledger_entries(self, voucher_type, voucher_no, expected_sle):
# check stock ledger entries
@@ -173,6 +177,9 @@
def _clear_stock(self):
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
webnotes.conn.sql("""delete from `tabBin`""")
+
+ self.old_default_company = webnotes.conn.get_default("company")
+ webnotes.conn.set_default("company", "_Test Company")
def _insert_material_receipt(self):
self._clear_stock()
@@ -185,6 +192,8 @@
se2.insert()
se2.submit()
+ webnotes.conn.set_default("company", self.old_default_company)
+
def _get_actual_qty(self):
return flt(webnotes.conn.get_value("Bin", {"item_code": "_Test Item",
"warehouse": "_Test Warehouse"}, "actual_qty"))
@@ -463,6 +472,8 @@
self.assertEquals(actual_qty_1 - 5, actual_qty_2)
+ webnotes.conn.set_default("company", self.old_default_company)
+
return se, pr.doc.name
def test_over_stock_return(self):
@@ -563,6 +574,8 @@
self.assertEquals(actual_qty_1 - 5, actual_qty_2)
+ webnotes.conn.set_default("company", self.old_default_company)
+
return se, pr.doc.name
test_records = [