test: Use name instead of doc

Previous filters implicitly returned last document.
This commit is contained in:
Ankush Menat
2025-06-10 11:55:10 +05:30
parent 9f0df5ecf3
commit e8c8f6fb63
14 changed files with 23 additions and 23 deletions

View File

@@ -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",

View File

@@ -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
}

View File

@@ -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")

View File

@@ -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(

View File

@@ -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:

View File

@@ -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

View File

@@ -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,

View File

@@ -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,

View File

@@ -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()

View File

@@ -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,

View File

@@ -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,

View File

@@ -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),

View File

@@ -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):

View File

@@ -48,7 +48,7 @@ class TestGetItemDetail(IntegrationTestCase):
{
"doctype": "Batch",
"batch_id": "BATCH01",
"item": item,
"item": item.name,
}
).insert()