From 567f7b4d71cb84e2951f64d55a098474c111f90e Mon Sep 17 00:00:00 2001 From: ljain112 Date: Sat, 12 Jul 2025 12:48:01 +0530 Subject: [PATCH 1/3] chore: fix flacky test and remove redundant code (cherry picked from commit de8c3ba968ce239db3a1e317254aa77852628dcc) # Conflicts: # erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py --- erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py | 7 +++++++ erpnext/stock/doctype/batch/test_batch.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py index aa0a898bd42..1b72b15a3e3 100644 --- a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py +++ b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py @@ -1073,8 +1073,15 @@ def create_pos_invoice(**args): return pos_inv +<<<<<<< HEAD def make_batch_item(item_name): from erpnext.stock.doctype.item.test_item import make_item if not frappe.db.exists(item_name): return make_item(item_name, dict(has_batch_no=1, create_new_batch=1, is_stock_item=1)) +======= +def set_allow_partial_payment(pos_profile, value): + pos_profile.reload() + pos_profile.allow_partial_payment = value + pos_profile.save() +>>>>>>> de8c3ba968 (chore: fix flacky test and remove redundant code) diff --git a/erpnext/stock/doctype/batch/test_batch.py b/erpnext/stock/doctype/batch/test_batch.py index 1bd202df28a..e678f3be3e2 100644 --- a/erpnext/stock/doctype/batch/test_batch.py +++ b/erpnext/stock/doctype/batch/test_batch.py @@ -35,7 +35,7 @@ class TestBatch(FrappeTestCase): def make_batch_item(cls, item_name=None): from erpnext.stock.doctype.item.test_item import make_item - if not frappe.db.exists(item_name): + if not frappe.db.exists("Item", item_name): return make_item(item_name, dict(has_batch_no=1, create_new_batch=1, is_stock_item=1)) def test_purchase_receipt(self, batch_qty=100): From 8f6cd40c7b289b20ef3295e6987beee777c78a3b Mon Sep 17 00:00:00 2001 From: ljain112 Date: Sat, 12 Jul 2025 13:07:52 +0530 Subject: [PATCH 2/3] chore: return doc if item already exists for test (cherry picked from commit e6b9e82b2fba369edabec85383680a6e4d2a3e1c) --- erpnext/stock/doctype/batch/test_batch.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/stock/doctype/batch/test_batch.py b/erpnext/stock/doctype/batch/test_batch.py index e678f3be3e2..1d44d19ac81 100644 --- a/erpnext/stock/doctype/batch/test_batch.py +++ b/erpnext/stock/doctype/batch/test_batch.py @@ -38,6 +38,8 @@ class TestBatch(FrappeTestCase): if not frappe.db.exists("Item", item_name): return make_item(item_name, dict(has_batch_no=1, create_new_batch=1, is_stock_item=1)) + return frappe.get_doc("Item", item_name) + def test_purchase_receipt(self, batch_qty=100): """Test automated batch creation from Purchase Receipt""" self.make_batch_item("ITEM-BATCH-1") From 153df4eca5901ddee6fdfcf019c4d3e2983bf07c Mon Sep 17 00:00:00 2001 From: ljain112 Date: Sun, 13 Jul 2025 18:16:49 +0530 Subject: [PATCH 3/3] chore: resolve conflicts --- .../doctype/pos_invoice/test_pos_invoice.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py index 1b72b15a3e3..2cc1d5f22bb 100644 --- a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py +++ b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py @@ -1071,17 +1071,3 @@ def create_pos_invoice(**args): pos_inv.payment_schedule = [] return pos_inv - - -<<<<<<< HEAD -def make_batch_item(item_name): - from erpnext.stock.doctype.item.test_item import make_item - - if not frappe.db.exists(item_name): - return make_item(item_name, dict(has_batch_no=1, create_new_batch=1, is_stock_item=1)) -======= -def set_allow_partial_payment(pos_profile, value): - pos_profile.reload() - pos_profile.allow_partial_payment = value - pos_profile.save() ->>>>>>> de8c3ba968 (chore: fix flacky test and remove redundant code)