From ac477bb33c4a015e80212273b3a720de8e465a3b Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Tue, 28 Jul 2026 20:06:47 +0530 Subject: [PATCH] test: stop relying on companies having no default warehouse Companies now get their Stores warehouse as Default Warehouse, so item warehouse resolution succeeds where it previously came back empty. test_internal_pr_reference cleared inter_company_reference and asserted a ValidationError, but no validation covers that field - the mapper already sets it. It was incidentally catching 'Row #1: Warehouse is mandatory for stock Item' from the blank target warehouse, so the assertion never tested what it claimed. Dropped it; the delivery_note_item assertion below still covers the reference linkage. test_inter_company_transaction_without_default_warehouse now establishes its own premise by clearing the company's default warehouse instead of relying on it being unset. Its failure previously skipped the teardown that restores frappe.local.enable_perpetual_inventory, which db rollback cannot undo, which in turn broke two later inter-company tests. --- erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py | 4 ++++ .../stock/doctype/purchase_receipt/test_purchase_receipt.py | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 770b24fe4ca..5033fc25cc0 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -3215,6 +3215,10 @@ class TestSalesInvoice(ERPNextTestSuite): "Stock Received But Not Billed - _TC1", ) + # companies are created with their Stores warehouse as Default Warehouse; clear it so the + # item genuinely maps without one + frappe.db.set_value("Company", "_Test Company 1", "default_warehouse", None) + # begin test si = create_sales_invoice( company="Wind Power LLC", diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index 20268d1b4d4..9ecd02fedab 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -2395,9 +2395,6 @@ class TestPurchaseReceipt(ERPNextTestSuite): from erpnext.stock.doctype.delivery_note.mapper import make_inter_company_purchase_receipt pr = make_inter_company_purchase_receipt(dn.name) - pr.inter_company_reference = "" - self.assertRaises(frappe.ValidationError, pr.save) - pr.inter_company_reference = dn.name pr.items[0].qty = 10 pr.items[0].from_warehouse = target_warehouse