blob: 28841441354ad29b9203cc9ecbfffbe7a609bbfd [file] [log] [blame]
Rushabh Mehtae67d1fb2013-08-05 14:59:54 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
2# License: GNU General Public License v3. See license.txt
3
Rushabh Mehta7c2a2e22013-08-07 15:08:11 +05304import webnotes, os, datetime
5import webnotes.utils
Rushabh Mehta622c98d2013-08-22 15:17:58 +05306from webnotes.utils import random_string
Rushabh Mehta0b995402013-08-09 15:29:59 +05307from webnotes.widgets import query_report
Rushabh Mehta7c2a2e22013-08-07 15:08:11 +05308import random
Rushabh Mehta4a404e92013-08-09 18:11:35 +05309import json
Rushabh Mehta7c2a2e22013-08-07 15:08:11 +053010
Rushabh Mehtaed186b72013-07-30 16:19:40 +053011webnotes.session = webnotes._dict({"user":"Administrator"})
12from core.page.data_import_tool.data_import_tool import upload
13
Rushabh Mehta0b995402013-08-09 15:29:59 +053014# fix price list
15# fix fiscal year
16
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +053017company = "Wind Power LLC"
Rushabh Mehta622c98d2013-08-22 15:17:58 +053018company_abbr = "WP"
Rushabh Mehta20a10942013-08-20 15:18:42 +053019country = "United States"
20currency = "USD"
21time_zone = "America/New York"
Rushabh Mehta7c2a2e22013-08-07 15:08:11 +053022start_date = '2010-01-01'
Rushabh Mehta622c98d2013-08-22 15:17:58 +053023bank_name = "Citibank"
Rushabh Mehta4a404e92013-08-09 18:11:35 +053024runs_for = 20
Rushabh Mehta7c2a2e22013-08-07 15:08:11 +053025prob = {
Rushabh Mehta20a10942013-08-20 15:18:42 +053026 "default": { "make": 0.6, "qty": (1,5) },
Rushabh Mehta16a62fa2013-08-23 13:16:22 +053027 "Sales Order": { "make": 0.4, "qty": (1,3) },
Rushabh Mehta20a10942013-08-20 15:18:42 +053028 "Purchase Order": { "make": 0.7, "qty": (1,15) },
29 "Purchase Receipt": { "make": 0.7, "qty": (1,15) },
Rushabh Mehta7c2a2e22013-08-07 15:08:11 +053030}
31
Rushabh Mehta4c17f942013-08-12 14:18:09 +053032def make(reset=False):
Rushabh Mehtaed186b72013-07-30 16:19:40 +053033 webnotes.connect()
Rushabh Mehta16a62fa2013-08-23 13:16:22 +053034 #webnotes.print_messages = True
Rushabh Mehtaed186b72013-07-30 16:19:40 +053035 webnotes.mute_emails = True
Rushabh Mehta62030e02013-08-14 18:37:28 +053036 webnotes.rollback_on_exception = True
Rushabh Mehta4a404e92013-08-09 18:11:35 +053037
Rushabh Mehta4c17f942013-08-12 14:18:09 +053038 if reset:
39 setup()
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +053040 simulate()
Rushabh Mehta7c2a2e22013-08-07 15:08:11 +053041
42def setup():
Rushabh Mehtaed186b72013-07-30 16:19:40 +053043 install()
44 complete_setup()
Rushabh Mehtaed186b72013-07-30 16:19:40 +053045 make_customers_suppliers_contacts()
Rushabh Mehta4a404e92013-08-09 18:11:35 +053046 make_items()
Rushabh Mehta0b50b482013-08-06 17:53:41 +053047 make_users_and_employees()
Rushabh Mehta622c98d2013-08-22 15:17:58 +053048 make_bank_account()
Rushabh Mehtaed186b72013-07-30 16:19:40 +053049 # make_opening_stock()
50 # make_opening_accounts()
Rushabh Mehta7c2a2e22013-08-07 15:08:11 +053051
52def simulate():
53 current_date = None
54 for i in xrange(runs_for):
55 if not current_date:
Rushabh Mehta20a10942013-08-20 15:18:42 +053056 # get last stock ledger posting date or use default
57 last_posting = webnotes.conn.sql("""select max(posting_date) from `tabStock Ledger Entry`""")
58 if last_posting[0][0]:
59 current_date = webnotes.utils.add_days(last_posting[0][0], 1)
60 else:
61 current_date = webnotes.utils.getdate(start_date)
Rushabh Mehta7c2a2e22013-08-07 15:08:11 +053062 else:
63 current_date = webnotes.utils.add_days(current_date, 1)
Rushabh Mehta20a10942013-08-20 15:18:42 +053064
65 print current_date.strftime("%Y-%m-%d")
66
Rushabh Mehta7c2a2e22013-08-07 15:08:11 +053067 if current_date.weekday() in (5, 6):
68 continue
69
70 run_sales(current_date)
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +053071 run_purchase(current_date)
72 run_manufacturing(current_date)
Rushabh Mehta0b995402013-08-09 15:29:59 +053073 run_stock(current_date)
Rushabh Mehta622c98d2013-08-22 15:17:58 +053074 run_accounts(current_date)
Rushabh Mehta7c2a2e22013-08-07 15:08:11 +053075
Rushabh Mehta7c2a2e22013-08-07 15:08:11 +053076def run_sales(current_date):
Rushabh Mehta0b995402013-08-09 15:29:59 +053077 if can_make("Quotation"):
78 for i in xrange(how_many("Quotation")):
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +053079 make_quotation(current_date)
Rushabh Mehta0b995402013-08-09 15:29:59 +053080
81 if can_make("Sales Order"):
82 for i in xrange(how_many("Sales Order")):
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +053083 make_sales_order(current_date)
84
Rushabh Mehta622c98d2013-08-22 15:17:58 +053085def run_accounts(current_date):
86 if can_make("Sales Invoice"):
87 from selling.doctype.sales_order.sales_order import make_sales_invoice
88 report = "Ordered Items to be Billed"
89 for so in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Sales Invoice")]:
90 si = webnotes.bean(make_sales_invoice(so))
91 si.doc.posting_date = current_date
92 si.insert()
93 si.submit()
94 webnotes.conn.commit()
95
96 if can_make("Purchase Invoice"):
97 from stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
98 report = "Received Items to be Billed"
99 for pr in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Purchase Invoice")]:
100 pi = webnotes.bean(make_purchase_invoice(pr))
101 pi.doc.posting_date = current_date
102 pi.doc.bill_no = random_string(6)
103 pi.insert()
104 pi.submit()
105 webnotes.conn.commit()
106
107 if can_make("Payment Received"):
108 from accounts.doctype.journal_voucher.journal_voucher import get_payment_entry_from_sales_invoice
109 report = "Accounts Receivable"
110 for si in list(set([r[4] for r in query_report.run(report, {"report_date": current_date })["result"] if r[3]=="Sales Invoice"]))[:how_many("Payment Received")]:
111 jv = webnotes.bean(get_payment_entry_from_sales_invoice(si))
112 jv.doc.posting_date = current_date
113 jv.doc.cheque_no = random_string(6)
114 jv.doc.cheque_date = current_date
115 jv.insert()
116 jv.submit()
117 webnotes.conn.commit()
118
119 if can_make("Payment Made"):
120 from accounts.doctype.journal_voucher.journal_voucher import get_payment_entry_from_purchase_invoice
121 report = "Accounts Payable"
122 for pi in list(set([r[4] for r in query_report.run(report, {"report_date": current_date })["result"] if r[3]=="Purchase Invoice"]))[:how_many("Payment Made")]:
123 jv = webnotes.bean(get_payment_entry_from_purchase_invoice(pi))
124 jv.doc.posting_date = current_date
125 jv.doc.cheque_no = random_string(6)
126 jv.doc.cheque_date = current_date
127 jv.insert()
128 jv.submit()
129 webnotes.conn.commit()
130
Rushabh Mehta0b995402013-08-09 15:29:59 +0530131def run_stock(current_date):
132 # make purchase requests
Rushabh Mehta4c17f942013-08-12 14:18:09 +0530133 if can_make("Purchase Receipt"):
134 from buying.doctype.purchase_order.purchase_order import make_purchase_receipt
135 report = "Purchase Order Items To Be Received"
136 for po in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Purchase Receipt")]:
137 pr = webnotes.bean(make_purchase_receipt(po))
138 pr.doc.posting_date = current_date
139 pr.doc.fiscal_year = "2010"
140 pr.insert()
141 pr.submit()
Rushabh Mehta6ca903f2013-08-13 14:31:15 +0530142 webnotes.conn.commit()
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +0530143
Rushabh Mehta0b995402013-08-09 15:29:59 +0530144 # make delivery notes (if possible)
Rushabh Mehta4c17f942013-08-12 14:18:09 +0530145 if can_make("Delivery Note"):
146 from selling.doctype.sales_order.sales_order import make_delivery_note
Rushabh Mehta20a10942013-08-20 15:18:42 +0530147 from stock.stock_ledger import NegativeStockError
148 from stock.doctype.stock_ledger_entry.stock_ledger_entry import SerialNoRequiredError, SerialNoQtyError
Rushabh Mehta4c17f942013-08-12 14:18:09 +0530149 report = "Ordered Items To Be Delivered"
150 for so in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Delivery Note")]:
151 dn = webnotes.bean(make_delivery_note(so))
152 dn.doc.posting_date = current_date
153 dn.doc.fiscal_year = "2010"
154 dn.insert()
Rushabh Mehta20a10942013-08-20 15:18:42 +0530155 try:
156 dn.submit()
157 webnotes.conn.commit()
158 except NegativeStockError: pass
159 except SerialNoRequiredError: pass
160 except SerialNoQtyError: pass
161
162 # try submitting existing
163 for dn in webnotes.conn.get_values("Delivery Note", {"docstatus": 0}, "name"):
164 b = webnotes.bean("Delivery Note", dn[0])
165 b.submit()
166 webnotes.conn.commit()
167
Rushabh Mehta0b995402013-08-09 15:29:59 +0530168def run_purchase(current_date):
Rushabh Mehta20a10942013-08-20 15:18:42 +0530169 # make material requests for purchase items that have negative projected qtys
170 if can_make("Material Request"):
171 report = "Items To Be Requested"
172 for row in query_report.run(report)["result"][:how_many("Material Request")]:
173 mr = webnotes.new_bean("Material Request")
174 mr.doc.material_request_type = "Purchase"
175 mr.doc.transaction_date = current_date
176 mr.doc.fiscal_year = "2010"
177 mr.doclist.append({
178 "doctype": "Material Request Item",
179 "parentfield": "indent_details",
180 "schedule_date": webnotes.utils.add_days(current_date, 7),
181 "item_code": row[0],
182 "qty": -row[-1]
183 })
184 mr.insert()
185 mr.submit()
186
Rushabh Mehta0b995402013-08-09 15:29:59 +0530187 # make supplier quotations
188 if can_make("Supplier Quotation"):
189 from stock.doctype.material_request.material_request import make_supplier_quotation
190 report = "Material Requests for which Supplier Quotations are not created"
191 for row in query_report.run(report)["result"][:how_many("Supplier Quotation")]:
Rushabh Mehta4a404e92013-08-09 18:11:35 +0530192 if row[0] != "Total":
193 sq = webnotes.bean(make_supplier_quotation(row[0]))
194 sq.doc.transaction_date = current_date
195 sq.doc.fiscal_year = "2010"
196 sq.insert()
197 sq.submit()
Rushabh Mehta6ca903f2013-08-13 14:31:15 +0530198 webnotes.conn.commit()
Rushabh Mehta0b995402013-08-09 15:29:59 +0530199
200 # make purchase orders
201 if can_make("Purchase Order"):
202 from stock.doctype.material_request.material_request import make_purchase_order
203 report = "Requested Items To Be Ordered"
204 for row in query_report.run(report)["result"][:how_many("Purchase Order")]:
Rushabh Mehta4a404e92013-08-09 18:11:35 +0530205 if row[0] != "Total":
206 po = webnotes.bean(make_purchase_order(row[0]))
207 po.doc.transaction_date = current_date
208 po.doc.fiscal_year = "2010"
209 po.insert()
210 po.submit()
Rushabh Mehta6ca903f2013-08-13 14:31:15 +0530211 webnotes.conn.commit()
Rushabh Mehta0b995402013-08-09 15:29:59 +0530212
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +0530213def run_manufacturing(current_date):
Rushabh Mehta6ca903f2013-08-13 14:31:15 +0530214 from stock.stock_ledger import NegativeStockError
Rushabh Mehta20a10942013-08-20 15:18:42 +0530215 from stock.doctype.stock_entry.stock_entry import IncorrectValuationRateError, DuplicateEntryForProductionOrderError
Rushabh Mehta6ca903f2013-08-13 14:31:15 +0530216
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +0530217 ppt = webnotes.bean("Production Planning Tool", "Production Planning Tool")
218 ppt.doc.company = company
219 ppt.doc.use_multi_level_bom = 1
220 ppt.doc.purchase_request_for_warehouse = "Stores - WP"
221 ppt.run_method("get_open_sales_orders")
222 ppt.run_method("get_items_from_so")
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +0530223 ppt.run_method("raise_production_order")
224 ppt.run_method("raise_purchase_request")
Rushabh Mehta6ca903f2013-08-13 14:31:15 +0530225 webnotes.conn.commit()
Rushabh Mehta2c968ce2013-08-08 14:16:39 +0530226
227 # submit production orders
Rushabh Mehta20a10942013-08-20 15:18:42 +0530228 for pro in webnotes.conn.get_values("Production Order", {"docstatus": 0}, "name"):
Rushabh Mehta2c968ce2013-08-08 14:16:39 +0530229 b = webnotes.bean("Production Order", pro[0])
230 b.doc.wip_warehouse = "Work in Progress - WP"
231 b.submit()
Rushabh Mehta6ca903f2013-08-13 14:31:15 +0530232 webnotes.conn.commit()
Rushabh Mehta75c31712013-08-08 16:00:40 +0530233
234 # submit material requests
Rushabh Mehta20a10942013-08-20 15:18:42 +0530235 for pro in webnotes.conn.get_values("Material Request", {"docstatus": 0}, "name"):
Rushabh Mehta75c31712013-08-08 16:00:40 +0530236 b = webnotes.bean("Material Request", pro[0])
237 b.submit()
Rushabh Mehta6ca903f2013-08-13 14:31:15 +0530238 webnotes.conn.commit()
Rushabh Mehta2c968ce2013-08-08 14:16:39 +0530239
Rushabh Mehta4c17f942013-08-12 14:18:09 +0530240 # stores -> wip
241 if can_make("Stock Entry for WIP"):
242 for pro in query_report.run("Open Production Orders")["result"][:how_many("Stock Entry for WIP")]:
243 make_stock_entry_from_pro(pro[0], "Material Transfer", current_date)
244
245 # wip -> fg
246 if can_make("Stock Entry for FG"):
247 for pro in query_report.run("Production Orders in Progress")["result"][:how_many("Stock Entry for FG")]:
248 make_stock_entry_from_pro(pro[0], "Manufacture/Repack", current_date)
249
250 # try posting older drafts (if exists)
Rushabh Mehta20a10942013-08-20 15:18:42 +0530251 for st in webnotes.conn.get_values("Stock Entry", {"docstatus":0}, "name"):
Rushabh Mehta4c17f942013-08-12 14:18:09 +0530252 try:
253 webnotes.bean("Stock Entry", st[0]).submit()
Rushabh Mehta6ca903f2013-08-13 14:31:15 +0530254 webnotes.conn.commit()
Rushabh Mehta4c17f942013-08-12 14:18:09 +0530255 except NegativeStockError: pass
256 except IncorrectValuationRateError: pass
Rushabh Mehta20a10942013-08-20 15:18:42 +0530257 except DuplicateEntryForProductionOrderError: pass
Rushabh Mehta4c17f942013-08-12 14:18:09 +0530258
259def make_stock_entry_from_pro(pro_id, purpose, current_date):
260 from manufacturing.doctype.production_order.production_order import make_stock_entry
261 from stock.stock_ledger import NegativeStockError
Rushabh Mehta20a10942013-08-20 15:18:42 +0530262 from stock.doctype.stock_entry.stock_entry import IncorrectValuationRateError, DuplicateEntryForProductionOrderError
Rushabh Mehta4c17f942013-08-12 14:18:09 +0530263
264 st = webnotes.bean(make_stock_entry(pro_id, purpose))
Rushabh Mehta4c17f942013-08-12 14:18:09 +0530265 st.doc.posting_date = current_date
266 st.doc.fiscal_year = "2010"
267 st.doc.expense_adjustment_account = "Stock in Hand - WP"
268 try:
269 st.insert()
Rushabh Mehta6ca903f2013-08-13 14:31:15 +0530270 webnotes.conn.commit()
Rushabh Mehta4c17f942013-08-12 14:18:09 +0530271 st.submit()
Rushabh Mehta6ca903f2013-08-13 14:31:15 +0530272 webnotes.conn.commit()
Rushabh Mehta4c17f942013-08-12 14:18:09 +0530273 except NegativeStockError: pass
274 except IncorrectValuationRateError: pass
Rushabh Mehta20a10942013-08-20 15:18:42 +0530275 except DuplicateEntryForProductionOrderError: pass
Rushabh Mehta4c17f942013-08-12 14:18:09 +0530276
Rushabh Mehta7c2a2e22013-08-07 15:08:11 +0530277def make_quotation(current_date):
278 b = webnotes.bean([{
279 "creation": current_date,
280 "doctype": "Quotation",
281 "quotation_to": "Customer",
282 "customer": get_random("Customer"),
283 "order_type": "Sales",
Rushabh Mehta7c2a2e22013-08-07 15:08:11 +0530284 "transaction_date": current_date,
285 "fiscal_year": "2010"
286 }])
287
288 add_random_children(b, {
289 "doctype": "Quotation Item",
290 "parentfield": "quotation_details",
291 }, rows=3, randomize = {
292 "qty": (1, 5),
293 "item_code": ("Item", {"is_sales_item": "Yes"})
294 }, unique="item_code")
295
296 b.insert()
Rushabh Mehta6ca903f2013-08-13 14:31:15 +0530297 webnotes.conn.commit()
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +0530298 b.submit()
Rushabh Mehta6ca903f2013-08-13 14:31:15 +0530299 webnotes.conn.commit()
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +0530300
301def make_sales_order(current_date):
302 q = get_random("Quotation", {"status": "Submitted"})
Rushabh Mehta4a404e92013-08-09 18:11:35 +0530303 if q:
304 from selling.doctype.quotation.quotation import make_sales_order
305 so = webnotes.bean(make_sales_order(q))
306 so.doc.transaction_date = current_date
307 so.doc.delivery_date = webnotes.utils.add_days(current_date, 10)
308 so.insert()
Rushabh Mehta6ca903f2013-08-13 14:31:15 +0530309 webnotes.conn.commit()
Rushabh Mehta4a404e92013-08-09 18:11:35 +0530310 so.submit()
Rushabh Mehta6ca903f2013-08-13 14:31:15 +0530311 webnotes.conn.commit()
Rushabh Mehta7c2a2e22013-08-07 15:08:11 +0530312
313def add_random_children(bean, template, rows, randomize, unique=None):
314 for i in xrange(random.randrange(1, rows)):
315 d = template.copy()
316 for key, val in randomize.items():
317 if isinstance(val[0], basestring):
318 d[key] = get_random(*val)
319 else:
320 d[key] = random.randrange(*val)
321
322 if unique:
323 if not bean.doclist.get({"doctype": d["doctype"], unique:d[unique]}):
324 bean.doclist.append(d)
325 else:
326 bean.doclist.append(d)
327
Rushabh Mehta7c2a2e22013-08-07 15:08:11 +0530328def get_random(doctype, filters=None):
329 condition = []
330 if filters:
331 for key, val in filters.items():
332 condition.append("%s='%s'" % (key, val))
333 if condition:
334 condition = " where " + " and ".join(condition)
335 else:
336 condition = ""
337
338 out = webnotes.conn.sql("""select name from `tab%s` %s
Rushabh Mehta4a404e92013-08-09 18:11:35 +0530339 order by RAND() limit 0,1""" % (doctype, condition))
Rushabh Mehta7c2a2e22013-08-07 15:08:11 +0530340
Rushabh Mehta4a404e92013-08-09 18:11:35 +0530341 return out and out[0][0] or None
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +0530342
Rushabh Mehta0b995402013-08-09 15:29:59 +0530343def can_make(doctype):
Rushabh Mehta20a10942013-08-20 15:18:42 +0530344 return random.random() < prob.get(doctype, prob["default"])["make"]
Rushabh Mehta0b995402013-08-09 15:29:59 +0530345
346def how_many(doctype):
Rushabh Mehta20a10942013-08-20 15:18:42 +0530347 return random.randrange(*prob.get(doctype, prob["default"])["qty"])
Rushabh Mehta0b995402013-08-09 15:29:59 +0530348
Rushabh Mehtaed186b72013-07-30 16:19:40 +0530349def install():
350 print "Creating Fresh Database..."
351 from webnotes.install_lib.install import Installer
352 inst = Installer('root')
353 inst.import_from_db("demo", verbose = 1)
354
355def complete_setup():
356 print "Complete Setup..."
357 webnotes.get_obj("Setup Control").setup_account({
358 "first_name": "Test",
359 "last_name": "User",
360 "fy_start": "1st Jan",
361 "industry": "Manufacturing",
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +0530362 "company_name": company,
Rushabh Mehta622c98d2013-08-22 15:17:58 +0530363 "company_abbr": company_abbr,
Rushabh Mehta20a10942013-08-20 15:18:42 +0530364 "currency": currency,
365 "timezone": time_zone,
366 "country": country
Rushabh Mehtaed186b72013-07-30 16:19:40 +0530367 })
Rushabh Mehta7c2a2e22013-08-07 15:08:11 +0530368
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +0530369 import_data("Fiscal_Year")
Rushabh Mehtaed186b72013-07-30 16:19:40 +0530370
371def make_items():
Rushabh Mehta20a10942013-08-20 15:18:42 +0530372 import_data("Item")
Rushabh Mehta4a404e92013-08-09 18:11:35 +0530373 import_data("BOM", submit=True)
Rushabh Mehtaed186b72013-07-30 16:19:40 +0530374
375def make_customers_suppliers_contacts():
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +0530376 import_data(["Customer", "Supplier", "Contact", "Address", "Lead"])
Rushabh Mehtaed186b72013-07-30 16:19:40 +0530377
Rushabh Mehta0b50b482013-08-06 17:53:41 +0530378def make_users_and_employees():
Rushabh Mehta0b50b482013-08-06 17:53:41 +0530379 webnotes.conn.set_value("HR Settings", None, "emp_created_by", "Naming Series")
380 webnotes.conn.commit()
381
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +0530382 import_data(["Profile", "Employee", "Salary_Structure"])
Rushabh Mehta622c98d2013-08-22 15:17:58 +0530383
384def make_bank_account():
385 ba = webnotes.bean({
386 "doctype": "Account",
387 "account_name": bank_name,
388 "account_type": "Bank or Cash",
389 "group_or_ledger": "Ledger",
390 "parent_account": "Bank Accounts - " + company_abbr,
391 "company": company
392 }).insert()
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +0530393
Rushabh Mehta622c98d2013-08-22 15:17:58 +0530394 webnotes.set_value("Company", company, "default_bank_account", ba.doc.name)
395
Rushabh Mehta4a404e92013-08-09 18:11:35 +0530396def import_data(dt, submit=False):
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +0530397 if not isinstance(dt, (tuple, list)):
398 dt = [dt]
399
400 for doctype in dt:
401 print "Importing", doctype.replace("_", " "), "..."
Rushabh Mehta4a404e92013-08-09 18:11:35 +0530402 webnotes.form_dict = {}
403 if submit:
404 webnotes.form_dict["params"] = json.dumps({"_submit": 1})
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +0530405 webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", doctype+".csv")
406 upload()
Rushabh Mehtaed186b72013-07-30 16:19:40 +0530407
408if __name__=="__main__":
409 make()