fix: create default warehouse (backport #47125) (#47131)

Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com>
fix: create default warehouse (#47125)
This commit is contained in:
mergify[bot]
2025-04-17 13:40:05 +02:00
committed by GitHub
parent 673694ae48
commit ad177e08b8

View File

@@ -282,6 +282,7 @@ class Company(NestedSet):
frappe.clear_cache()
def create_default_warehouses(self):
parent_warehouse = None
for wh_detail in [
{"warehouse_name": _("All Warehouses"), "is_group": 1},
{"warehouse_name": _("Stores"), "is_group": 0},
@@ -289,24 +290,31 @@ class Company(NestedSet):
{"warehouse_name": _("Finished Goods"), "is_group": 0},
{"warehouse_name": _("Goods In Transit"), "is_group": 0, "warehouse_type": "Transit"},
]:
if not frappe.db.exists("Warehouse", "{} - {}".format(wh_detail["warehouse_name"], self.abbr)):
warehouse = frappe.get_doc(
{
"doctype": "Warehouse",
"warehouse_name": wh_detail["warehouse_name"],
"is_group": wh_detail["is_group"],
"company": self.name,
"parent_warehouse": "{} - {}".format(_("All Warehouses"), self.abbr)
if not wh_detail["is_group"]
else "",
"warehouse_type": wh_detail["warehouse_type"]
if "warehouse_type" in wh_detail
else None,
}
)
warehouse.flags.ignore_permissions = True
warehouse.flags.ignore_mandatory = True
warehouse.insert()
if frappe.db.exists(
"Warehouse",
{
"warehouse_name": wh_detail["warehouse_name"],
"company": self.name,
},
):
continue
warehouse = frappe.get_doc(
{
"doctype": "Warehouse",
"warehouse_name": wh_detail["warehouse_name"],
"is_group": wh_detail["is_group"],
"company": self.name,
"parent_warehouse": parent_warehouse,
"warehouse_type": wh_detail.get("warehouse_type"),
}
)
warehouse.flags.ignore_permissions = True
warehouse.flags.ignore_mandatory = True
warehouse.insert()
if wh_detail["is_group"]:
parent_warehouse = warehouse.name
def create_default_accounts(self):
from erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts import create_charts