mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-11 05:31:48 +00:00
fix: use stock settings for warehouse defaults
This commit is contained in:
@@ -247,9 +247,11 @@ class TestPurchaseOrder(FrappeTestCase):
|
||||
po.submit()
|
||||
first_item_of_po = po.get("items")[0]
|
||||
|
||||
company_default = frappe.db.get_value("Company", po.company, "default_warehouse")
|
||||
frappe.db.set_value("Company", po.company, "default_warehouse", None)
|
||||
self.addCleanup(frappe.db.set_value, "Company", po.company, "default_warehouse", company_default)
|
||||
stock_settings_default = frappe.db.get_single_value("Stock Settings", "default_warehouse")
|
||||
frappe.db.set_single_value("Stock Settings", "default_warehouse", None)
|
||||
self.addCleanup(
|
||||
frappe.db.set_single_value, "Stock Settings", "default_warehouse", stock_settings_default
|
||||
)
|
||||
|
||||
def get_trans_items(item_code):
|
||||
return json.dumps(
|
||||
@@ -463,11 +465,13 @@ class TestPurchaseOrder(FrappeTestCase):
|
||||
"item_code": item,
|
||||
"rate": 100,
|
||||
"qty": 1,
|
||||
"warehouse": po.items[0].warehouse,
|
||||
}, # added item whose tax account head already exists in PO
|
||||
{
|
||||
"item_code": new_item_with_tax.name,
|
||||
"rate": 100,
|
||||
"qty": 1,
|
||||
"warehouse": po.items[0].warehouse,
|
||||
}, # added item whose tax account head is missing in PO
|
||||
]
|
||||
)
|
||||
|
||||
@@ -3753,7 +3753,7 @@ def get_new_child_item_warehouse(p_doc, item, trans_item: dict, child_doctype: s
|
||||
if is_warehouse_required_for_new_child_item(child_doctype, item, trans_item):
|
||||
frappe.throw(
|
||||
_(
|
||||
"Cannot find a default warehouse for item {0}. Please select one in the Update Items dialog, or set a default in the Item Master or in the Company."
|
||||
"Cannot find a default warehouse for item {0}. Please select one in the Update Items dialog, or set a default in the Item Master or in Stock Settings."
|
||||
).format(frappe.bold(item.item_code))
|
||||
)
|
||||
return None
|
||||
|
||||
@@ -629,10 +629,11 @@ class TestSalesOrder(AccountsTestMixin, FrappeTestCase):
|
||||
so = make_sales_order(item_code="_Test Item", qty=4)
|
||||
existing_item = so.get("items")[0]
|
||||
|
||||
# a company gets a default warehouse when its warehouses are created
|
||||
company_default = frappe.db.get_value("Company", so.company, "default_warehouse")
|
||||
frappe.db.set_value("Company", so.company, "default_warehouse", None)
|
||||
self.addCleanup(frappe.db.set_value, "Company", so.company, "default_warehouse", company_default)
|
||||
stock_settings_default = frappe.db.get_single_value("Stock Settings", "default_warehouse")
|
||||
frappe.db.set_single_value("Stock Settings", "default_warehouse", None)
|
||||
self.addCleanup(
|
||||
frappe.db.set_single_value, "Stock Settings", "default_warehouse", stock_settings_default
|
||||
)
|
||||
|
||||
def get_trans_items(warehouse=None):
|
||||
new_row = {"item_code": item_code, "rate": 200, "qty": 7}
|
||||
@@ -651,7 +652,7 @@ class TestSalesOrder(AccountsTestMixin, FrappeTestCase):
|
||||
]
|
||||
)
|
||||
|
||||
# no default in the Item Master, Item Group, Brand or Company
|
||||
# no default in the Item Master, Item Group, Brand or Stock Settings
|
||||
self.assertRaisesRegex(
|
||||
frappe.ValidationError,
|
||||
"Cannot find a default warehouse",
|
||||
|
||||
Reference in New Issue
Block a user