fix: warehouse naming when suffix is present (#30621)

This commit is contained in:
Ankush Menat 2022-04-07 13:21:08 +05:30 committed by GitHub
parent a6e26cce87
commit be04eaf723
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -38,6 +38,16 @@ class TestWarehouse(FrappeTestCase):
self.assertEqual(p_warehouse.name, child_warehouse.parent_warehouse)
self.assertEqual(child_warehouse.is_group, 0)
def test_naming(self):
company = "Wind Power LLC"
warehouse_name = "Named Warehouse - WP"
wh = frappe.get_doc(doctype="Warehouse", warehouse_name=warehouse_name, company=company).insert()
self.assertEqual(wh.name, warehouse_name)
warehouse_name = "Unnamed Warehouse"
wh = frappe.get_doc(doctype="Warehouse", warehouse_name=warehouse_name, company=company).insert()
self.assertIn(warehouse_name, wh.name)
def test_unlinking_warehouse_from_item_defaults(self):
company = "_Test Company"

View File

@ -21,8 +21,9 @@ class Warehouse(NestedSet):
suffix = " - " + frappe.get_cached_value("Company", self.company, "abbr")
if not self.warehouse_name.endswith(suffix):
self.name = self.warehouse_name + suffix
else:
self.name = self.warehouse_name
return
self.name = self.warehouse_name
def onload(self):
"""load account name for General Ledger Report"""