Skip to content

Commit

Permalink
refactor: install fixtures (#33964)
Browse files Browse the repository at this point in the history
* refactor: install fixtures

* style: disable semgrep for install_defaults signature

(cherry picked from commit 201573a)
  • Loading branch information
barredterra authored and mergify[bot] committed Feb 11, 2023
1 parent 02c4c55 commit 5b7420a
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions erpnext/setup/setup_wizard/operations/install_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,11 @@ def install(country=None):
make_default_records()
make_records(records)
set_up_address_templates(default_country=country)
set_more_defaults()
update_global_search_doctypes()


def set_more_defaults():
# Do more setup stuff that can be done here with no dependencies
update_selling_defaults()
update_buying_defaults()
add_uom_data()
update_item_variant_settings()
update_global_search_doctypes()


def update_selling_defaults():
Expand Down Expand Up @@ -381,7 +376,7 @@ def add_uom_data():
)
for d in uoms:
if not frappe.db.exists("UOM", _(d.get("uom_name"))):
uom_doc = frappe.get_doc(
frappe.get_doc(
{
"doctype": "UOM",
"uom_name": _(d.get("uom_name")),
Expand All @@ -404,15 +399,15 @@ def add_uom_data():
if not frappe.db.exists(
"UOM Conversion Factor", {"from_uom": _(d.get("from_uom")), "to_uom": _(d.get("to_uom"))}
):
uom_conversion = frappe.get_doc(
frappe.get_doc(
{
"doctype": "UOM Conversion Factor",
"category": _(d.get("category")),
"from_uom": _(d.get("from_uom")),
"to_uom": _(d.get("to_uom")),
"value": d.get("value"),
}
).insert(ignore_permissions=True)
).db_insert()


def add_market_segments():
Expand Down Expand Up @@ -468,7 +463,7 @@ def install_company(args):
make_records(records)


def install_defaults(args=None):
def install_defaults(args=None): # nosemgrep
records = [
# Price Lists
{
Expand All @@ -493,7 +488,7 @@ def install_defaults(args=None):

# enable default currency
frappe.db.set_value("Currency", args.get("currency"), "enabled", 1)
frappe.db.set_value("Stock Settings", None, "email_footer_address", args.get("company_name"))
frappe.db.set_single_value("Stock Settings", "email_footer_address", args.get("company_name"))

set_global_defaults(args)
update_stock_settings()
Expand Down

0 comments on commit 5b7420a

Please sign in to comment.