Merge branch 'develop' of https://github.com/frappe/erpnext into demo_data_on_install
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index 4996203..db366cf 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -706,6 +706,7 @@
if party_type not in ("Customer", "Supplier"):
return
template = None
+
if party_type == "Customer":
customer = frappe.get_cached_value(
"Customer", party_name, fieldname=["payment_terms", "customer_group"], as_dict=1
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index d5eb464..e5d9318 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -70,6 +70,16 @@
"Department",
]
+demo_master_doctypes = [
+ "item_group",
+ "item",
+ "customer_group",
+ "supplier_group",
+ "customer",
+ "supplier",
+]
+demo_transaction_doctypes = ["purchase_invoice", "sales_invoice", "payment_entry"]
+
jinja = {
"methods": [
"erpnext.stock.serial_batch_bundle.get_serial_or_batch_nos",
diff --git a/erpnext/public/build.json b/erpnext/public/build.json
index b9b48ab..0b63e9f 100644
--- a/erpnext/public/build.json
+++ b/erpnext/public/build.json
@@ -19,6 +19,7 @@
"public/js/queries.js",
"public/js/sms_manager.js",
"public/js/utils/party.js",
+ "public/js/utils/demo.js",
"public/js/controllers/stock_controller.js",
"public/js/payment/payments.js",
"public/js/controllers/taxes_and_totals.js",
diff --git a/erpnext/public/js/setup_wizard.js b/erpnext/public/js/setup_wizard.js
index a913844..a067ec0 100644
--- a/erpnext/public/js/setup_wizard.js
+++ b/erpnext/public/js/setup_wizard.js
@@ -38,6 +38,7 @@
{ fieldname: 'fy_start_date', label: __('Financial Year Begins On'), fieldtype: 'Date', reqd: 1 },
// end date should be hidden (auto calculated)
{ fieldname: 'fy_end_date', label: __('End Date'), fieldtype: 'Date', reqd: 1, hidden: 1 },
+ { fieldname: 'setup_demo', label: __('Generate dummy data for demo'), fieldtype: 'Check'},
],
onload: function (slide) {
diff --git a/erpnext/public/js/utils/demo.js b/erpnext/public/js/utils/demo.js
new file mode 100644
index 0000000..432bad6
--- /dev/null
+++ b/erpnext/public/js/utils/demo.js
@@ -0,0 +1,11 @@
+$(document).on("toolbar_setup", function() {
+ if (erpnext.is_demo_company_setup) {
+ console.log("setup");
+ }
+});
+
+erpnext.is_demo_company_setup = function() {
+ frappe.db.get_value("Global Default", "Global Default", "demo_company", function(r) {
+ console.log(r);
+ });
+};
\ No newline at end of file
diff --git a/erpnext/setup/demo.py b/erpnext/setup/demo.py
new file mode 100644
index 0000000..882ed37
--- /dev/null
+++ b/erpnext/setup/demo.py
@@ -0,0 +1,159 @@
+# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+import json
+import os
+from random import randint
+
+import frappe
+from frappe.utils import add_days
+
+import erpnext
+from erpnext.setup.setup_wizard.operations.install_fixtures import create_bank_account
+
+
+@frappe.whitelist()
+def setup_demo_data():
+ company = create_demo_company()
+ process_masters()
+ make_transactions(company)
+
+
+@frappe.whitelist()
+def clear_demo_data():
+ company = frappe.db.get_single_value("Global Defaults", "demo_company")
+ create_transaction_deletion_record(company)
+ clear_masters()
+ delete_company(company)
+
+
+def create_demo_company():
+ company = frappe.db.get_all("Company")[0].name
+ company_doc = frappe.get_doc("Company", company)
+
+ # Make a dummy company
+ new_company = frappe.new_doc("Company")
+ new_company.company_name = company_doc.company_name + " (Demo)"
+ new_company.abbr = company_doc.abbr + "D"
+ new_company.enable_perpetual_inventory = 1
+ new_company.default_currency = company_doc.default_currency
+ new_company.country = company_doc.country
+ new_company.chart_of_accounts_based_on = "Standard Template"
+ new_company.chart_of_accounts = company_doc.chart_of_accounts
+ new_company.insert()
+
+ # Set Demo Company as default to
+ frappe.db.set_single_value("Global Defaults", "demo_company", new_company.name)
+ frappe.db.set_default("company", new_company.name)
+
+ bank_account = create_bank_account({"company_name": new_company.name})
+ frappe.db.set_value("Company", new_company.name, "default_bank_account", bank_account.name)
+
+ return new_company.name
+
+
+def process_masters():
+ for doctype in frappe.get_hooks("demo_master_doctypes"):
+ data = read_data_file_using_hooks(doctype)
+ if data:
+ for item in json.loads(data):
+ create_demo_record(item)
+
+
+def create_demo_record(doctype):
+ frappe.get_doc(doctype).insert(ignore_permissions=True)
+
+
+def make_transactions(company):
+ fiscal_year = frappe.db.get_single_value("Global Defaults", "current_fiscal_year")
+ start_date = frappe.db.get_value("Fiscal Year", fiscal_year, "year_start_date")
+ frappe.db.set_single_value("Stock Settings", "allow_negative_stock", 1)
+
+ for doctype in frappe.get_hooks("demo_transaction_doctypes"):
+ data = read_data_file_using_hooks(doctype)
+ if data:
+ for item in json.loads(data):
+ create_transaction(item, company, start_date)
+
+
+def create_transaction(doctype, company, start_date):
+ warehouse = get_warehouse(company)
+ posting_date = (
+ start_date if doctype.get("doctype") == "Purchase Invoice" else get_random_date(start_date)
+ )
+ bank_account = frappe.db.get_value("Company", company, "default_bank_account")
+ bank_field = "paid_to" if doctype.get("party_type") == "Customer" else "paid_from"
+
+ doctype.update(
+ {
+ "company": company,
+ "set_posting_time": 1,
+ "posting_date": posting_date,
+ "set_warehouse": warehouse,
+ bank_field: bank_account,
+ "reference_date": posting_date,
+ }
+ )
+
+ income_account, expense_account = frappe.db.get_value(
+ "Company", company, ["default_income_account", "default_expense_account"]
+ )
+
+ for item in doctype.get("items") or []:
+ item.update(
+ {
+ "cost_center": erpnext.get_default_cost_center(company),
+ "income_account": income_account,
+ "expense_account": expense_account,
+ }
+ )
+
+ doc = frappe.get_doc(doctype)
+ doc.save(ignore_permissions=True)
+ doc.submit()
+
+
+def get_random_date(start_date):
+ return add_days(start_date, randint(1, 365))
+
+
+def create_transaction_deletion_record(company):
+ transaction_deletion_record = frappe.new_doc("Transaction Deletion Record")
+ transaction_deletion_record.company = company
+ transaction_deletion_record.save(ignore_permissions=True)
+ transaction_deletion_record.submit()
+
+
+def clear_masters():
+ for doctype in frappe.get_hooks("demo_master_doctypes")[::-1]:
+ data = read_data_file_using_hooks(doctype)
+ if data:
+ for item in json.loads(data):
+ clear_demo_record(item)
+
+
+def clear_demo_record(doctype):
+ doc_type = doctype.get("doctype")
+ del doctype["doctype"]
+ doc = frappe.get_doc(doc_type, doctype)
+ frappe.delete_doc(doc.doctype, doc.name, ignore_permissions=True)
+
+
+def delete_company(company):
+ frappe.db.set_single_value("Global Defaults", "demo_company", "")
+ frappe.delete_doc("Company", company, ignore_permissions=True)
+
+
+def read_data_file_using_hooks(doctype):
+ path = os.path.join(os.path.dirname(__file__), "demo_data")
+ with open(os.path.join(path, doctype + ".json"), "r") as f:
+ data = f.read()
+
+ return data
+
+
+def get_warehouse(company):
+ abbr = frappe.db.get_value("Company", company, "abbr")
+ warehouse = "Stores - {0}".format(abbr)
+
+ return warehouse
diff --git a/erpnext/setup/demo_data/customer.json b/erpnext/setup/demo_data/customer.json
new file mode 100644
index 0000000..b27c444
--- /dev/null
+++ b/erpnext/setup/demo_data/customer.json
@@ -0,0 +1,20 @@
+[
+ {
+ "doctype": "Customer",
+ "customer_group": "Demo Customer Group",
+ "territory": "All Territories",
+ "customer_name": "ABC Enterprises"
+ },
+ {
+ "doctype": "Customer",
+ "customer_group": "Demo Customer Group",
+ "territory": "All Territories",
+ "customer_name": "XYZ Corporation"
+ },
+ {
+ "doctype": "Customer",
+ "customer_group": "Demo Customer Group",
+ "territory": "All Territories",
+ "customer_name": "KJPR Pvt. Ltd."
+ }
+]
\ No newline at end of file
diff --git a/erpnext/setup/demo_data/customer_group.json b/erpnext/setup/demo_data/customer_group.json
new file mode 100644
index 0000000..7543335
--- /dev/null
+++ b/erpnext/setup/demo_data/customer_group.json
@@ -0,0 +1,6 @@
+[
+ {
+ "doctype": "Customer Group",
+ "customer_group_name": "Demo Customer Group"
+ }
+]
\ No newline at end of file
diff --git a/erpnext/setup/demo_data/item.json b/erpnext/setup/demo_data/item.json
new file mode 100644
index 0000000..a241337
--- /dev/null
+++ b/erpnext/setup/demo_data/item.json
@@ -0,0 +1,72 @@
+[
+ {
+ "doctype": "Item",
+ "item_group": "Demo Item Group",
+ "item_code": "SKU001",
+ "item_name": "T-shirt",
+ "image": "https://media.istockphoto.com/id/1281631373/vector/mockup-template-men-black-t-shirt-short-sleeve.jpg?s=612x612&w=0&k=20&c=SfYrtFXQS2wJ1-R9ozvxhUabJz3cnmH5HXv2sXW_mZk="
+ },
+ {
+ "doctype": "Item",
+ "item_group": "Demo Item Group",
+ "item_code": "SKU002",
+ "item_name": "Laptop",
+ "image": "https://media.istockphoto.com/id/1297051332/vector/levitation-laptop-mockup.jpg?s=612x612&w=0&k=20&c=E9rp9HY7CaPjjsnZlg8NYBTFOGy7gfBSL7oK6wv5VnY="
+ },
+ {
+ "doctype": "Item",
+ "item_group": "Demo Item Group",
+ "item_code": "SKU003",
+ "item_name": "Book",
+ "image": "https://media.istockphoto.com/id/950152244/vector/vector-mock-up-of-standing-book.jpg?s=612x612&w=0&k=20&c=oDF2LeFoAcPAwJZFEVjWRvT53sMmCQwkVj-3qYy1duw="
+ },
+ {
+ "doctype": "Item",
+ "item_group": "Demo Item Group",
+ "item_code": "SKU004",
+ "item_name": "Smartphone",
+ "image": "https://media.istockphoto.com/id/1308145590/vector/realistic-mobile-phone-mockup-template-isolated-stock-vector.jpg?s=612x612&w=0&k=20&c=63UyujU3S9kAkUh3MXdJcr10xelDjgVyQzRx5Sh5018="
+ },
+ {
+ "doctype": "Item",
+ "item_group": "Demo Item Group",
+ "item_code": "SKU005",
+ "item_name": "Sneakers",
+ "image": "https://media.istockphoto.com/id/1303978937/photo/white-sneaker-on-a-blue-gradient-background-mens-fashion-sport-shoe-sneakers-lifestyle.jpg?s=612x612&w=0&k=20&c=L725fuzFTnm6qEaqE7Urc5q6IR80EgYQEjBn_qtBIQg="
+ },
+ {
+ "doctype": "Item",
+ "item_group": "Demo Item Group",
+ "item_code": "SKU006",
+ "item_name": "Coffee Mug",
+ "image": "https://media.istockphoto.com/id/821282266/photo/white-mug-isolated.jpg?s=612x612&w=0&k=20&c=LJCMPk0D83OKmJHahkiLzAB3OsKr83nMbL7KxSgfpfM="
+ },
+ {
+ "doctype": "Item",
+ "item_group": "Demo Item Group",
+ "item_code": "SKU007",
+ "item_name": "Television",
+ "image": "https://media.istockphoto.com/id/1002728980/vector/wide-tv-monitor-mockup.jpg?s=612x612&w=0&k=20&c=1gDEH7ppC9ap8UBuIQmO1gM_Z8VeEaEUDDo-Aw_k8qs="
+ },
+ {
+ "doctype": "Item",
+ "item_group": "Demo Item Group",
+ "item_code": "SKU008",
+ "item_name": "Backpack",
+ "image": "https://media.istockphoto.com/id/1141208525/photo/yellow-open-backpack.jpg?s=612x612&w=0&k=20&c=k0NOqN9FnIGdkaUNx6-fMIBG2IfWwLT_AbDVefqJT_0="
+ },
+ {
+ "doctype": "Item",
+ "item_group": "Demo Item Group",
+ "item_code": "SKU009",
+ "item_name": "Headphones",
+ "image": "https://media.istockphoto.com/id/860853774/photo/blue-headphones-isolated-on-a-white-background.jpg?s=612x612&w=0&k=20&c=KqMSLWuM_Prrq5XHTe79bnFRU_leFDaXTuKqup5uvrE="
+ },
+ {
+ "doctype": "Item",
+ "item_group": "Demo Item Group",
+ "item_code": "SKU010",
+ "item_name": "Camera",
+ "image": "https://media.istockphoto.com/id/185278433/photo/black-digital-slr-camera-in-a-white-background.jpg?s=612x612&w=0&k=20&c=OOCbhvOF0W-eVhhrm-TxbgLfbKhFfs4Lprjd7hiQBNU="
+ }
+]
\ No newline at end of file
diff --git a/erpnext/setup/demo_data/item_group.json b/erpnext/setup/demo_data/item_group.json
new file mode 100644
index 0000000..acb261f
--- /dev/null
+++ b/erpnext/setup/demo_data/item_group.json
@@ -0,0 +1,7 @@
+[
+ {
+ "doctype": "Item Group",
+ "item_group_name": "Demo Item Group",
+ "parent_item_group": "All Item Groups"
+ }
+]
\ No newline at end of file
diff --git a/erpnext/setup/demo_data/payment_entry.json b/erpnext/setup/demo_data/payment_entry.json
new file mode 100644
index 0000000..7d8d7d5
--- /dev/null
+++ b/erpnext/setup/demo_data/payment_entry.json
@@ -0,0 +1,12 @@
+[
+ {
+ "doctype": "Payment Entry",
+ "party_type": "Customer",
+ "party": "ABC Enterprises",
+ "paid_amount": 67000,
+ "received_amount": 67000,
+ "reference_no": "#ref0001",
+ "source_exchange_rate": 1,
+ "target_exchange_rate": 1
+ }
+]
\ No newline at end of file
diff --git a/erpnext/setup/demo_data/purchase_invoice.json b/erpnext/setup/demo_data/purchase_invoice.json
new file mode 100644
index 0000000..eda26b0
--- /dev/null
+++ b/erpnext/setup/demo_data/purchase_invoice.json
@@ -0,0 +1,162 @@
+[
+ {
+ "conversion_rate": 1.0,
+ "supplier": "DQ Industries",
+ "doctype": "Purchase Invoice",
+ "update_stock": 1,
+ "items": [
+ {
+ "doctype": "Purchase Invoice Item",
+ "item_code": "SKU001",
+ "parentfield": "items",
+ "qty": 100.0,
+ "rate": 400.0,
+ "conversion_factor": 1
+ }
+ ]
+ },
+ {
+ "conversion_rate": 1.0,
+ "supplier": "MA Inc.",
+ "doctype": "Purchase Invoice",
+ "update_stock": 1,
+ "items": [
+ {
+ "doctype": "Purchase Invoice Item",
+ "item_code": "SKU002",
+ "parentfield": "items",
+ "qty": 100.0,
+ "rate": 400.0,
+ "conversion_factor": 1
+ }
+ ]
+ },
+ {
+ "conversion_rate": 1.0,
+ "supplier": "KC Corp.",
+ "doctype": "Purchase Invoice",
+ "update_stock": 1,
+ "items": [
+ {
+ "doctype": "Purchase Invoice Item",
+ "item_code": "SKU003",
+ "parentfield": "items",
+ "qty": 100.0,
+ "rate": 400.0,
+ "conversion_factor": 1
+ }
+ ]
+ },
+ {
+ "conversion_rate": 1.0,
+ "supplier": "DQ Industries",
+ "doctype": "Purchase Invoice",
+ "update_stock": 1,
+ "items": [
+ {
+ "doctype": "Purchase Invoice Item",
+ "item_code": "SKU004",
+ "parentfield": "items",
+ "qty": 100.0,
+ "rate": 400.0,
+ "conversion_factor": 1
+ }
+ ]
+ },
+ {
+ "conversion_rate": 1.0,
+ "supplier": "MA Inc.",
+ "doctype": "Purchase Invoice",
+ "update_stock": 1,
+ "items": [
+ {
+ "doctype": "Purchase Invoice Item",
+ "item_code": "SKU005",
+ "parentfield": "items",
+ "qty": 100.0,
+ "rate": 400.0,
+ "conversion_factor": 1
+ }
+ ]
+ },
+ {
+ "conversion_rate": 1.0,
+ "supplier": "KC Corp.",
+ "doctype": "Purchase Invoice",
+ "update_stock": 1,
+ "items": [
+ {
+ "doctype": "Purchase Invoice Item",
+ "item_code": "SKU006",
+ "parentfield": "items",
+ "qty": 100.0,
+ "rate": 400.0,
+ "conversion_factor": 1
+ }
+ ]
+ },
+ {
+ "conversion_rate": 1.0,
+ "supplier": "DQ Industries",
+ "doctype": "Purchase Invoice",
+ "update_stock": 1,
+ "items": [
+ {
+ "doctype": "Purchase Invoice Item",
+ "item_code": "SKU007",
+ "parentfield": "items",
+ "qty": 100.0,
+ "rate": 400.0,
+ "conversion_factor": 1
+ }
+ ]
+ },
+ {
+ "conversion_rate": 1.0,
+ "supplier": "MA Inc.",
+ "doctype": "Purchase Invoice",
+ "update_stock": 1,
+ "items": [
+ {
+ "doctype": "Purchase Invoice Item",
+ "item_code": "SKU008",
+ "parentfield": "items",
+ "qty": 100.0,
+ "rate": 400.0,
+ "conversion_factor": 1
+ }
+ ]
+ },
+ {
+ "conversion_rate": 1.0,
+ "supplier": "KC Corp.",
+ "doctype": "Purchase Invoice",
+ "update_stock": 1,
+ "items": [
+ {
+ "doctype": "Purchase Invoice Item",
+ "item_code": "SKU009",
+ "parentfield": "items",
+ "qty": 100.0,
+ "rate": 400.0,
+ "conversion_factor": 1
+ }
+ ]
+ },
+ {
+ "conversion_rate": 1.0,
+ "supplier": "DQ Industries",
+ "doctype": "Purchase Invoice",
+ "update_stock": 1,
+ "items": [
+ {
+ "doctype": "Purchase Invoice Item",
+ "item_code": "SKU010",
+ "parentfield": "items",
+ "qty": 100.0,
+ "rate": 400.0,
+ "conversion_factor": 1
+ }
+ ]
+ }
+]
\ No newline at end of file
diff --git a/erpnext/setup/demo_data/sales_invoice.json b/erpnext/setup/demo_data/sales_invoice.json
new file mode 100644
index 0000000..6bbfcbe
--- /dev/null
+++ b/erpnext/setup/demo_data/sales_invoice.json
@@ -0,0 +1,122 @@
+[
+ {
+ "conversion_rate": 1.0,
+ "customer": "ABC Enterprises",
+ "doctype": "Sales Invoice",
+ "update_stock": 1,
+ "items": [
+ {
+ "doctype": "Sales Invoice Item",
+ "item_code": "SKU004",
+ "parentfield": "items",
+ "qty": 20.0,
+ "rate": 500.0,
+ "conversion_factor": 1
+ }
+ ]
+ },
+ {
+ "conversion_rate": 1.0,
+ "customer": "XYZ Corporation",
+ "doctype": "Sales Invoice",
+ "update_stock": 1,
+ "items": [
+ {
+ "doctype": "Sales Invoice Item",
+ "item_code": "SKU001",
+ "parentfield": "items",
+ "qty": 25.0,
+ "rate": 600.0,
+ "conversion_factor": 1
+ },
+ {
+ "doctype": "Sales Invoice Item",
+ "item_code": "SKU002",
+ "parentfield": "items",
+ "qty": 15.0,
+ "rate": 300.0,
+ "conversion_factor": 1
+ }
+ ]
+ },
+ {
+ "conversion_rate": 1.0,
+ "customer": "XYZ Corporation",
+ "doctype": "Sales Invoice",
+ "update_stock": 1,
+ "items": [
+ {
+ "doctype": "Sales Invoice Item",
+ "item_code": "SKU003",
+ "parentfield": "items",
+ "qty": 100,
+ "rate": 300.0,
+ "conversion_factor": 1
+ },
+ {
+ "doctype": "Sales Invoice Item",
+ "item_code": "SKU006",
+ "parentfield": "items",
+ "qty": 100,
+ "rate": 300.0,
+ "conversion_factor": 1
+ },
+ {
+ "doctype": "Sales Invoice Item",
+ "item_code": "SKU007",
+ "parentfield": "items",
+ "qty": 100,
+ "rate": 300.0,
+ "conversion_factor": 1
+ }
+ ]
+ },
+ {
+ "conversion_rate": 1.0,
+ "customer": "KJPR Pvt. Ltd.",
+ "doctype": "Sales Invoice",
+ "update_stock": 1,
+ "items": [
+ {
+ "doctype": "Sales Invoice Item",
+ "item_code": "SKU005",
+ "parentfield": "items",
+ "qty": 200.0,
+ "rate": 100.0,
+ "conversion_factor": 1
+ }
+ ]
+ },
+ {
+ "conversion_rate": 1.0,
+ "customer": "ABC Enterprises",
+ "doctype": "Sales Invoice",
+ "update_stock": 1,
+ "items": [
+ {
+ "doctype": "Sales Invoice Item",
+ "item_code": "SKU008",
+ "parentfield": "items",
+ "qty": 20.0,
+ "rate": 500.0,
+ "conversion_factor": 1
+ },
+ {
+ "doctype": "Sales Invoice Item",
+ "item_code": "SKU009",
+ "parentfield": "items",
+ "qty": 40.0,
+ "rate": 300.0,
+ "conversion_factor": 1
+ },
+ {
+ "doctype": "Sales Invoice Item",
+ "item_code": "SKU010",
+ "parentfield": "items",
+ "qty": 50.0,
+ "rate": 900.0,
+ "conversion_factor": 1
+ }
+ ]
+ }
+]
\ No newline at end of file
diff --git a/erpnext/setup/demo_data/supplier.json b/erpnext/setup/demo_data/supplier.json
new file mode 100644
index 0000000..96c83d1
--- /dev/null
+++ b/erpnext/setup/demo_data/supplier.json
@@ -0,0 +1,17 @@
+[
+ {
+ "doctype": "Supplier",
+ "supplier_group": "Demo Supplier Group",
+ "supplier_name": "DQ Industries"
+ },
+ {
+ "doctype": "Supplier",
+ "supplier_group": "Demo Supplier Group",
+ "supplier_name": "MA Inc."
+ },
+ {
+ "doctype": "Supplier",
+ "supplier_group": "Demo Supplier Group",
+ "supplier_name": "KC Corp."
+ }
+]
\ No newline at end of file
diff --git a/erpnext/setup/demo_data/supplier_group.json b/erpnext/setup/demo_data/supplier_group.json
new file mode 100644
index 0000000..17070bf
--- /dev/null
+++ b/erpnext/setup/demo_data/supplier_group.json
@@ -0,0 +1,6 @@
+[
+ {
+ "doctype": "Supplier Group",
+ "supplier_group_name": "Demo Supplier Group"
+ }
+]
\ No newline at end of file
diff --git a/erpnext/setup/doctype/company/test_company.py b/erpnext/setup/doctype/company/test_company.py
index fd2fe30..0ed9621 100644
--- a/erpnext/setup/doctype/company/test_company.py
+++ b/erpnext/setup/doctype/company/test_company.py
@@ -195,6 +195,17 @@
child_company.save()
self.test_basic_tree()
+ def test_demo_data(self):
+ from erpnext.setup.demo import clear_demo_data, setup_demo_data
+
+ setup_demo_data()
+ company_name = frappe.db.get_value("Company", {"name": ("like", "%(Demo)")})
+ self.assertTrue(company_name)
+
+ clear_demo_data()
+ company_name = frappe.db.get_value("Company", {"name": ("like", "%(Demo)")})
+ self.assertFalse(company_name)
+
def create_company_communication(doctype, docname):
comm = frappe.get_doc(
diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.json b/erpnext/setup/doctype/global_defaults/global_defaults.json
index 823d2ba..bd80e1d 100644
--- a/erpnext/setup/doctype/global_defaults/global_defaults.json
+++ b/erpnext/setup/doctype/global_defaults/global_defaults.json
@@ -12,7 +12,8 @@
"default_currency",
"hide_currency_symbol",
"disable_rounded_total",
- "disable_in_words"
+ "disable_in_words",
+ "demo_company"
],
"fields": [
{
@@ -71,6 +72,14 @@
"fieldtype": "Check",
"in_list_view": 1,
"label": "Disable In Words"
+ },
+ {
+ "fieldname": "demo_company",
+ "fieldtype": "Link",
+ "hidden": 1,
+ "label": "Demo Company",
+ "options": "Company",
+ "read_only": 1
}
],
"icon": "fa fa-cog",
diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py
index 535c87d..2205924 100644
--- a/erpnext/setup/setup_wizard/operations/install_fixtures.py
+++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py
@@ -454,7 +454,6 @@
set_global_defaults(args)
update_stock_settings()
- update_shopping_cart_settings(args)
args.update({"set_default": 1})
create_bank_account(args)
@@ -490,7 +489,7 @@
def create_bank_account(args):
if not args.get("bank_account"):
- return
+ args["bank_account"] = _("Bank Account")
company_name = args.get("company_name")
bank_account_group = frappe.db.get_value(
@@ -529,20 +528,6 @@
pass
-def update_shopping_cart_settings(args): # nosemgrep
- shopping_cart = frappe.get_doc("E Commerce Settings")
- shopping_cart.update(
- {
- "enabled": 1,
- "company": args.company_name,
- "price_list": frappe.db.get_value("Price List", {"selling": 1}),
- "default_customer_group": _("Individual"),
- "quotation_series": "QTN-",
- }
- )
- shopping_cart.update_single(shopping_cart.get_valid_dict())
-
-
def get_fy_details(fy_start_date, fy_end_date):
start_year = getdate(fy_start_date).year
if start_year == getdate(fy_end_date).year:
diff --git a/erpnext/setup/setup_wizard/setup_wizard.py b/erpnext/setup/setup_wizard/setup_wizard.py
index 65b268e..ad49be6 100644
--- a/erpnext/setup/setup_wizard/setup_wizard.py
+++ b/erpnext/setup/setup_wizard/setup_wizard.py
@@ -5,6 +5,7 @@
import frappe
from frappe import _
+from ..demo import setup_demo_data
from .operations import install_fixtures as fixtures
@@ -37,6 +38,11 @@
],
},
{
+ "status": _("Setting up demo data"),
+ "fail_msg": _("Failed to setup demo data"),
+ "tasks": [{"fn": setup_demo, "args": args, "fail_msg": _("Failed to login")}],
+ },
+ {
"status": _("Wrapping up"),
"fail_msg": _("Failed to login"),
"tasks": [{"fn": fin, "args": args, "fail_msg": _("Failed to login")}],
@@ -63,6 +69,11 @@
login_as_first_user(args)
+def setup_demo(args):
+ if args.get("setup_demo"):
+ setup_demo_data()
+
+
def login_as_first_user(args):
if args.get("email") and hasattr(frappe.local, "login_manager"):
frappe.local.login_manager.login_as(args.get("email"))