From e8c8f6fb6334832a694f228efbcc00b1b3d1b0b0 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Tue, 10 Jun 2025 11:55:10 +0530 Subject: [PATCH] test: Use name instead of doc Previous filters implicitly returned last document. --- .../doctype/bank_clearance/test_bank_clearance.py | 2 +- .../test_bank_reconciliation_tool.py | 2 +- erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py | 2 +- .../doctype/purchase_invoice/test_purchase_invoice.py | 2 +- .../accounts/doctype/sales_invoice/test_sales_invoice.py | 2 +- .../accounts_receivable/test_accounts_receivable.py | 4 ++-- .../test_deferred_revenue_and_expense.py | 8 ++++---- .../test_asset_depreciation_schedule.py | 8 ++++---- ...t_sales_partner_target_variance_based_on_item_group.py | 2 +- erpnext/stock/doctype/delivery_note/test_delivery_note.py | 4 ++-- .../doctype/purchase_receipt/test_purchase_receipt.py | 2 +- .../repost_item_valuation/test_repost_item_valuation.py | 4 ++-- erpnext/stock/doctype/stock_entry/test_stock_entry.py | 2 +- erpnext/stock/tests/test_get_item_details.py | 2 +- 14 files changed, 23 insertions(+), 23 deletions(-) diff --git a/erpnext/accounts/doctype/bank_clearance/test_bank_clearance.py b/erpnext/accounts/doctype/bank_clearance/test_bank_clearance.py index 6d25a791e7c..dda65594554 100644 --- a/erpnext/accounts/doctype/bank_clearance/test_bank_clearance.py +++ b/erpnext/accounts/doctype/bank_clearance/test_bank_clearance.py @@ -146,7 +146,7 @@ def make_payment_entry(): supplier = create_supplier(supplier_name="_Test Supplier") pi = make_purchase_invoice( - supplier=supplier, + supplier=supplier.name, supplier_warehouse="_Test Warehouse - _TC", expense_account="Cost of Goods Sold - _TC", uom="Nos", diff --git a/erpnext/accounts/doctype/bank_reconciliation_tool/test_bank_reconciliation_tool.py b/erpnext/accounts/doctype/bank_reconciliation_tool/test_bank_reconciliation_tool.py index 4f3808f157a..53586b333b4 100644 --- a/erpnext/accounts/doctype/bank_reconciliation_tool/test_bank_reconciliation_tool.py +++ b/erpnext/accounts/doctype/bank_reconciliation_tool/test_bank_reconciliation_tool.py @@ -40,7 +40,7 @@ class TestBankReconciliationTool(AccountsTestMixin, IntegrationTestCase): { "doctype": "Bank Account", "account_name": "HDFC _current_", - "bank": bank, + "bank": bank.name, "is_company_account": True, "account": self.bank, # account from Chart of Accounts } diff --git a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py index 20e6c319d70..1a029980586 100644 --- a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py +++ b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py @@ -36,7 +36,7 @@ class TestPOSInvoice(IntegrationTestCase): from erpnext.accounts.doctype.pos_opening_entry.test_pos_opening_entry import create_opening_entry cls.test_user, cls.pos_profile = init_user_and_profile() - create_opening_entry(cls.pos_profile, cls.test_user) + create_opening_entry(cls.pos_profile, cls.test_user.name) mode_of_payment = frappe.get_doc("Mode of Payment", "Bank Draft") set_default_account_for_mode_of_payment(mode_of_payment, "_Test Company", "_Test Bank - _TC") diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index 52bce93ec8b..7fb4ea3d8c3 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -2051,7 +2051,7 @@ class TestPurchaseInvoice(IntegrationTestCase, StockTestMixin): def test_gl_entries_for_standalone_debit_note(self): from erpnext.stock.doctype.item.test_item import make_item - item_code = make_item(properties={"is_stock_item": 1}) + item_code = make_item(properties={"is_stock_item": 1}).name make_purchase_invoice(item_code=item_code, qty=5, rate=500, update_stock=True) returned_inv = make_purchase_invoice( diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 8216de391de..2f3c8b0f945 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -77,7 +77,7 @@ class TestSalesInvoice(ERPNextTestSuite): si = create_sales_invoice( customer="_Test Internal Customer 3", company="_Test Company", is_internal_customer=1, rate=100 ) - pi = make_inter_company_purchase_invoice(si) + pi = make_inter_company_purchase_invoice(si.name) pi.items[0].rate = 120 with self.assertRaises(ValidationError) as e: diff --git a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py index 2fc9a33f615..e65c4d94146 100644 --- a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py @@ -712,7 +712,7 @@ class TestAccountsReceivable(AccountsTestMixin, IntegrationTestCase): si2 = self.create_sales_invoice(do_not_submit=True) si2.posting_date = add_days(today(), -1) - si2.customer = self.customer2 + si2.customer = self.customer2.name si2.currency = "USD" si2.conversion_rate = 80 si2.debit_to = self.debtors_usd @@ -935,7 +935,7 @@ class TestAccountsReceivable(AccountsTestMixin, IntegrationTestCase): si = self.create_sales_invoice(do_not_submit=True) si.posting_date = add_days(today(), -1) - si.customer = self.customer2 + si.customer = self.customer2.name si.currency = "USD" si.conversion_rate = 80 si.debit_to = self.debtors_usd diff --git a/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py b/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py index 1d652a86f67..d918a936091 100644 --- a/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py +++ b/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py @@ -114,7 +114,7 @@ class TestDeferredRevenueAndExpense(IntegrationTestCase, AccountsTestMixin): pda.submit() # execute report - fiscal_year = frappe.get_doc("Fiscal Year", get_fiscal_year(date="2021-05-01")) + fiscal_year = frappe.get_doc("Fiscal Year", get_fiscal_year(date="2021-05-01")[0]) self.filters = frappe._dict( { "company": self.company, @@ -186,7 +186,7 @@ class TestDeferredRevenueAndExpense(IntegrationTestCase, AccountsTestMixin): pda.submit() # execute report - fiscal_year = frappe.get_doc("Fiscal Year", get_fiscal_year(date="2021-05-01")) + fiscal_year = frappe.get_doc("Fiscal Year", get_fiscal_year(date="2021-05-01")[0]) self.filters = frappe._dict( { "company": self.company, @@ -253,7 +253,7 @@ class TestDeferredRevenueAndExpense(IntegrationTestCase, AccountsTestMixin): pda.submit() # execute report - fiscal_year = frappe.get_doc("Fiscal Year", get_fiscal_year(date="2021-05-01")) + fiscal_year = frappe.get_doc("Fiscal Year", get_fiscal_year(date="2021-05-01")[0]) self.filters = frappe._dict( { "company": self.company, @@ -326,7 +326,7 @@ class TestDeferredRevenueAndExpense(IntegrationTestCase, AccountsTestMixin): pda.submit() # execute report - fiscal_year = frappe.get_doc("Fiscal Year", get_fiscal_year(date="2022-01-31")) + fiscal_year = frappe.get_doc("Fiscal Year", get_fiscal_year(date="2022-01-31")[0]) self.filters = frappe._dict( { "company": self.company, diff --git a/erpnext/assets/doctype/asset_depreciation_schedule/test_asset_depreciation_schedule.py b/erpnext/assets/doctype/asset_depreciation_schedule/test_asset_depreciation_schedule.py index 7e226a8fe90..e0366cbf790 100644 --- a/erpnext/assets/doctype/asset_depreciation_schedule/test_asset_depreciation_schedule.py +++ b/erpnext/assets/doctype/asset_depreciation_schedule/test_asset_depreciation_schedule.py @@ -774,7 +774,7 @@ class TestAssetDepreciationSchedule(IntegrationTestCase): current_asset_value = asset.finance_books[0].value_after_depreciation asset_value_adjustment = make_asset_value_adjustment( - asset=asset, + asset=asset.name, date="2023-04-01", current_asset_value=current_asset_value, new_asset_value=1200, @@ -879,7 +879,7 @@ class TestAssetDepreciationSchedule(IntegrationTestCase): current_asset_value = asset.finance_books[0].value_after_depreciation asset_value_adjustment = make_asset_value_adjustment( - asset=asset, + asset=asset.name, date="2023-04-01", current_asset_value=current_asset_value, new_asset_value=600, @@ -945,7 +945,7 @@ class TestAssetDepreciationSchedule(IntegrationTestCase): current_asset_value = asset.finance_books[0].value_after_depreciation asset_value_adjustment = make_asset_value_adjustment( - asset=asset, + asset=asset.name, date="2022-01-15", current_asset_value=current_asset_value, new_asset_value=500, @@ -1034,7 +1034,7 @@ class TestAssetDepreciationSchedule(IntegrationTestCase): current_asset_value = asset.finance_books[0].value_after_depreciation asset_value_adjustment = make_asset_value_adjustment( - asset=asset, + asset=asset.name, date="2022-01-15", current_asset_value=current_asset_value, new_asset_value=500, diff --git a/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/test_sales_partner_target_variance_based_on_item_group.py b/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/test_sales_partner_target_variance_based_on_item_group.py index 4e32d7973e8..0f5ee17330a 100644 --- a/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/test_sales_partner_target_variance_based_on_item_group.py +++ b/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/test_sales_partner_target_variance_based_on_item_group.py @@ -35,7 +35,7 @@ class TestSalesPartnerTargetVarianceBasedOnItemGroup(IntegrationTestCase): qty=20, do_not_submit=True, ) - si.sales_partner = sales_partner + si.sales_partner = sales_partner.name si.commission_rate = 5 si.submit() diff --git a/erpnext/stock/doctype/delivery_note/test_delivery_note.py b/erpnext/stock/doctype/delivery_note/test_delivery_note.py index ab2fc92ad96..9f1352e28e0 100644 --- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py @@ -1131,7 +1131,7 @@ class TestDeliveryNote(IntegrationTestCase): dn = create_delivery_note(do_not_submit=True) dt = make_delivery_trip(dn.name) self.assertEqual(dn.name, dt.delivery_stops[0].delivery_note) - dt.driver = create_driver() + dt.driver = create_driver().name self.assertRaisesRegex( frappe.exceptions.ValidationError, r"^Delivery Notes should not be in draft state when submitting a Delivery Trip.*", @@ -2468,7 +2468,7 @@ class TestDeliveryNote(IntegrationTestCase): make_stock_entry(item_code=item.name, target="_Test Warehouse - _TC", qty=5, basic_rate=100) dn = create_delivery_note( - item_code=batch_item, + item_code=batch_item.name, qty=5, rate=500, use_serial_batch_fields=1, diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index 52e114d64a2..47c3bbfb993 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -1773,7 +1773,7 @@ class TestPurchaseReceipt(IntegrationTestCase): # Step - 3: Create back-date Stock Reconciliation [After DN and Before PR] create_stock_reconciliation( - item_code=item, + item_code=item.name, warehouse=target_warehouse, qty=10, rate=50, diff --git a/erpnext/stock/doctype/repost_item_valuation/test_repost_item_valuation.py b/erpnext/stock/doctype/repost_item_valuation/test_repost_item_valuation.py index 19c5c00c11a..285e9648fdd 100644 --- a/erpnext/stock/doctype/repost_item_valuation/test_repost_item_valuation.py +++ b/erpnext/stock/doctype/repost_item_valuation/test_repost_item_valuation.py @@ -425,13 +425,13 @@ class TestRepostItemValuation(IntegrationTestCase, StockTestMixin): item_code = make_item("_Test Remove Attached File Item", properties={"is_stock_item": 1}) make_purchase_receipt( - item_code=item_code, + item_code=item_code.name, qty=1, rate=100, ) pr1 = make_purchase_receipt( - item_code=item_code, + item_code=item_code.name, qty=1, rate=100, posting_date=add_days(today(), days=-1), diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index db4a0fe0f46..0ae619b3049 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -113,7 +113,7 @@ class TestStockEntry(IntegrationTestCase): def test_barcode_item_stock_entry(self): item_code = make_item("_Test Item Stock Entry For Barcode", barcode="BDD-1234567890") - se = make_stock_entry(item_code=item_code, target="_Test Warehouse - _TC", qty=1, basic_rate=100) + se = make_stock_entry(item_code=item_code.name, target="_Test Warehouse - _TC", qty=1, basic_rate=100) self.assertEqual(se.items[0].barcode, "BDD-1234567890") def test_auto_material_request_for_variant(self): diff --git a/erpnext/stock/tests/test_get_item_details.py b/erpnext/stock/tests/test_get_item_details.py index 9bf20f2f03f..e0f32402d85 100644 --- a/erpnext/stock/tests/test_get_item_details.py +++ b/erpnext/stock/tests/test_get_item_details.py @@ -48,7 +48,7 @@ class TestGetItemDetail(IntegrationTestCase): { "doctype": "Batch", "batch_id": "BATCH01", - "item": item, + "item": item.name, } ).insert()