Rushabh Mehta | e67d1fb | 2013-08-05 14:59:54 +0530 | [diff] [blame] | 1 | # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. |
| 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
Rushabh Mehta | ed186b7 | 2013-07-30 16:19:40 +0530 | [diff] [blame] | 4 | import webnotes, os |
| 5 | webnotes.session = webnotes._dict({"user":"Administrator"}) |
| 6 | from core.page.data_import_tool.data_import_tool import upload |
| 7 | |
| 8 | def make(): |
| 9 | webnotes.connect() |
Rushabh Mehta | 2b76a5e | 2013-08-02 15:16:59 +0530 | [diff] [blame] | 10 | webnotes.print_messages = True |
Rushabh Mehta | ed186b7 | 2013-07-30 16:19:40 +0530 | [diff] [blame] | 11 | webnotes.mute_emails = True |
| 12 | install() |
| 13 | complete_setup() |
| 14 | make_items() |
| 15 | make_customers_suppliers_contacts() |
Rushabh Mehta | 0b50b48 | 2013-08-06 17:53:41 +0530 | [diff] [blame] | 16 | make_users_and_employees() |
Rushabh Mehta | ed186b7 | 2013-07-30 16:19:40 +0530 | [diff] [blame] | 17 | # make_bom() |
| 18 | # make_opening_stock() |
| 19 | # make_opening_accounts() |
| 20 | |
| 21 | def install(): |
| 22 | print "Creating Fresh Database..." |
| 23 | from webnotes.install_lib.install import Installer |
| 24 | inst = Installer('root') |
| 25 | inst.import_from_db("demo", verbose = 1) |
| 26 | |
| 27 | def complete_setup(): |
| 28 | print "Complete Setup..." |
| 29 | webnotes.get_obj("Setup Control").setup_account({ |
| 30 | "first_name": "Test", |
| 31 | "last_name": "User", |
| 32 | "fy_start": "1st Jan", |
| 33 | "industry": "Manufacturing", |
| 34 | "company_name": "Wind Power LLC", |
| 35 | "company_abbr": "WP", |
Rushabh Mehta | 0b50b48 | 2013-08-06 17:53:41 +0530 | [diff] [blame] | 36 | "currency": "USD", |
Rushabh Mehta | ed186b7 | 2013-07-30 16:19:40 +0530 | [diff] [blame] | 37 | "timezone": "America/New York", |
| 38 | "country": "United States" |
| 39 | }) |
| 40 | |
| 41 | def make_items(): |
| 42 | print "Importing Items..." |
| 43 | webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Item.csv") |
| 44 | upload() |
Rushabh Mehta | 2b76a5e | 2013-08-02 15:16:59 +0530 | [diff] [blame] | 45 | print "Importing Item Prices..." |
| 46 | webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Item_Price.csv") |
| 47 | upload() |
Rushabh Mehta | ed186b7 | 2013-07-30 16:19:40 +0530 | [diff] [blame] | 48 | |
| 49 | def make_customers_suppliers_contacts(): |
| 50 | print "Importing Customers..." |
| 51 | webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Customer.csv") |
| 52 | upload() |
| 53 | print "Importing Suppliers..." |
| 54 | webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Supplier.csv") |
| 55 | upload() |
| 56 | print "Importing Contacts..." |
| 57 | webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Contact.csv") |
| 58 | upload() |
| 59 | print "Importing Address..." |
| 60 | webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Address.csv") |
| 61 | upload() |
| 62 | print "Importing Lead..." |
| 63 | webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Lead.csv") |
| 64 | upload() |
| 65 | |
Rushabh Mehta | 0b50b48 | 2013-08-06 17:53:41 +0530 | [diff] [blame] | 66 | def make_users_and_employees(): |
| 67 | print "Importing Profile..." |
| 68 | webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Profile.csv") |
| 69 | upload() |
| 70 | webnotes.conn.set_value("HR Settings", None, "emp_created_by", "Naming Series") |
| 71 | webnotes.conn.commit() |
| 72 | |
| 73 | print "Importing Employee..." |
| 74 | webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Employee.csv") |
| 75 | upload() |
| 76 | |
| 77 | print "Importing Salary Structure..." |
| 78 | webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Salary Structure.csv") |
| 79 | upload() |
Rushabh Mehta | ed186b7 | 2013-07-30 16:19:40 +0530 | [diff] [blame] | 80 | |
| 81 | if __name__=="__main__": |
| 82 | make() |