diff --git a/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py b/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py index 6aaf02572b8..e1e4aca0b28 100644 --- a/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py +++ b/erpnext/selling/doctype/party_specific_item/test_party_specific_item.py @@ -17,36 +17,37 @@ def create_party_specific_item(**args): class TestPartySpecificItem(ERPNextTestSuite): - def setUp(self): - self.customer = frappe.get_last_doc("Customer") - self.supplier = frappe.get_last_doc("Supplier") - self.item = frappe.get_last_doc("Item") - def test_item_query_for_customer(self): + customer = self.customer[0].name + item = self.item[0].name + create_party_specific_item( party_type="Customer", - party=self.customer.name, + party=customer, restrict_based_on="Item", - based_on_value=self.item.name, + based_on_value=item, ) - filters = {"is_sales_item": 1, "customer": self.customer.name} + filters = {"is_sales_item": 1, "customer": customer} items = item_query( doctype="Item", txt="", searchfield="name", start=0, page_len=20, filters=filters, as_dict=False ) - self.assertTrue(self.item.name in flatten(items)) + self.assertTrue(item in flatten(items)) def test_item_query_for_supplier(self): + supplier = self.suppliers[0].name + item = self.item_group[0].name + create_party_specific_item( party_type="Supplier", - party=self.supplier.name, + party=supplier, restrict_based_on="Item Group", - based_on_value=self.item.item_group, + based_on_value=item, ) - filters = {"supplier": self.supplier.name, "is_purchase_item": 1} + filters = {"supplier": supplier, "is_purchase_item": 1} items = item_query( doctype="Item", txt="", searchfield="name", start=0, page_len=20, filters=filters, as_dict=False ) - self.assertTrue(self.item.item_group in flatten(items)) + self.assertTrue(item in flatten(items)) def flatten(lst):