From dab670954961c1f0235033c124ebaf3cb84f6a14 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 9 Sep 2024 15:53:27 +0530 Subject: [PATCH] test: utilize test mixin and barebones test case --- erpnext/accounts/test/accounts_mixin.py | 8 ++++++++ .../doctype/sales_order/test_sales_order.py | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/erpnext/accounts/test/accounts_mixin.py b/erpnext/accounts/test/accounts_mixin.py index d503f7bc4af..b0967196962 100644 --- a/erpnext/accounts/test/accounts_mixin.py +++ b/erpnext/accounts/test/accounts_mixin.py @@ -104,6 +104,14 @@ class AccountsTestMixin: new_acc.save() setattr(self, acc.attribute_name, new_acc.name) + self.identify_default_warehouses() + + def identify_default_warehouses(self): + for w in frappe.db.get_all( + "Warehouse", filters={"company": self.company}, fields=["name", "warehouse_name"] + ): + setattr(self, "warehouse_" + w.warehouse_name.lower().strip().replace(" ", "_"), w.name) + def create_usd_receivable_account(self): account_name = "Debtors USD" if not frappe.db.get_value( diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py index 1d4d65da065..52922bff298 100644 --- a/erpnext/selling/doctype/sales_order/test_sales_order.py +++ b/erpnext/selling/doctype/sales_order/test_sales_order.py @@ -2197,6 +2197,21 @@ class TestSalesOrder(AccountsTestMixin, FrappeTestCase): self.assertRaises(frappe.ValidationError, so1.update_status, "Draft") + @change_settings("Stock Settings", {"enable_stock_reservation": True}) + def test_warehouse_mapping_based_on_stock_reservation(self): + self.create_company() + self.create_item("Lamy Safari", True, self.warehouse_stores) + self.create_customer() + self.clear_old_entries() + + so = frappe.new_doc("Sales Order") + so.company = self.company + so.transaction_date = today() + so.append( + "items", {"item_code": self.item, "qty": 10, "rate": 2000, "warehouse": self.warehouse_stores} + ) + so.save() + def automatically_fetch_payment_terms(enable=1): accounts_settings = frappe.get_doc("Accounts Settings")