diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index f824a00743e..ccf4b402465 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -1175,7 +1175,9 @@ def repost_gle_for_stock_vouchers( voucher_obj.make_gl_entries(gl_entries=expected_gle, from_repost=True) else: _delete_gl_entries(voucher_type, voucher_no) - frappe.db.commit() + + if not frappe.flags.in_test: + frappe.db.commit() if repost_doc: repost_doc.db_set( diff --git a/erpnext/stock/tests/test_utils.py b/erpnext/stock/tests/test_utils.py index b046dbda24f..4e93ac93cb7 100644 --- a/erpnext/stock/tests/test_utils.py +++ b/erpnext/stock/tests/test_utils.py @@ -26,6 +26,7 @@ class StockTestMixin: filters=filters, order_by="timestamp(posting_date, posting_time), creation", ) + self.assertGreaterEqual(len(sles), len(expected_sles)) for exp_sle, act_sle in zip(expected_sles, sles): for k, v in exp_sle.items(): @@ -49,7 +50,7 @@ class StockTestMixin: filters=filters, order_by=order_by or "posting_date, creation", ) - + self.assertGreaterEqual(len(actual_gles), len(expected_gles)) for exp_gle, act_gle in zip(expected_gles, actual_gles): for k, exp_value in exp_gle.items(): act_value = act_gle[k]