Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 1 | from __future__ import unicode_literals |
| 2 | |
| 3 | import random, json |
Neil Trini Lasrado | 0672459 | 2016-08-22 12:57:09 +0530 | [diff] [blame] | 4 | import frappe, erpnext |
| 5 | from frappe.utils import flt, now_datetime, cstr |
Nabin Hait | 74edfff | 2016-07-21 11:39:46 +0530 | [diff] [blame] | 6 | from frappe.utils.make_random import add_random_children, get_random |
Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 7 | from erpnext.demo.domains import data |
Saurabh | f589c82 | 2016-07-15 18:28:05 +0530 | [diff] [blame] | 8 | from frappe import _ |
Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 9 | |
Neil Trini Lasrado | 0672459 | 2016-08-22 12:57:09 +0530 | [diff] [blame] | 10 | def setup(domain): |
Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 11 | complete_setup(domain) |
| 12 | setup_demo_page() |
| 13 | setup_fiscal_year() |
| 14 | setup_holiday_list() |
Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 15 | setup_user() |
| 16 | setup_employee() |
| 17 | setup_salary_structure() |
Rohit Waghchaure | 8002d47 | 2016-07-13 16:03:05 +0530 | [diff] [blame] | 18 | setup_salary_structure_for_timesheet() |
Kanchan Chauhan | db0e57c | 2016-07-29 15:59:39 +0530 | [diff] [blame] | 19 | setup_leave_allocation() |
Neil Trini Lasrado | 0672459 | 2016-08-22 12:57:09 +0530 | [diff] [blame] | 20 | setup_user_roles() |
| 21 | setup_customer() |
| 22 | setup_supplier() |
| 23 | setup_warehouse() |
| 24 | import_json('Address') |
| 25 | import_json('Contact') |
| 26 | import_json('Lead') |
| 27 | setup_currency_exchange() |
Rohit Waghchaure | 7d439ec | 2016-07-21 14:50:59 +0530 | [diff] [blame] | 28 | setup_mode_of_payment() |
Saurabh | f589c82 | 2016-07-15 18:28:05 +0530 | [diff] [blame] | 29 | setup_account_to_expense_type() |
Nabin Hait | 74edfff | 2016-07-21 11:39:46 +0530 | [diff] [blame] | 30 | setup_budget() |
Rohit Waghchaure | 7d439ec | 2016-07-21 14:50:59 +0530 | [diff] [blame] | 31 | setup_pos_profile() |
Neil Trini Lasrado | 0672459 | 2016-08-22 12:57:09 +0530 | [diff] [blame] | 32 | |
Rushabh Mehta | 391c0ef | 2016-07-11 13:01:44 +0530 | [diff] [blame] | 33 | frappe.db.commit() |
| 34 | frappe.clear_cache() |
Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 35 | |
| 36 | def complete_setup(domain='Manufacturing'): |
| 37 | print "Complete Setup..." |
| 38 | from frappe.desk.page.setup_wizard.setup_wizard import setup_complete |
| 39 | |
| 40 | if not frappe.get_all('Company', limit=1): |
| 41 | setup_complete({ |
| 42 | "first_name": "Test", |
| 43 | "last_name": "User", |
| 44 | "email": "test_demo@erpnext.com", |
| 45 | "company_tagline": 'Awesome Products and Services', |
| 46 | "password": "test", |
| 47 | "fy_start_date": "2015-01-01", |
| 48 | "fy_end_date": "2015-12-31", |
| 49 | "bank_account": "National Bank", |
Rushabh Mehta | 04a64a7 | 2016-07-22 12:19:18 +0530 | [diff] [blame] | 50 | "domain": domain, |
Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 51 | "company_name": data.get(domain).get('company_name'), |
| 52 | "chart_of_accounts": "Standard", |
| 53 | "company_abbr": ''.join([d[0] for d in data.get(domain).get('company_name').split()]).upper(), |
| 54 | "currency": 'USD', |
| 55 | "timezone": 'America/New_York', |
| 56 | "country": 'United States', |
| 57 | "language": "english" |
| 58 | }) |
| 59 | |
| 60 | def setup_demo_page(): |
| 61 | # home page should always be "start" |
| 62 | website_settings = frappe.get_doc("Website Settings", "Website Settings") |
| 63 | website_settings.home_page = "demo" |
| 64 | website_settings.save() |
| 65 | |
| 66 | def setup_fiscal_year(): |
| 67 | fiscal_year = None |
Nabin Hait | 1606626 | 2016-07-21 11:00:28 +0530 | [diff] [blame] | 68 | for year in xrange(2010, now_datetime().year + 1, 1): |
Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 69 | try: |
| 70 | fiscal_year = frappe.get_doc({ |
| 71 | "doctype": "Fiscal Year", |
Saurabh | f589c82 | 2016-07-15 18:28:05 +0530 | [diff] [blame] | 72 | "year": cstr(year), |
Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 73 | "year_start_date": "{0}-01-01".format(year), |
| 74 | "year_end_date": "{0}-12-31".format(year) |
| 75 | }).insert() |
| 76 | except frappe.DuplicateEntryError: |
| 77 | pass |
| 78 | |
| 79 | # set the last fiscal year (current year) as default |
| 80 | fiscal_year.set_as_default() |
| 81 | |
| 82 | def setup_holiday_list(): |
| 83 | """Setup Holiday List for the current year""" |
Saurabh | f589c82 | 2016-07-15 18:28:05 +0530 | [diff] [blame] | 84 | year = now_datetime().year |
Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 85 | holiday_list = frappe.get_doc({ |
| 86 | "doctype": "Holiday List", |
| 87 | "holiday_list_name": str(year), |
| 88 | "from_date": "{0}-01-01".format(year), |
| 89 | "to_date": "{0}-12-31".format(year), |
| 90 | }) |
| 91 | holiday_list.insert() |
| 92 | holiday_list.weekly_off = "Saturday" |
| 93 | holiday_list.get_weekly_off_dates() |
| 94 | holiday_list.weekly_off = "Sunday" |
| 95 | holiday_list.get_weekly_off_dates() |
| 96 | holiday_list.save() |
| 97 | |
| 98 | frappe.set_value("Company", erpnext.get_default_company(), "default_holiday_list", holiday_list.name) |
| 99 | |
Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 100 | |
| 101 | def setup_user(): |
| 102 | frappe.db.sql('delete from tabUser where name not in ("Guest", "Administrator")') |
| 103 | for u in json.loads(open(frappe.get_app_path('erpnext', 'demo', 'data', 'user.json')).read()): |
| 104 | user = frappe.new_doc("User") |
| 105 | user.update(u) |
| 106 | user.flags.no_welcome_mail |
Rushabh Mehta | efe1ab7 | 2016-08-04 17:29:35 +0530 | [diff] [blame] | 107 | user.new_password = 'demo' |
Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 108 | user.insert() |
| 109 | |
Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 110 | def setup_employee(): |
| 111 | frappe.db.set_value("HR Settings", None, "emp_created_by", "Naming Series") |
| 112 | frappe.db.commit() |
| 113 | |
| 114 | import_json('Employee') |
| 115 | |
Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 116 | def setup_salary_structure(): |
| 117 | f = frappe.get_doc('Fiscal Year', frappe.defaults.get_global_default('fiscal_year')) |
| 118 | |
Kanchan Chauhan | db197d5 | 2016-08-20 00:30:59 +0530 | [diff] [blame] | 119 | ss = frappe.new_doc('Salary Structure') |
| 120 | ss.name = "Sample Salary Structure - " + str(f.year_start_date) |
Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 121 | for e in frappe.get_all('Employee', fields=['name', 'date_of_joining']): |
Kanchan Chauhan | db197d5 | 2016-08-20 00:30:59 +0530 | [diff] [blame] | 122 | ss.append('employees', { |
| 123 | 'employee': e.name, |
| 124 | 'base': random.random() * 10000 |
| 125 | }) |
Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 126 | |
| 127 | if not e.date_of_joining: |
| 128 | continue |
| 129 | |
| 130 | ss.from_date = e.date_of_joining if (e.date_of_joining |
| 131 | and e.date_of_joining > f.year_start_date) else f.year_start_date |
| 132 | ss.to_date = f.year_end_date |
Rushabh Mehta | cca33b2 | 2016-07-08 18:24:46 +0530 | [diff] [blame] | 133 | |
Kanchan Chauhan | db197d5 | 2016-08-20 00:30:59 +0530 | [diff] [blame] | 134 | ss.append('earnings', { |
| 135 | 'salary_component': 'Basic', |
| 136 | "abbr":'B', |
| 137 | 'condition': 'base > 5000', |
| 138 | 'formula': 'base*.2', |
| 139 | 'amount_based_on_formula': 1, |
| 140 | "idx": 1 |
| 141 | }) |
| 142 | ss.append('deductions', { |
| 143 | 'salary_component': 'Income Tax', |
| 144 | "abbr":'IT', |
| 145 | 'condition': 'base > 5000', |
| 146 | 'amount': random.random() * 1000, |
| 147 | "idx": 1 |
| 148 | }) |
| 149 | |
| 150 | ss.insert() |
Rushabh Mehta | 04a64a7 | 2016-07-22 12:19:18 +0530 | [diff] [blame] | 151 | |
Rohit Waghchaure | 8002d47 | 2016-07-13 16:03:05 +0530 | [diff] [blame] | 152 | def setup_salary_structure_for_timesheet(): |
| 153 | for e in frappe.get_all('Salary Structure', fields=['name'], filters={'is_active': 'Yes'}, limit=2): |
| 154 | ss_doc = frappe.get_doc("Salary Structure", e.name) |
| 155 | ss_doc.salary_slip_based_on_timesheet = 1 |
| 156 | ss_doc.salary_component = 'Basic' |
| 157 | ss_doc.hour_rate = flt(random.random() * 10, 2) |
| 158 | ss_doc.save(ignore_permissions=True) |
Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 159 | |
Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 160 | def setup_user_roles(): |
Rushabh Mehta | efe1ab7 | 2016-08-04 17:29:35 +0530 | [diff] [blame] | 161 | user = frappe.get_doc('User', 'demo@erpnext.com') |
| 162 | user.add_roles('HR User', 'HR Manager', 'Accounts User', 'Accounts Manager', |
| 163 | 'Stock User', 'Stock Manager', 'Sales User', 'Sales Manager', 'Purchase User', |
| 164 | 'Purchase Manager', 'Projects User', 'Manufacturing User', 'Manufacturing Manager', |
Neil Trini Lasrado | 0672459 | 2016-08-22 12:57:09 +0530 | [diff] [blame] | 165 | 'Support Team', 'Academics User') |
Rushabh Mehta | efe1ab7 | 2016-08-04 17:29:35 +0530 | [diff] [blame] | 166 | |
Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 167 | if not frappe.db.get_global('demo_hr_user'): |
| 168 | user = frappe.get_doc('User', 'CharmaineGaudreau@example.com') |
| 169 | user.add_roles('HR User', 'HR Manager', 'Accounts User') |
| 170 | frappe.db.set_global('demo_hr_user', user.name) |
| 171 | |
| 172 | if not frappe.db.get_global('demo_sales_user_1'): |
| 173 | user = frappe.get_doc('User', 'VakhitaRyzaev@example.com') |
| 174 | user.add_roles('Sales User') |
| 175 | frappe.db.set_global('demo_sales_user_1', user.name) |
| 176 | |
| 177 | if not frappe.db.get_global('demo_sales_user_2'): |
| 178 | user = frappe.get_doc('User', 'GabrielleLoftus@example.com') |
| 179 | user.add_roles('Sales User', 'Sales Manager', 'Accounts User') |
| 180 | frappe.db.set_global('demo_sales_user_2', user.name) |
Rushabh Mehta | ea0ff23 | 2016-07-07 14:02:26 +0530 | [diff] [blame] | 181 | |
| 182 | if not frappe.db.get_global('demo_purchase_user'): |
| 183 | user = frappe.get_doc('User', 'MichalSobczak@example.com') |
Rushabh Mehta | cca33b2 | 2016-07-08 18:24:46 +0530 | [diff] [blame] | 184 | user.add_roles('Purchase User', 'Purchase Manager', 'Accounts User', 'Stock User') |
Rushabh Mehta | ea0ff23 | 2016-07-07 14:02:26 +0530 | [diff] [blame] | 185 | frappe.db.set_global('demo_purchase_user', user.name) |
Rushabh Mehta | cca33b2 | 2016-07-08 18:24:46 +0530 | [diff] [blame] | 186 | |
| 187 | if not frappe.db.get_global('demo_manufacturing_user'): |
| 188 | user = frappe.get_doc('User', 'NuranVerkleij@example.com') |
| 189 | user.add_roles('Manufacturing User', 'Stock User', 'Purchase User', 'Accounts User') |
| 190 | frappe.db.set_global('demo_manufacturing_user', user.name) |
| 191 | |
| 192 | if not frappe.db.get_global('demo_stock_user'): |
| 193 | user = frappe.get_doc('User', 'HatsueKashiwagi@example.com') |
| 194 | user.add_roles('Manufacturing User', 'Stock User', 'Purchase User', 'Accounts User') |
| 195 | frappe.db.set_global('demo_stock_user', user.name) |
| 196 | |
Rushabh Mehta | 8cfe18e | 2016-07-13 11:29:59 +0530 | [diff] [blame] | 197 | if not frappe.db.get_global('demo_accounts_user'): |
| 198 | user = frappe.get_doc('User', 'LeonAbdulov@example.com') |
Rushabh Mehta | 92d1b8c | 2016-07-14 15:46:12 +0530 | [diff] [blame] | 199 | user.add_roles('Accounts User', 'Accounts Manager', 'Sales User', 'Purchase User') |
Rushabh Mehta | 8cfe18e | 2016-07-13 11:29:59 +0530 | [diff] [blame] | 200 | frappe.db.set_global('demo_accounts_user', user.name) |
Rushabh Mehta | 04a64a7 | 2016-07-22 12:19:18 +0530 | [diff] [blame] | 201 | |
Rohit Waghchaure | 8002d47 | 2016-07-13 16:03:05 +0530 | [diff] [blame] | 202 | if not frappe.db.get_global('demo_projects_user'): |
| 203 | user = frappe.get_doc('User', 'panca@example.com') |
| 204 | user.add_roles('HR User', 'Projects User') |
| 205 | frappe.db.set_global('demo_projects_user', user.name) |
Rushabh Mehta | 8cfe18e | 2016-07-13 11:29:59 +0530 | [diff] [blame] | 206 | |
Neil Trini Lasrado | 0672459 | 2016-08-22 12:57:09 +0530 | [diff] [blame] | 207 | if not frappe.db.get_global('demo_schools_user'): |
| 208 | user = frappe.get_doc('User', 'aromn@example.com') |
| 209 | user.add_roles('Academics User') |
| 210 | frappe.db.set_global('demo_schools_user', user.name) |
| 211 | |
| 212 | #Add Expense Approver |
| 213 | user = frappe.get_doc('User', 'WanMai@example.com') |
| 214 | user.add_roles('Expense Approver') |
| 215 | |
Kanchan Chauhan | db0e57c | 2016-07-29 15:59:39 +0530 | [diff] [blame] | 216 | def setup_leave_allocation(): |
| 217 | year = now_datetime().year |
| 218 | for employee in frappe.get_all('Employee', fields=['name']): |
| 219 | leave_types = frappe.get_all("Leave Type", fields=['name', 'max_days_allowed']) |
| 220 | for leave_type in leave_types: |
| 221 | if not leave_type.max_days_allowed: |
| 222 | leave_type.max_days_allowed = 10 |
Rushabh Mehta | efe1ab7 | 2016-08-04 17:29:35 +0530 | [diff] [blame] | 223 | |
Kanchan Chauhan | db0e57c | 2016-07-29 15:59:39 +0530 | [diff] [blame] | 224 | leave_allocation = frappe.get_doc({ |
| 225 | "doctype": "Leave Allocation", |
| 226 | "employee": employee.name, |
| 227 | "from_date": "{0}-01-01".format(year), |
| 228 | "to_date": "{0}-12-31".format(year), |
| 229 | "leave_type": leave_type.name, |
| 230 | "new_leaves_allocated": random.randint(1, int(leave_type.max_days_allowed)) |
| 231 | }) |
| 232 | leave_allocation.insert() |
| 233 | leave_allocation.submit() |
Rushabh Mehta | efe1ab7 | 2016-08-04 17:29:35 +0530 | [diff] [blame] | 234 | frappe.db.commit() |
Neil Trini Lasrado | 0672459 | 2016-08-22 12:57:09 +0530 | [diff] [blame] | 235 | |
| 236 | def setup_customer(): |
| 237 | customers = [u'Asian Junction', u'Life Plan Counselling', u'Two Pesos', u'Mr Fables', u'Intelacard', u'Big D Supermarkets', u'Adaptas', u'Nelson Brothers', u'Landskip Yard Care', u'Buttrey Food & Drug', u'Fayva', u'Asian Fusion', u'Crafts Canada', u'Consumers and Consumers Express', u'Netobill', u'Choices', u'Chi-Chis', u'Red Food', u'Endicott Shoes', u'Hind Enterprises'] |
| 238 | for c in customers: |
| 239 | frappe.get_doc({ |
| 240 | "doctype": "Customer", |
| 241 | "customer_name": c, |
| 242 | "customer_group": "Commercial", |
| 243 | "customer_type": random.choice(["Company", "Individual"]), |
| 244 | "territory": "Rest Of The World" |
| 245 | }).insert() |
| 246 | |
| 247 | def setup_supplier(): |
| 248 | suppliers = [u'Helios Air', u'Ks Merchandise', u'HomeBase', u'Scott Ties', u'Reliable Investments', u'Nan Duskin', u'Rainbow Records', u'New World Realty', u'Asiatic Solutions', u'Eagle Hardware', u'Modern Electricals'] |
| 249 | for s in suppliers: |
| 250 | frappe.get_doc({ |
| 251 | "doctype": "Supplier", |
| 252 | "supplier_name": s, |
| 253 | "supplier_type": random.choice(["Services", "Raw Material"]), |
| 254 | }).insert() |
| 255 | |
| 256 | def setup_warehouse(): |
| 257 | w = frappe.new_doc('Warehouse') |
| 258 | w.warehouse_name = 'Supplier' |
| 259 | w.insert() |
| 260 | |
| 261 | def setup_currency_exchange(): |
| 262 | frappe.get_doc({ |
| 263 | 'doctype': 'Currency Exchange', |
| 264 | 'from_currency': 'EUR', |
| 265 | 'to_currency': 'USD', |
| 266 | 'exchange_rate': 1.13 |
| 267 | }).insert() |
| 268 | |
| 269 | frappe.get_doc({ |
| 270 | 'doctype': 'Currency Exchange', |
| 271 | 'from_currency': 'CNY', |
| 272 | 'to_currency': 'USD', |
| 273 | 'exchange_rate': 0.16 |
| 274 | }).insert() |
| 275 | |
| 276 | def setup_mode_of_payment(): |
| 277 | company_abbr = frappe.db.get_value("Company", erpnext.get_default_company(), "abbr") |
| 278 | account_dict = {'Cash': 'Cash - '+ company_abbr , 'Bank': 'National Bank - '+ company_abbr} |
| 279 | for payment_mode in frappe.get_all('Mode of Payment', fields = ["name", "type"]): |
| 280 | if payment_mode.type: |
| 281 | mop = frappe.get_doc('Mode of Payment', payment_mode.name) |
| 282 | mop.append('accounts', { |
| 283 | 'company': erpnext.get_default_company(), |
| 284 | 'default_account': account_dict.get(payment_mode.type) |
| 285 | }) |
| 286 | mop.save(ignore_permissions=True) |
| 287 | |
| 288 | def setup_account(): |
| 289 | frappe.flags.in_import = True |
| 290 | data = json.loads(open(frappe.get_app_path('erpnext', 'demo', 'data', |
| 291 | 'account.json')).read()) |
| 292 | for d in data: |
| 293 | doc = frappe.new_doc('Account') |
| 294 | doc.update(d) |
| 295 | doc.parent_account = frappe.db.get_value('Account', {'account_name': doc.parent_account}) |
| 296 | doc.insert() |
| 297 | |
| 298 | def setup_account_to_expense_type(): |
| 299 | company_abbr = frappe.db.get_value("Company", erpnext.get_default_company(), "abbr") |
| 300 | expense_types = [{'name': _('Calls'), "account": "Sales Expenses - "+ company_abbr}, |
| 301 | {'name': _('Food'), "account": "Entertainment Expenses - "+ company_abbr}, |
| 302 | {'name': _('Medical'), "account": "Utility Expenses - "+ company_abbr}, |
| 303 | {'name': _('Others'), "account": "Miscellaneous Expenses - "+ company_abbr}, |
| 304 | {'name': _('Travel'), "account": "Travel Expenses - "+ company_abbr}] |
| 305 | |
| 306 | for expense_type in expense_types: |
| 307 | doc = frappe.get_doc("Expense Claim Type", expense_type["name"]) |
| 308 | doc.append("accounts", { |
| 309 | "company" : erpnext.get_default_company(), |
| 310 | "default_account" : expense_type["account"] |
| 311 | }) |
| 312 | doc.save(ignore_permissions=True) |
| 313 | |
| 314 | def setup_budget(): |
| 315 | fiscal_years = frappe.get_all("Fiscal Year", order_by="year_start_date")[-2:] |
| 316 | |
| 317 | for fy in fiscal_years: |
| 318 | budget = frappe.new_doc("Budget") |
| 319 | budget.cost_center = get_random("Cost Center") |
| 320 | budget.fiscal_year = fy.name |
| 321 | budget.action_if_annual_budget_exceeded = "Warn" |
| 322 | expense_ledger_count = frappe.db.count("Account", {"is_group": "0", "root_type": "Expense"}) |
| 323 | |
| 324 | add_random_children(budget, "accounts", rows=random.randint(10, expense_ledger_count), randomize = { "account": ("Account", {"is_group": "0", "root_type": "Expense"}) |
| 325 | }, unique="account") |
| 326 | |
| 327 | for d in budget.accounts: |
| 328 | d.budget_amount = random.randint(5, 100) * 10000 |
| 329 | |
| 330 | budget.save() |
| 331 | budget.submit() |
| 332 | |
| 333 | def setup_pos_profile(): |
| 334 | company_abbr = frappe.db.get_value("Company", erpnext.get_default_company(), "abbr") |
| 335 | pos = frappe.new_doc('POS Profile') |
| 336 | pos.user = frappe.db.get_global('demo_accounts_user') |
| 337 | pos.naming_series = 'SINV-' |
| 338 | pos.update_stock = 0 |
| 339 | pos.write_off_account = 'Cost of Goods Sold - '+ company_abbr |
| 340 | pos.write_off_cost_center = 'Main - '+ company_abbr |
| 341 | |
| 342 | pos.append('payments', { |
| 343 | 'mode_of_payment': frappe.db.get_value('Mode of Payment', {'type': 'Cash'}, 'name'), |
| 344 | 'amount': 0.0 |
| 345 | }) |
| 346 | |
| 347 | pos.insert() |
| 348 | |
| 349 | def import_json(doctype, submit=False, values=None): |
| 350 | frappe.flags.in_import = True |
| 351 | data = json.loads(open(frappe.get_app_path('erpnext', 'demo', 'data', |
| 352 | frappe.scrub(doctype) + '.json')).read()) |
| 353 | for d in data: |
| 354 | doc = frappe.new_doc(doctype) |
| 355 | doc.update(d) |
| 356 | doc.insert() |
| 357 | if submit: |
| 358 | doc.submit() |
| 359 | |
| 360 | frappe.db.commit() |
| 361 | |
| 362 | |