blob: 9173ca5d2f7ba90b125e627a606b9747293adc44 [file] [log] [blame]
Rushabh Mehta33bce672011-08-25 15:15:25 +05301"""
2 Old patches for reference
3"""
4
5if patch_no==33:
6 pass
7elif patch_no==34:
8 webnotes.conn.sql("update `tabDocField` set options = 'Letter Head', print_hide = 1 where fieldname = 'letter_head' and fieldtype = 'Link'")
9elif patch_no==35:
10 webnotes.conn.sql("update tabDocType set module = 'Event Updates' where name = 'Feed Control'")
11elif patch_no==36:
12 # remove delivery note foreign key in Serial Number
13 from webnotes.model.db_schema import DbTable
14 t = DbTable('Serial No')
15 fk_list = t.get_foreign_keys()
16 for f in fk_list:
17 if f[0]=='delivery_note_no':
18 webnotes.conn.commit()
19 webnotes.conn.sql("alter table `tabSerial No` drop foreign key `%s`" % f[1])
20 webnotes.conn.begin()
21 webnotes.conn.sql("update tabDocField set fieldtype='Data' where fieldname='delivery_note_no' and parent='Serial No' limit 1")
22elif patch_no==37:
23 import os
24 mod_path = webnotes.defs.modules_path
25 path_list = []
26 for m in os.listdir(mod_path):
27 for t in ['doctype', 'page', 'search_criteria']:
28 dt_path = os.path.join(mod_path, m, t)
29 if os.path.exists(dt_path):
30 for dt in os.listdir(dt_path):
31 if '.' not in dt and os.path.exists(os.path.join(dt_path, dt, dt+ '.txt')):
32 path_list.append(os.path.join(dt_path, dt, dt+ '.txt'))
33
34 for d in path_list:
35 doclist = eval(open(d,'r').read())
36 webnotes.conn.sql("update `tab%s` set module = '%s' where name = '%s'" % (doclist[0]['doctype'], doclist[0]['module'], doclist[0]['name']))
37
38elif patch_no==38:
39 import webnotes
40 webnotes.conn.set_global("system_message", "System Updates: Hello! You would have noticed some changes on the Home Page. As a part of our commitment to make the system more friendly and social, we have re-designed the feed so that now you will only see feed that is relevant to you (either you have created something or you have been mentioned in the document).<br><br>On the individual listings, you can add tags and also color them!<br><br>You will also get time-to-time updates from our side here. Do keep sending your feedback at support@erpnext.com.")
41 webnotes.conn.set_global("system_message_id", "1")
42
43elif patch_no == 39:
44 pass
45
46elif patch_no == 40:
47 import_from_files(record_list=[['material_management','doctype','item']])
48
49elif patch_no == 42:
50 acc = sql("select name, lft, rgt from tabAccount where account_name in ('Incomes', 'Expenses')")
51 for d in acc:
52 sql("update tabAccount set is_pl_account = 'Yes' where lft >= '%s' and rgt <= '%s'" % (d[1], d[2]))
53elif patch_no == 43:
54 import webnotes.model
55 webnotes.model.delete_doc('Page', 'Module Manager')
56
57# cleanup of Service, Customer Support, Utilities Modules
58# -------------------------------------------------------
59elif patch_no == 44:
60 from webnotes.model import delete_doc
61
62 for dt in sql("select name from tabDocType where module in ('Customer Support')"):
63 delete_doc('DocType', dt[0])
64
65 for dt in sql("select name from `tabSearch Criteria` where module in ('Customer Support')"):
66 delete_doc('Search Criteria', dt[0])
67
68 for dt in sql("select name from tabPage where module in ('Customer Support')"):
69 delete_doc('Page', dt[0])
70
71 # move a couple
72 webnotes.conn.sql("update `tab%s` set module=%s where name=%s" % ('DocType', '%s', '%s'), ('Application Internal', 'Patch Util'))
73 webnotes.conn.sql("update `tab%s` set module=%s where name=%s" % ('DocType', '%s', '%s'), ('Application Internal', 'DocType Property Setter'))
74
75 # remove utilities
76 webnotes.conn.sql('delete from `tabModule Def` where name in ("Customer Support", "Utilities")')
77
78elif patch_no == 45:
79 webnotes.conn.sql('delete from tabDocField where options="Ticket Response Detail"')
80
81elif patch_no == 46:
82 import webnotes
83 webnotes.conn.set_global("system_message", "<b>SYSTEM DOWNTIME:</b> Hello! As part of our commitment to keep improving the service, we are planning a scheduled maintenance on our servers for 4 hrs on 16-Jan-2011(Sunday), from 10AM to 2PM. Do keep sending your feedback at support@erpnext.com.")
84 webnotes.conn.set_global("system_message_id", "2")
85
86elif patch_no == 47:
87 import webnotes
88 webnotes.conn.set_global("system_message", "")
89 webnotes.conn.set_global("system_message_id", "3")
90
91elif patch_no == 48:
92 webnotes.conn.sql("update tabDocField set options = 'Print Heading' where fieldname = 'select_print_heading'")
93
94elif patch_no == 49:
95 webnotes.conn.sql("update tabDocType set autoname = '' where name = 'Search Criteria'")
96elif patch_no == 50:
97 sql("update tabDocField set in_filter = 1 where fieldname in ('cost_center', 'income_account', 'Item Group') and parent = 'RV Detail'")
98elif patch_no == 51:
99 sql("update tabDocField set options = 'link:Print Heading' where fieldtype = 'Select' and fieldname = 'select_print_heading' and parent = 'POS Setting'")
100elif patch_no == 52:
101 sql("update tabDocField set print_hide = 1 where fieldname = 'letter_head'")
102elif patch_no == 53:
103 sql("update tabDocType set search_fields = 'lead_name,lead_owner,status,contact_by,contact_date' where name = 'Lead'")
104elif patch_no == 54:
105 sql("delete from tabDocField where parent = 'Supplier' and label = 'Supplier Contacts' and fieldtype = 'Section Break'")
106elif patch_no == 55:
107 sql("commit")
108 try:
109 sql("alter table tabFeed add column `_user_tags` varchar(180)")
110 except Exception, e:
111 if e.args[0]!=1060:
112 raise e
113elif patch_no == 56:
114 sql("delete from `tabModule Def Item` where parent = 'CRM' and doc_type = 'Reports' and doc_name = 'Delivery Note' and display_name = 'Territory, Item Group wise GP'")
115elif patch_no == 57:
116 import_from_files(record_list=[['selling','doctype','sales_order_detail']])
117
118elif patch_no == 58:
119 # module def patches
120 sql("update `tabModule Def` set module_page = NULL where name not in ('Event Updates', 'Setup', 'My Company')")
121 sql("delete from `tabModule Def Item` where doc_type in ('Separator', 'Setup Forms', 'More Reports')")
122 sql("delete from `tabModule Def Item` where doc_name = 'Project Activity'")
123 sql("update `tabModule Def` set module_label = 'People', disabled='No', is_hidden='No' where name = 'My Company'")
124
125 # insert new module items
126 from webnotes.model.doc import make_autoname
127 if not sql("select name from `tabModule Def Item` where parent='Projects' and doc_name='Ticket'"):
128 sql("""insert into `tabModule Def Item`
129 (name, parent, parenttype, parentfield, docstatus, doc_type, doc_name, display_name, idx) values
130 (%s, 'Projects', 'Module Def', 'items', 0, 'Forms', 'Ticket', 'Task', 1)""", make_autoname('MDI.#####'))
131
132 if not sql("select name from `tabModule Def Item` where parent='Projects' and doc_name='Timesheet'"):
133 sql("""insert into `tabModule Def Item`
134 (name, parent, parenttype, parentfield, docstatus, doc_type, doc_name, display_name, idx) values
135 (%s, 'Projects', 'Module Def', 'items', 0, 'Forms', 'Timesheet', 'Timesheet', 2)""", make_autoname('MDI.#####'))
136
137 if not sql("select name from `tabModule Def Item` where parent='Projects' and doc_name='Projects'"):
138 sql("""insert into `tabModule Def Item`
139 (name, parent, parenttype, parentfield, docstatus, doc_type, doc_name, display_name, idx) values
140 (%s, 'Projects', 'Module Def', 'items', 0, 'Pages', 'Projects', 'Gantt Chart', 1)""", make_autoname('MDI.#####'))
141
142elif patch_no == 59:
143 webnotes.conn.set_value('Control Panel',None,'mail_footer','')
144 webnotes.conn.set_global('global_mail_footer','<div style="margin-top:8px; padding: 8px; font-size: 11px; text-align:right; border-top: 1px solid #AAA">Sent via <a href="https://www.erpnext.com">ERPNext</a></div>')
145elif patch_no == 60:
146 sql("delete from `tabModule Def Item` where display_name = 'Point of Sales'")
147elif patch_no == 61:
148 sql("delete from `tabTDS Category Account` where company not in (select name from tabCompany)")
149elif patch_no == 62:
150 # Import Supplier Quotation
151 import_from_files(record_list=[['srm','doctype','supplier_quotation']])
152
153 # Adding Status Filter
154 sql("update tabDocType set search_fields = concat('status,',search_fields) where name IN ('Delivery Note','Leave Transaction')")
155 # Import Other Charges
156
157 import_from_files(record_list=[['setup','doctype','other_charges']])
158elif patch_no == 63:
159 sql("update `tabDocField` set permlevel = 1 where fieldname in ('return_date', 'return_details') and parent = 'Sales and Purchase Return Wizard'")
160 import_from_files(record_list = [['accounts', 'doctype', 'rv_detail'], ['material_management', 'doctype', 'sales_and_purchase_return_wizard'], ['material_management', 'doctype', 'stock_entry']])
161
162elif patch_no == 64:
163 sql("update tabDocField set `hidden` = 1, `print_hide` = 1, `report_hide` = 1 where options in ('RFQ','Supplier Quotation')")
164 sql("update tabDocType set `read_only` = 1, in_create = 1 where name in ('RFQ','Supplier Quotation')")
165 sql("update tabDocField set `report_hide` = 0 where fieldname in ('email_id','phone_1','fax_1') and parent = 'Customer'")
166elif patch_no == 65:
167 # Monthly Trend Analyzer <-> Trend Analyzer
168 sql("update `tabSearch Criteria` set criteria_name = 'Trend Analyzer' where criteria_name = 'Monthly Trend Analyzer' and name = 'SRCH/00159'")
169 sql("update `tabModule Def Item` set display_name = 'Trend Analyzer' where parent = 'Analysis' and display_name = 'Monthly Trend Analyzer'")
170elif patch_no == 66:
171 import webnotes
172 webnotes.conn.set_global("system_message", """<h3>UI Updates</h3>Based on user feedback, we have made a couple of changes in the UI:<ul><li>Sidebar menus are now collapsable</li><li>Forms are now scrollable (we removed the confusing tabs)</li><li>Feed is a lot more descriptive</li></ul>Do send us your feedback!""")
173 webnotes.conn.set_global("system_message_id", "4")
174
175 sql("update `tabModule Def Item` set doc_type = 'Setup Forms' where doc_name in ('TDS Payment', 'TDS Return Acknowledgement', 'Form 16A', 'Period Closing Voucher', 'IT Checklist')")
176 from webnotes.session_cache import clear_cache
177 clear_cache(webnotes.session['user'])
178elif patch_no == 67:
179 sql("update `tabDocField` set in_filter = 1 where fieldname = 'brand' and parent = 'RV Detail'")
180 sql("delete from `tabModule Def Item` where (display_name = 'Sales Invoice' and parent = 'CRM') or (display_name = 'Purchase Invoice' and parent = 'SRM')")
181elif patch_no == 68:
182 from webnotes.modules.import_module import import_from_files
183 import_from_files(record_list=[['hr','doctype','employee'],['roles','Role','Employee']])
184elif patch_no == 69:
185 # delete flds from employee master
186 p = get_obj('Patch Util')
187 emp_del_flds = ['month_of_birth']
188 for f in emp_del_flds:
189 p.delete_field('Employee', f)
190
191 sql("Update tabDocField set `default` = 'Active' where fieldname = 'status' and parent = 'Employee'")
192
193 # map parent flds
194 fld_map = ['cell_number', 'personal_email', 'person_to_be_contacted', 'relation', 'emergency_phone_number', 'pan_number', 'passport_number', 'date_of_issue', 'valid_upto', 'place_of_issue', 'marital_status', 'blood_group', 'permanent_accommodation_type']
195
196 emp_prof = sql("select t1.name, t1.employee, t1.permanent_address_line_1, t1.permanent_address_line_2, t1.city1, t1.state1, t1.country1, t1.pin_code1, t1.phn_no1, t1.present_address_line_1, t1.present_address_line_2, t1.city2, t1.state2, t1.country2, t1.pin_code2, t1.phn_no2, t1.fathers_name, t1.fathers_occupation, t1.mothers_name, t1.mothers_occupation, t1.spouses_name, t1.spouses_occupation, t1.height_cms, t1.weight_kgs, t1.allergies, t1.other_medical_concerns, t1.physical_handicap from `tabEmployee Profile` t1, `tabEmployee` t2 where t1.employee = t2.name")
197 for e in emp_prof:
198 prof_obj = get_obj('Employee Profile', e[0])
199 emp_obj = get_obj('Employee', e[1])
200 for d in fld_map:
201 emp_obj.doc.fields[d] = prof_obj.doc.fields[d]
202 emp_obj.doc.current_accommodation_type = prof_obj.doc.present_accommodation_type
203
204 # address
205 per_addr = cstr(e[2]) + '\n' + cstr(e[3]) + '\n' + cstr(e[4]) + '\n' + cstr(e[5]) + ', ' + cstr(e[6]) + '\n' + 'PIN - ' + cstr(e[7]) + '\n' + 'Ph. No' + cstr(e[8])
206 cur_addr = cstr(e[9]) + '\n' + cstr(e[10]) + '\n' + cstr(e[11]) + '\n' + cstr(e[12]) + ', ' + cstr(e[13]) + '\n' + 'PIN - ' + cstr(e[14]) + '\n' + 'Ph. No' + cstr(e[15])
207 emp_obj.doc.permanent_address = per_addr
208 emp_obj.doc.current_address = cur_addr
209 #family
210 fam = "Father's Name: " + cstr(e[16]) + '\n' + "Father's Occupation: " + cstr(e[17]) + '\n' + "Mother's Name: " + cstr(e[18]) + '\n' + "Mother's Occupation: " + cstr(e[19]) + '\n' + "Spouse's Name: " + cstr(e[20]) + '\n' + "Spouse's Occupation: " + cstr(e[21])
211 emp_obj.doc.family_background = fam
212 # health
213 health = 'Height(cms): ' + cstr(e[22]) + '\n' + 'Weight(kgs): ' + cstr(e[23]) + '\n' + 'Allergies: ' +cstr( e[24]) + '\n' + 'Other Medical Concern: ' + cstr(e[25]) + '\n' + 'Physically Handicapped(if any): ' + cstr(e[26])
214 emp_obj.doc.health_details = health
215 emp_obj.doc.save()
216
217
218 # map tables
219 tbl_list = ['Experience In Company Detail', 'Previous Experience Detail', 'Educational Qualifications Detail']
220 for t in tbl_list:
221 sql("update `tab%s` t1, `tabEmployee Profile` t2 set t1.parent = t2.employee, t1.parenttype = 'Employee' where t1.parent = t2.name" % t)
222
223
224 # overwrite idx?????????
225
226
227 # delete emp profile
228 webnotes.model.delete_doc('DocType', 'Employee Profile')
229 for e in emp_prof:
230 webnotes.model.delete_doc('Employee Profile', e[0])
231
232elif patch_no == 70:
233 # update search criteria module -> System
234 sql("update tabDocType set module='System' where name='Search Criteria'")
235
236 # Cleanups to Contact
237 sql("update tabDocField set fieldtype='Data' where options='Designation' and parent='Contact'")
238 sql("update tabDocField set fieldtype='Data' where options='Department' and parent='Contact'")
239 sql("update tabDocField set depends_on='eval:(cint(doc.is_customer) || cint(doc.is_supplier) || cint(doc.is_sales_partner))' where fieldname='is_primary_contact' and parent='Contact'")
240
241 # import Contact, Employee
242 from webnotes.modules.import_module import import_from_files
243 import_from_files(record_list=[['utilities','doctype','contact']])
244
245
246 # remove last_contact_date from Lead
247 sql("delete from tabDocField where fieldname='last_contact_date' and parent='Lead'")
248
249elif patch_no == 71:
250 # Make Stock Qty and Conversion Factor field editable. Also no need to mention Conversion factor in table can do it directly
251 sql("update `tabDocField` set `permlevel` = 0, `width` = '100px', `trigger` = 'Client' where parent IN ('PO Detail','Purchase Receipt Detail') and fieldname in ('stock_qty','conversion_factor')")
252 sql("update `tabDocField` set `width` = '100px' where parent IN ('PO Detail','Purchase Receipt Detail') and fieldname = 'stock_uom'")
253
254elif patch_no == 72:
255 # Core Patch
256 # ----------
257
258 from webnotes.modules.import_module import import_from_files
259
260 # import module def
261 import_from_files(record_list = [['core', 'Module Def', 'Core']])
262elif patch_no == 73:
263 # set module in DocTypes
264 sql("update tabDocType set module='Core' where name in ('DocType', 'DocField', 'DocPerm', 'Role', 'UserRole', 'Profile', 'Print Format', 'DocFormat', 'Control Panel', 'Event', 'Event Role', 'Event User', 'DefaultValue', 'Default Home Page', 'File', 'File Group', 'File Data', 'Letter Head', 'Module Def', 'Module Def Item', 'Module Def Role', 'Page', 'Page Role', 'Search Criteria', 'DocType Label', 'DocType Mapper', 'Field Mapper Detail', 'Table Mapper Detail')")
265
266 # set module in Page
267 sql("update tabPage set module='Core' where name='Login Page'")
268
269 # move file browser to Tools
270 sql("update tabPage set module='Tools' where name='File Browser'")
271 sql("update tabDocType set module='Tools' where name='File Browser Control'")
272 sql("update tabDocType set module='Application Internal' where name='Profile Control'")
273elif patch_no == 74:
274 p = get_obj('Patch Util')
275 # permission
276 p.delete_permission('Employee', 'Administrator', 0)
277 p.delete_permission('Employee', 'Administrator', 1)
278 p.add_permission('Employee', 'Employee', 0, read = 1, match = 'owner')
279 p.add_permission('Employee', 'Employee', 1, read = 1, match = 'owner')
280 sql("delete from `tabDocField` where parent = 'Employee' and label = 'Payroll Rule'")
281elif patch_no == 75:
282 #sal structure patch
283 # import
284 from webnotes.modules.import_module import import_from_files
285 import_from_files(record_list=[['hr','doctype','salary_structure'], ['hr','doctype','earning_detail'],['hr','doctype','deduction_detail']])
286elif patch_no == 76:
287 # property
288 p = get_obj('Patch Util')
289 p.set_field_property('Salary Structure', 'is_active', 'default', 'Yes')
290 p.set_field_property('Salary Structure', 'ctc', 'reqd', '1')
291 p.set_field_property('Earning Detail', 'modified_value', 'width', '')
292 p.set_field_property('Earning Detail', 'modified_value', 'trigger', 'Client')
293 p.set_field_property('Deduction Detail', 'd_modified_amt', 'width', '')
294 p.set_field_property('Earning Detail', 'd_modified_amt', 'trigger', 'Client')
295 sql("Update tabDocField set `description` = 'You can create more earning and deduction type from Setup --> HR' where label = 'Earning & Deduction' and parent = 'Salary Structure' and fieldtype = 'Section Break'")
296
297 # delete
298 sql("update `tabSalary Structure` set net_pay = total")
299 sql("delete from tabDocField where label in ('LWP Help', 'Calculate Total', 'Total') and parent = 'Salary Structure'")
300 sql("delete from tabDocPerm where parent in ('Earning Detail', 'Deduction Detail')")
301
302
303 # permission
304 p.delete_permission('Salary Structure', 'Administrator', 0)
305 p.delete_permission('Salary Structure', 'Administrator', 1)
306 p.add_permission('Salary Structure', 'Employee', 0, read = 1, match = 'owner')
307 p.add_permission('Salary Structure', 'Employee', 1, read = 1, match = 'owner')
308elif patch_no == 77:
309 # sal slip patch
310 # import
311 from webnotes.modules.import_module import import_from_files
312 import_from_files(record_list=[['hr','doctype','salary_slip'], ['hr','doctype','ss_earning_detail'],['hr','doctype','ss_deduction_detail'], ['mapper', 'DocType Mapper', 'Salary Structure-Salary Slip']])
313elif patch_no == 78:
314 p = get_obj('Patch Util')
315 # delete
316 sql("update `tabSalary Slip` set leave_encashment_amount = encashment_amount")
317 p.delete_field('Salary Slip', 'encashment_amount')
318 p.delete_field('Salary Slip', 'year')
319 p.delete_field('Salary Slip', 'flag')
320 sql("delete from tabDocField where label = 'Process Payroll' and parent = 'Salary Slip'")
321
322 # field property
323 p.set_field_property('Salary Slip', 'bank_name', 'permlevel', '1')
324 p.set_field_property('Salary Slip', 'leave_without_pay', 'permlevel', '0')
325 p.set_field_property('Salary Slip', 'leave_without_pay', 'trigger', 'Client')
326 p.set_field_property('SS Earning Detail', 'e_type', 'permlevel', '0')
327 p.set_field_property('SS Earning Detail', 'e_type', 'fieldtype', 'Link')
328 p.set_field_property('SS Earning Detail', 'e_type', 'options', 'Earning Type')
329 p.set_field_property('SS Deduction Detail', 'd_type', 'permlevel', '0')
330 p.set_field_property('SS Deduction Detail', 'd_type', 'fieldtype', 'Link')
331 p.set_field_property('SS Deduction Detail', 'd_type', 'options', 'Deduction Type')
332 sql("update `tabSS Earning Detail` set e_modified_amount = e_amount")
333 sql("update `tabSS Deduction Detail` set d_modified_amount = d_amount")
334
335 # permission
336 p.delete_permission('Salary Slip', 'Administrator', 0)
337 p.delete_permission('Salary Slip', 'Administrator', 1)
338 p.add_permission('Salary Slip', 'Employee', 0, read = 1, match = 'owner')
339 p.add_permission('Salary Slip', 'Employee', 1, read = 1, match = 'owner')
340elif patch_no == 79:
341 # Import Modules
342 import_from_files(record_list=[['hr','doctype','leave_application'],['hr','doctype','leave_allocation'],['hr','doctype','leave_control_panel'],['hr','doctype','holiday_list'],['hr','doctype','holiday_list_detail'],['hr','Module Def','HR']])
343elif patch_no == 80:
344 # Holiday List
345 sql("update `tabHoliday List Detail` set description = holiday_name")
346 sql("delete from tabDocField where parent = 'Holiday List Detail' and fieldname = 'holiday_name'")
347 sql("update tabDocField set fieldtype = 'Select', options = 'link:Fiscal Year' where parent = 'Holiday List' and fieldname = 'fiscal_year'")
348 sql("delete from tabDocPerm where role in ('Administrator','HR User') and parent = 'Holiday List'")
349
350 # Leave Control Panel
351 # --------------------
352 sql("delete from `tabDocField` where parent = 'Leave Control Panel' and label in ('Leave Control Panel','Allocation Details') and fieldtype = 'Section Break'")
353 sql("delete from tabDocField where parent = 'Leave Control Panel' and fieldname in ('col_brk3','allocation_type','col_brk2','from_date','to_date','leave_transaction_type','posting_date')")
354 sql("update tabDocField set fieldtype = 'Select', options = 'link:Fiscal Year' where parent = 'Leave Control Panel' and fieldname = 'fiscal_year'")
355 sql("update tabDocField set fieldtype = 'Select', options = 'link:Leave Type' where parent = 'Leave Control Panel' and fieldname = 'leave_type'")
356 sql("update tabDocField set reqd = 1 where parent = 'Leave Control Panel' and fieldname = 'no_of_days'")
357
358 # Leave Application
359 # ------------------
360 for d in sql("select * from `tabLeave Transaction` where leave_transaction_type = 'Deduction' and ifnull(deduction_type, '') = 'Leave'", as_dict = 1):
361 lp = Document('Leave Application')
362 lp.employee = d['employee']
363 lp.leave_type = d['leave_type']
364 lp.posting_date = d['date']
365 lp.fiscal_year = d['fiscal_year']
366 lp.leave_balance = d['pre_balance']
367 lp.half_day = d['half_day']
368 lp.from_date = d['from_date']
369 lp.to_date = d['to_date']
370 lp.total_leave_days = d['total_leave']
371 lp.description = d['reason']
372 lp.docstatus = cint(d['docstatus'])
373 lp.save(1)
374
375 # Leave Allocation
376 # -----------------
377 for d in sql("select * from `tabLeave Transaction` where leave_transaction_type = 'Allocation'", as_dict = 1):
378 la = Document('Leave Allocation')
379 la.employee = d['employee']
380 la.leave_type = d['leave_type']
381 la.posting_date = d['date']
382 la.fiscal_year = d['fiscal_year']
383 la.new_leaves_allocated = d['total_leave']
384 la.total_leaves_allocated = d['total_leave']
385 la.description = d['reason']
386 la.docstatus = cint(d['docstatus'])
387 la.save(1)
388
389 # Payroll Module Def
390 # -------------------
391 sql("delete from `tabModule Def Item` where doc_name = 'Leave Transaction' and display_name = 'Leave Transaction' and parent = 'Payroll' and doc_type = 'Forms'")
392
393elif patch_no == 81:
394 # Import Modules
395 import_from_files(record_list=[['hr','Module Def','HR']])
396elif patch_no == 82:
397 sql("update tabDocType set search_fields = 'employee,leave_type,total_leaves_allocated,fiscal_year' where name = 'Leave Allocation'")
398 sql("update tabDocType set search_fields = 'employee,leave_type,from_date,to_date,total_leave_days,fiscal_year' where name = 'Leave Application'")
399elif patch_no == 83:
400 # delete leave transaction
401 webnotes.conn.sql("set foreign_key_checks=0")
402 sql("delete from `tabLeave Transaction`")
403 import webnotes.model
404 webnotes.model.delete_doc('DocType','Badge Settings Detail')
405 webnotes.model.delete_doc('DocType','Leave Transaction')
406 webnotes.conn.sql("set foreign_key_checks=1")
407elif patch_no == 84:
408 p = get_obj('Patch Util')
409 p.set_field_property('SS Earning Detail', 'e_amount', 'permlevel', '1')
410 p.set_field_property('SS Deduction Detail', 'd_amount', 'permlevel', '1')
411elif patch_no == 85:
412 # permission
413 p = get_obj('Patch Util')
414 p.add_permission('Leave Application', 'Employee', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1, match = 'owner')
415 p.add_permission('Leave Application', 'Employee', 1, read = 1, match = 'owner')
416 p.add_permission('Leave Allocation', 'HR User', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1, match = 'owner')
417 p.add_permission('Leave Allocation', 'HR User', 1, read = 1)
418 sql("update tabDocPerm set `match` = '' where parent = 'Leave Application' and role = 'HR User'")
419elif patch_no == 86:
420 # Import Modules
421 import_from_files(record_list=[['hr','doctype','leave_type']])
422elif patch_no == 87:
423 sql("update `tabLeave Type` set is_lwp = 1 where name = 'Leave Without Pay'")
424elif patch_no == 88:
425 # Import Modules
426 import_from_files(record_list=[['hr','doctype','leave_allocation']])
427
428elif patch_no == 89:
429 sql("delete from `tabModule Def Item` where doc_type = 'Setup Forms' and doc_name in ('Payroll Rule', 'IT Checklist', 'Employee Profile') and parent = 'Payroll'")
430 sql("update `tabDocField` set `hidden` = 1, `print_hide` = 1, `report_hide` = 1 where parent = 'Leave Type' and fieldname = 'is_encash'")
431elif patch_no == 90:
432 sql("update `tabLeave Allocation` set docstatus = 1")
433elif patch_no == 91:
434 import webnotes
435 webnotes.conn.set_global("system_message", """<h3>System Updates</h3>Based on user feedback, we have cleaned up HR module (Partly):<ul><li>Employee and Employee Profile are merged into a single document</li><li>Salary Structure and Salary Slip are now more user friendly</li><li>Leave Transaction document is now divided into 2 documents Leave Application and Leave Allocation</li></ul>We will work on Reports, Attendance and other documents of Payroll module next week<br><br> Do send us your feedback!""")
436 webnotes.conn.set_global("system_message_id", "5")
437elif patch_no == 92:
438 sql("update tabDocField set label = 'Get Charges' where parent IN ('Sales Order','Delivery Note','Receivable Voucher') and label = 'Get Other Charges' and fieldtype = 'Button'")
439 # Automated Other Charges Calculation basis
440 sql("update tabDocField set options = '', `trigger` = 'Client' where parent IN ('Quotation','Sales Order','Delivery Note','Receivable Voucher') and label = 'Get Charges' and fieldtype = 'Button'")
441elif patch_no == 93:
442 sql("update `tabTable Mapper Detail` set validation_logic = 'qty > ifnull(billed_qty,0) and docstatus = 1' where parent = 'Sales Order-Receivable Voucher' and from_table = 'Sales Order Detail'")
443 sql("update `tabField Mapper Detail` set from_field = 'customer' where to_field = 'customer' and parent = 'Sales Order-Receivable Voucher'")
444elif patch_no == 94:
445 import_from_files(record_list=[['selling','doctype','sms_center']])
446elif patch_no == 95:
447 import_from_files(record_list=[['mapper','DocType Mapper','Sales Order-Receivable Voucher'], ['mapper','DocType Mapper','Delivery Note-Receivable Voucher']])
448elif patch_no == 96:
449 sql("delete from `tabModule Def Item` where doc_type = 'Reports' and display_name = 'Cenvat Credit - Input or Capital Goods' and parent = 'Accounts'")
450elif patch_no == 97:
451 sql("update tabFeed set doc_label = 'Feed', doc_name = name where ifnull(doc_name,'') = '' and ifnull(doc_label,'') = ''")
452elif patch_no == 98:
453 import_from_files(record_list=[['accounts','doctype','payable_voucher']])
454elif patch_no == 99:
455 import_from_files(record_list=[['accounts','doctype','account']])
456elif patch_no == 100:
457 p = get_obj('Patch Util')
458 p.set_field_property('Account', 'level', 'hidden', '1')
459 p.set_field_property('Account', 'level', 'print_hide', '1')
460 p.set_field_property('Account', 'account_type', 'search_index', '0')
461 p.set_field_property('TDS Detail', 'tds_category', 'width', '150px')
462 p.set_field_property('TDS Detail', 'special_tds_rate_applicable', 'width', '150px')
463 p.set_field_property('TDS Detail', 'special_tds_rate', 'width', '150px')
464 p.set_field_property('TDS Detail', 'special_tds_limit', 'width', '150px')
465elif patch_no == 101:
466 # Leave Application Details and Leave Allocation Details
467 sql("update tabDocField set search_index = 1, in_filter = 1 where fieldname in ('employee','leave_type','fiscal_year') and parent in ('Leave Application','Leave Allocation')")
468 get_obj('DocType','Leave Application').doc.save()
469 get_obj('DocType','Leave Allocation').doc.save()
470elif patch_no == 102:
471 # make item description field editable in production order
472 sql("update tabDocField set permlevel = 0 where fieldname = 'description' and parent = 'Production Order'")
473elif patch_no == 103:
474 sql("update tabDocField set fieldname = '' where fieldtype = 'HTML'")
475elif patch_no == 104:
476 import_from_files(record_list=[['hr','search_criteria','stdsrch_00001'],['hr','search_criteria','stdsrch_00002'],['hr','search_criteria','stdsrch_00003'],['hr','Module Def','HR'],['hr','doctype','leave_application'],['hr','doctype','leave_allocation']])
477
478elif patch_no == 105:
479 # Employee Leave Balance
480 sql("delete from `tabModule Def Item` where parent = 'Payroll' and doc_type = 'Reports' and display_name IN ('Employeewise Leave Transaction Details','Employeewise Balance Leave Report')")
481 # Update Search Fields
482 sql("update tabDocType set search_fields = 'employee,employee_name,leave_type,from_date,to_date,total_leave_days,fiscal_year' where name = 'Leave Application'")
483 sql("update tabDocType set search_fields = 'employee,employee_name,leave_type,total_leaves_allocated,fiscal_year' where name = 'Leave Allocation'")
484elif patch_no == 106:
485 for d in sql("select name,employee,employee_name from `tabLeave Allocation`"):
486 if not cstr(d[2]):
487 sql("update `tabLeave Allocation` set employee_name = '%s' where name = '%s'" % (webnotes.conn.get_value('Employee',cstr(d[1]),'employee_name'), cstr(d[0])))
488 for d in sql("select name,employee,employee_name from `tabLeave Application`"):
489 if not cstr(d[2]):
490 sql("update `tabLeave Application` set employee_name = '%s' where name = '%s'" % (webnotes.conn.get_value('Employee',cstr(d[1]),'employee_name'), cstr(d[0])))
491elif patch_no == 107:
492 sql("delete from `tabDocField` where fieldname = 'fiscal_year' and parent = 'Employee'")
493elif patch_no == 108:
494 import_from_files(record_list=[['hr','search_criteria','srch_std_00013']])
495elif patch_no == 109:
496 import_from_files(record_list=[['hr','search_criteria','srch_std_00015']])
497elif patch_no == 110:
498 import_from_files(record_list=[['hr','doctype','salary_structure'], ['hr', 'doctype', 'salary_slip']])
499elif patch_no == 111:
500 sql("update tabDocType set search_fields = 'transfer_date, from_warehouse, to_warehouse, purpose, remarks' where name = 'Stock Entry'")
501elif patch_no == 112:
502 sql("delete from tabDocField where label = 'Get Other Charges' and fieldtype = 'Button' and parent = 'Receivable Voucher'")
503elif patch_no == 113:
504 sql("update tabDocField set reqd = 1 where parent = 'Customer' and fieldname = 'phone_1'")
505elif patch_no == 114:
506 for d in sql("select name, master_name, credit_days, credit_limit from tabAccount where master_type = 'Customer'"):
507 if cstr(d[1]):
508 days, limit = cint(d[2]), flt(d[3])
509 cust_det = sql("select credit_days, credit_limit from tabCustomer where name = '%s'" % (cstr(d[1])))
510 if not days: days = cust_det and cint(cust_det[0][0]) or 0
511 if not limit: limit = cust_det and flt(cust_det[0][1]) or 0
512 sql("COMMIT")
513 sql("START TRANSACTION")
514 sql("update tabAccount set credit_days = '%s', credit_limit = '%s' where name = '%s'" % (days, limit, cstr(d[0])))
515 sql("COMMIT")
516
517elif patch_no == 115:
518 # patch for timesheet cleanup
519 from webnotes.model import delete_doc
520 delete_doc('DocType', 'Timesheet Detail')
521
522 from webnotes.modules.import_module import import_from_files
523 import_from_files(record_list = [['Projects', 'DocType', 'Timesheet'], ['Projects', 'DocType', 'Timesheet Detail'], ['Projects', 'DocType', 'Activity Type']])
524
525elif patch_no == 116:
526 # again!
527 from webnotes.model import delete_doc
528 delete_doc('DocType', 'Timesheet Detail')
529
530 from webnotes.modules.import_module import import_from_files
531 import_from_files(record_list = [['Projects', 'DocType', 'Timesheet Detail']])
532elif patch_no == 117:
533 op = '\n' + 'Walk In'
534 sql("update `tabDocField` set `options` = concat(options, %s) where parent = 'Enquiry' and fieldname = 'source' and options not like '%%Walk%%'", op)
535elif patch_no == 118:
536 from webnotes.utils import get_defaults
537 ss = sql("select name, net_pay from `tabSalary Slip`")
538 for d in ss:
539 if d[1]:
540 w = get_obj('Sales Common').get_total_in_words(get_defaults()['currency'], d[1])
541 sql("update `tabSalary Slip` set net_pay_in_words = '%s' where name = '%s'" % (w, d[0]))
542elif patch_no == 119:
543 sql("update tabDocType set in_create = 1 where name = 'Profile'")
544elif patch_no == 120:
545 sql("update tabDocField set permlevel = 0 where parent = 'Sales and Purchase Return Wizard' and fieldname = 'return_date'")
546elif patch_no == 121:
547 import_from_files(record_list = [['CRM', 'DocType', 'Return Detail'], ['Material Management', 'DocType', 'Sales and Purchase Return Wizard']])
548elif patch_no == 122:
549 sql("delete from tabDocField where (fieldname = 'serial_no' or label = 'Warrany Status') and parent = 'Sales Order'")
550elif patch_no == 123:
551 import_from_files(record_list = [['CRM', 'Module Def', 'CRM'], ['CRM', 'Search Criteria', 'STDSRCH/00004']])
552elif patch_no == 124:
553 import webnotes
554 webnotes.conn.set_global("system_message", """<h3>Updates(New)</h3>We have added a new report in the Selling Module.<br><br><b>Sales Personwise Transaction Summary: </b>In this report you can see sales person's contribution in a particular order, delivery or invoice. You can select voucher type in "Based On" filter.<br><br> Do send us your feedback!""")
555 webnotes.conn.set_global("system_message_id", "5")
556elif patch_no == 125:
557 import_from_files(record_list = [['Material Management', 'DocType', 'Delivery Note']])
558elif patch_no == 126:
559 sql("delete from tabDocField where parent = 'Delivery Note' and label in ('Make Sales Invoice', 'Make Installation Note', 'Intro Note')")
560elif patch_no == 127:
561 sql("delete from tabDocPerm where role = 'All' and parent = 'Expense Voucher' and (permlevel = 0 or permlevel = 2)")
562 p = get_obj('Patch Util')
563 p.add_permission('Expense Voucher', 'Employee', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1, match = 'owner')
564 p.add_permission('Expense Voucher', 'HR Manager', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1)
565 p.add_permission('Expense Voucher', 'HR User', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1)
566elif patch_no == 128:
567 from webnotes.modules import import_module
568 import_module.import_from_files(record_list=[['selling','doctype','sales_order'], ['selling','doctype','sales_order_detail'], ['stock','doctype','delivery_note'], ['stock','doctype','delivery_note_detail']])
569elif patch_no == 129:
570 sql("update `tabTable Mapper Detail` set validation_logic = '(qty > ifnull(billed_qty, 0) or amount > ifnull(billed_amt, 0)) and docstatus = 1' where parent = 'Sales Order-Receivable Voucher' and from_table = 'Sales Order Detail' and to_table = 'RV Detail'")
571 sql("update `tabTable Mapper Detail` set validation_logic = '(qty > ifnull(billed_qty, 0) or amount > ifnull(billed_amt, 0)) and docstatus = 1' where parent = 'Delivery Note-Receivable Voucher' and from_table = 'Delivery Note Detail' and to_table = 'RV Detail'")
572elif patch_no == 130:
573 # update from rv
574 from webnotes.model.code import get_obj
575 from webnotes.utils import cstr
576 for d in sql("select name, docstatus from `tabReceivable Voucher` where ifnull(docstatus,0) != 0"):
577 sql("COMMIT")
578 sql("START TRANSACTION")
579 try:
580 obj = get_obj('Receivable Voucher', cstr(d[0]), with_children = 1)
581 is_submit = 1
582 if cint(d[1]) == 2: is_submit = 0
583 get_obj('Sales Common').update_prevdoc_detail(is_submit, obj)
584 except:
585 pass
586 sql("COMMIT")
587
588 # update from dn
589 from webnotes.model.code import get_obj
590 for d in sql("select name, docstatus from `tabDelivery Note` where ifnull(docstatus,0) != 0"):
591 sql("COMMIT")
592 sql("START TRANSACTION")
593 try:
594 obj = get_obj('Delivery Note', cstr(d[0]), with_children = 1)
595 is_submit = 1
596 if cint(d[1]) == 2: is_submit = 0
597 get_obj('Sales Common').update_prevdoc_detail(is_submit, obj)
598 except:
599 pass
600 sql("COMMIT")
601elif patch_no == 131:
602 sql("update `tabDocType` set allow_trash = 1 where name = 'Purchase Other Charges'")
603 sql("update tabDocPerm set `cancel` = 1 where parent = 'Purchase Other Charges' and permlevel = 0 and `read` = 1 and `write` = 1")
604elif patch_no == 132:
605 sql("update tabDocField set no_copy = 0 where parent = 'Receivable Voucher' and fieldname = 'customer'")
606elif patch_no == 133:
607 from webnotes.modules import import_module
608 import_module.import_from_files(record_list=[['accounts','doctype','receivable_voucher']])
609elif patch_no == 134:
610 sql("update tabDocField set no_copy = 1 where parent = 'Receivable Voucher' and fieldname = 'posting_time'")
611elif patch_no == 135:
612 sql("update tabDocField set `default` = 'Today' where parent = 'Receivable Voucher' and fieldname = 'due_date'")
613elif patch_no == 136:
614 from webnotes.modules import import_module
615 import_module.import_from_files(record_list=[['accounts','doctype','rv_detail']])
616elif patch_no == 137:
617 from webnotes.modules import import_module
618 import_module.import_from_files(record_list=[['setup','doctype','price_list']])
619elif patch_no == 138:
620 sql("update `tabDocType` set allow_attach = 1 where name = 'Price List'")
621elif patch_no == 139:
622 from webnotes.modules import import_module
623 import_module.import_from_files(record_list=[['mapper','DocType Mapper','Sales Order-Receivable Voucher'], ['mapper','DocType Mapper','Delivery Note-Receivable Voucher']])
624elif patch_no == 140:
625 from webnotes.modules import import_module
626 import_module.import_from_files(record_list=[['accounts','doctype','rv_detail']])
627elif patch_no == 141:
628 sql("delete from tabDocField where (fieldname = 'letter_head' or label = 'Letter Head') and parent = 'Company'")
629elif patch_no == 142:
630 # fixes to letter head and personalize
631 from webnotes.model import delete_doc
632
633 delete_doc('DocType', 'Batch Settings')
634 delete_doc('DocType', 'Batch Settings Detail')
635 delete_doc('DocType', 'Social Badge')
636 delete_doc('Page', 'Personalize Page')
637 delete_doc('DocType', 'Personalize Page Control')
638
639 import_from_files(record_list=[['core','doctype','letter_head'], ['setup','doctype','personalize']])
640elif patch_no == 144:
641 webnotes.conn.sql("update tabDocField set fieldtype='Code' where parent='Letter Head' and fieldname='content'")
642elif patch_no == 145:
643 sql("update `tabDocField` set permlevel=1 where fieldname = 'group_or_ledger' and parent = 'Account'")
644elif patch_no == 146:
645 import_from_files(record_list=[['accounts','doctype','account']])
646elif patch_no == 147:
647 import_from_files(record_list=[['mapper', 'DocType Mapper', 'Purchase Order-Payable Voucher'], ['mapper', 'DocType Mapper', 'Purchase Receipt-Payable Voucher'], ['mapper', 'DocType Mapper', 'Purchase Order-Purchase Receipt']])
648elif patch_no == 148:
649 sql("delete from `tabDocField` where (fieldname = 'account_balances' or label = 'Balances') and parent = 'Account'")
650 sql("update tabDocType set istable = 0, section_style = 'Simple', search_fields = 'account, period, fiscal_year, balance' where name = 'Account Balance'")
651 sql("update tabDocField set permlevel = 0 where parent = 'Account Balance'")
652 p = get_obj('Patch Util')
653 p.add_permission('Account Balance', 'Accounts User', 0, read = 1)
654 p.add_permission('Account Balance', 'Accounts Manager', 0, read = 1)
655 import_from_files(record_list=[['accounts','doctype','account_balance']])
656elif patch_no == 149:
657 sql("update `tabAccount Balance` set account = parent")
658elif patch_no == 150:
659 sql("update tabDocField set in_filter = 1, search_index = 1 where parent = 'Account Balance' and fieldname in ('account', 'period', 'fiscal_year', 'start_date', 'end_date')")
660 ac_bal = Document("DocType", "Account Balance")
661 ac_bal.save()
662elif patch_no == 151:
663 sql("delete from tabDocField where label = 'Add / Manage Contacts' and fieldtype = 'Button' and parent = 'Customer'")
664 sql("delete from `tabField Mapper Detail` where parent = 'Sales Order-Delivery Note' and from_field = 'note' and to_field = 'note'")
665elif patch_no == 152:
666 import_from_files(record_list=[['selling','doctype','sales_order'], ['stock','doctype','delivery_note'], ['selling','doctype','customer'], ['selling','doctype','shipping_address'], ['mapper', 'DocType Mapper', 'Sales Order-Delivery Note']])
667elif patch_no == 153:
668 sql("delete from `tabDocField` where fieldname = 'sales_person' and parent = 'Customer'")
669elif patch_no == 154:
670 import_from_files(record_list=[['stock','doctype','serial_no'], ['support','doctype','customer_issue']])
671elif patch_no == 155:
672 for d in sql("select name, item_code from `tabSerial No`"):
673 sql("COMMIT")
674 sql("START TRANSACTION")
675 sql("update `tabSerial No` set item_name = '%s' where name = '%s'" % (webnotes.conn.get_value('Item',cstr(d[1]),'item_name'), cstr(d[0])))
676 sql("COMMIT")
677elif patch_no == 156:
678 sql("update tabDocField set fieldtype = 'Code' where fieldname = 'html' and parent = 'Print Format'")
679elif patch_no == 157:
680 import_from_files(record_list=[['accounts', 'doctype', 'journal_voucher'], ['accounts', 'Print Format', 'Payment Receipt Voucher'], ['accounts', 'Print Format', 'Cheque Printing Format']])
681elif patch_no == 158:
682 from webnotes.model.doc import addchild
683 sql("delete from tabDocField where parent = 'Customer Issue' and fieldname = 'customer_group'")
684elif patch_no == 159:
685 sql("update tabAccount set account_type = 'Chargeable' where account_name in ('Advertising and Publicity', 'Freight & Forwarding Charges', 'Miscellaneous Expenses', 'Sales Promotion Expenses')")
686elif patch_no == 160:
687 sql("update `tabDocType` set search_fields = 'posting_date, due_date, debit_to, fiscal_year, grand_total, outstanding_amount' where name = 'Receivable Voucher'")
688 sql("update `tabDocType` set search_fields = 'posting_date, credit_to, fiscal_year, bill_no, grand_total, outstanding_amount' where name = 'Payable Voucher'")
689elif patch_no == 161:
690 sql("update tabDocType set autoname = 'field:batch_id' where name = 'Batch'")
691 sql("update tabDocField set no_copy = 1 where parent = 'Batch' and fieldname = 'batch_id'")
692elif patch_no == 162:
693 import_from_files(record_list=[['selling', 'search_criteria', 'sales_order_pending_items1']])
694elif patch_no == 163:
695 sql("delete from `tabModule Def Item` where display_name = 'Sales Orderwise Pending Packing Item Summary' and parent = 'CRM'")
696 import_from_files(record_list=[['selling', 'search_criteria', 'sales_orderwise_pending_qty_to_deliver'], ['selling', 'search_criteria', 'sales_orderwise_pending_amount_to_bill'], ['selling', 'search_criteria', 'delivered_items_to_be_install']])
697elif patch_no == 164:
698 import_from_files(record_list=[['buying', 'search_criteria', 'pending_po_items_to_receive'], ['buying', 'search_criteria', 'pending_po_items_to_bill']])
699elif patch_no == 165:
700 pass
701elif patch_no == 166:
702 import_from_files(record_list=[['buying', 'doctype', 'purchase_order']])
703elif patch_no == 167:
704 if webnotes.conn.get_value('Control Panel', None, 'account_id') not in ['ax0000956', 'ax0001338']:
705 sql("delete from tabDocField where parent = 'Purchase Order' and fieldname in ('test_certificate_required', 'estimated_cost', 'transport', 'vendor_reference', 'transportation_required', 'mode_of_dispatch', 'octroi')")
706elif patch_no == 168:
707 sql("update tabDocField set fieldtype = 'Data', options = 'Suggest' where fieldname = 'bank_name' and parent = 'Employee'")
708elif patch_no == 169:
709 import_from_files(record_list=[['accounts', 'doctype', 'pv_detail'], ['accounts', 'doctype', 'rv_detail']])
710elif patch_no == 170:
711 import_from_files(record_list=[['mapper', 'DocType Mapper', 'Delivery Note-Receivable Voucher']])
712elif patch_no == 171:
713 import_from_files(record_list=[['buying', 'doctype', 'supplier']])
714elif patch_no == 172:
715 import webnotes
716 webnotes.conn.set_global("system_message", """<b>Welcome to the new financial year 2011-2012 !!! </b><br><br> So obvious question in your mind is how to start Entries in the New Fiscal Year in ERPNext? What are the changes you have to make in the system? <br>We have made some guidelines regarding the basic steps you should follow. Please click on link <a href='http://erpnext.blogspot.com/2011/03/how-to-start-entries-in-new-fiscal-year.html'>How to start Entries in the New Fiscal Year in ERPNext?</a>""")
717 webnotes.conn.set_global("system_message_id", "6")
718elif patch_no == 173:
719 sql("delete from tabDocField where label = 'Get Other Charges' and parent = 'Delivery Note'")
720 sql("update tabDocField set reqd = 0 where fieldname = 'posting_time' and parent = 'Serial No'")
721elif patch_no == 174:
722 c = sql("select count(name) from `tabField Mapper Detail` where parent = 'Delivery Note-Receivable Voucher' and from_field = 'description' and to_field = 'description' and match_id = 2")
723 if c and cint(c[0][0]) > 1:
724 sql("update `tabField Mapper Detail` set match_id = 1 where parent = 'Delivery Note-Receivable Voucher' and from_field = 'description' and to_field = 'description' limit 1")
725elif patch_no == 175:
726 import webnotes
727 webnotes.conn.set_global("system_message", """If your financial year starts on 1st April then you have make some changes in the system to start entry in the new year.<br>We have made some guidelines regarding the basic steps you should follow. Please click on link <a href='http://erpnext.blogspot.com/2011/03/how-to-start-entries-in-new-fiscal-year.html'>How to start Entries in the New Fiscal Year in ERPNext?</a>""")
728 webnotes.conn.set_global("system_message_id", "6")
729elif patch_no == 176:
730 sql("update tabDocPerm set role='Guest', `write`=0, `create`=0 where role='Administrator' and parent='Notification Control' limit 1")
731elif patch_no == 177:
732 sql("delete from `tabDocField` where label = 'Next Steps' and parent = 'Purchase Order'")
733 sql("update tabDocField set options = 'Material Issue\nMaterial Receipt\nMaterial Transfer\nSales Return\nPurchase Return\nSubcontracting\nProduction Order' where parent = 'Stock Entry' and fieldname = 'purpose'")
734elif patch_no == 178:
735 import_from_files(record_list = [['hr', 'doctype', 'salary_slip']])
736elif patch_no == 179:
737 from webnotes.utils import get_defaults
738 sl = sql("select name, net_pay from `tabSalary Slip`")
739 for d in sl:
740 in_words = get_obj('Sales Common').get_total_in_words(get_defaults()['currency'], round(flt(d[1])))
741 sql("update `tabSalary Slip` set rounded_total = '%s', total_in_words = '%s' where name = '%s'" % (round(flt(d[1])), in_words, d[0]))
742elif patch_no == 180:
743 sql("delete from tabDocField where parent = 'Salary Slip' and fieldname = 'net_pay_in_words'")
744elif patch_no == 181:
745 import_from_files(record_list = [['accounts', 'doctype', 'journal_voucher']])
746elif patch_no == 182:
747 sql("update tabDocField set options = CONCAT(options, '\nWrite Off Voucher') where fieldname = 'voucher_type' and parent = 'Journal Voucher'")
748elif patch_no == 183:
749 sql("delete from tabDocField where label = 'SMS' and fieldtype = 'Section Break' and parent in ('Enquiry', 'Lead', 'Sales Order', 'Delivery Note')")
750elif patch_no == 184:
751 from webnotes.model import delete_doc
752 delete_doc('DocType', 'Feed')
753 delete_doc('DocType', 'Feed List')
754 delete_doc('DocType', 'Feed Control')
755
756 # add trigger
757 from webnotes.model.triggers import add_trigger
758 add_trigger('*','*','*','event_updates.update_feed')
759
760 webnotes.conn.commit()
761
762 try:
763 sql("drop table tabFeed")
764 sql("drop table `tabFeed List`")
765 except: pass
766
767 # import
768 from webnotes.modules.module_manager import reload_doc
769 reload_doc('event_updates','doctype','feed')
770elif patch_no==185:
771 sql("delete from tabDocTrigger where method = 'webnotes.widgets.follow.on_docsave'")
772elif patch_no==186:
773 from webnotes.modules.module_manager import reload_doc
774 reload_doc('event_updates','doctype','feed')
775elif patch_no == 187:
776 sql("update tabDocType set autoname = '' where name = 'QA Inspection Report'")
777elif patch_no == 188:
778 import_from_files(record_list = [['buying', 'doctype', 'qa_inspection_report']])
779elif patch_no == 189:
780 sql("update `tabDocField` set allow_on_submit = 1 where fieldname in ('entries', 'other_charges') and parent = 'Receivable Voucher'")
781elif patch_no == 190:
782 sql("update tabDocField set permlevel=0 where fieldname = 'fiscal_year' and parent = 'Stock Entry'")
783elif patch_no == 191:
784 import_from_files(record_list = [['support', 'doctype', 'customer_issue']])
785elif patch_no == 192:
786 sql("delete from `tabModule Def Item` where parent = 'Material Management' and doc_name = 'Landed Cost Wizard' and display_name = 'Landed Cost Wizard'")
787 import_from_files(record_list = [['buying', 'Module Def', 'SRM']])
788elif patch_no == 193:
789 sql("update tabDocField set fieldtype='Button', `trigger`='Client' where parent='Letter Head' and fieldname='set_from_image'")
790elif patch_no == 194:
791 sql("delete from `tabModule Def Item` where parent = 'SRM' and doc_name = 'Landed Cost Wizard' and display_name = 'Landed Cost Wizard'")
792 import_from_files(record_list = [['stock', 'Module Def', 'Material Management']])
793elif patch_no == 195:
794 from webnotes.modules.module_manager import reload_doc
795 reload_doc('setup','doctype','manage_account')
796elif patch_no == 196:
797 sql("update `tabModule Def` set module_page = null where name = 'Material Management'")
798elif patch_no == 197:
799 sql("update `tabDocField` set permlevel = 0, in_filter = 1 where fieldname = 'warranty_amc_status' and parent = 'Customer Issue'")
800 import_from_files(record_list = [['support', 'doctype', 'customer_issue']])
801elif patch_no == 198:
802 sql("delete from `tabDocField` where (label in ('SMS', 'Send SMS') or fieldname in ('message', 'customer_mobile_no')) and parent in ('Quoattion', 'Sales Order', 'Delivery Note', 'Receivable Voucher')")
803 sql("delete from `tabDocField` where label in ('SMS', 'Send SMS') and parent = 'Purchase Order'")
804 sql("delete from `tabDocField` where (label in ('Send SMS', 'SMS Html') or fieldname in ('sms_message', 'lead_sms_detail', 'enquiry_sms_detail')) and parent in ('Lead', 'Enquiry')")
805 from webnotes.model import delete_doc
806 delete_doc('DocType', 'Lead SMS Detail')
807 delete_doc('DocType', 'Enquiry SMS Detail')
808elif patch_no == 199:
809 sql("update tabDocField set reqd = 0 where parent = 'Attendance' and fieldname = 'shifts'")
810elif patch_no == 200:
811 reload_doc('event_updates','page','profile_settings')
812elif patch_no == 201:
813 reload_doc('setup','doctype','price_list')
814elif patch_no == 202:
815 name1 = sql("select name from tabDocField where parent='Price List' and label='Clear Prices' limit 1,1")
816 name2 = sql("select name from tabDocField where parent='Price List' and label='Update Prices' limit 1,1")
817 if name1:
818 sql("delete from tabDocField where name=%s limit 1", name1[0][0])
819 if name2:
820 sql("delete from tabDocField where name=%s limit 1", name2[0][0])
821elif patch_no == 203:
822 sql("delete from tabDocField where parent = 'Company' and fieldname = 'default_salary_account' limit 1")
823elif patch_no == 204:
824 sql("delete from tabDocField where parent = 'Company' and fieldname = 'default_salary_acount' limit 1")
825elif patch_no == 205:
826 sql("update `tabDocField` set `default` = '' where fieldname = 'naming_series' and parent = 'Installation Note'")
827elif patch_no == 206:
828 reload_doc('selling','doctype','installation_note')
829elif patch_no == 207:
830 import_from_files(record_list = [['setup', 'doctype', 'company']])
831elif patch_no == 208:
832 sql("delete from `tabDocField` where (label in ('SMS', 'Send SMS') or fieldname in ('message', 'customer_mobile_no')) and parent ='Quotation'")
833 default_currency = get_obj('Manage Account').doc.default_currency
834 sql("update tabCompany set default_currency = '%s'" % default_currency)
835elif patch_no == 209:
836 import_from_files(record_list = [['setup', 'doctype', 'company']])
837elif patch_no == 210:
838 sql("delete FROM `tabDocField` WHERE parent = 'Lead' AND label in ('CC:','Attachment Html','Create New File','Attachment')")
839elif patch_no == 212:
840 # reload company because of disturbed UI
841 import_from_files(record_list = [['setup', 'doctype', 'company']])
842elif patch_no == 213:
843 reload_doc('selling','doctype','lead')
844 reload_doc('setup','doctype','company')
845elif patch_no == 214:
846 reload_doc('selling','doctype','sales_order')
847elif patch_no == 215:
848 # patch for item and image in description
849 sql("update tabDocField set width = '300px' where fieldname='description'")
850 reload_doc('stock', 'doctype', 'item')
851 sql("delete from __DocTypeCache")
852elif patch_no == 216:
853 import_from_files(record_list = [['stock', 'doctype', 'serial_no'], ['stock', 'doctype', 'stock_ledger_entry']])
854elif patch_no == 217:
855 sql("update tabDocField set options = '\nIn Store\nDelivered\nNot in Use' where fieldname = 'status' and parent = 'Serial No'")
856 sql("update tabDocField set no_copy = 1 where fieldname = 'serial_no' and parent = 'Delivery Note Detail'")
857 sql("update tabDocField set no_copy = 1 where fieldname = 'serial_no' and parent = 'Stock Entry Detail'")
858elif patch_no == 218:
859 for d in sql("select name from `tabSerial No`"):
860 sql("Commit")
861 sql("Start Transaction")
862 s = Document('Serial No', d[0])
863 if s.pr_no:
864 s.purchase_document_type = 'Purchase Receipt'
865 s.purchase_document_no = s.pr_no
866 if s.delivery_note_no:
867 s.delivery_document_type = 'Delivery Note'
868 s.delivery_document_no = s.delivery_note_no
869 if s.notes:
870 s.delivery_note_no = s.notes
871 s.company = webnotes.utils.get_defaults()['company']
872 s.fiscal_year = webnotes.utils.get_defaults()['fiscal_year']
873 s.save()
874elif patch_no == 219:
875 sql("delete from tabDocField where fieldname in ('pr_no', 'make', 'label', 'delivery_note_no', 'notes') and parent = 'Serial No'")
876elif patch_no == 220:
877 sql("update tabDocField set label = 'Incoming Rate' where fieldname = 'purchase_rate' and parent = 'Serial No'")
878 sql("update tabDocField set label = 'Incoming Time' where fieldname = 'purchase_time' and parent = 'Serial No'")
879elif patch_no == 221:
880 sql("update tabDocField set reqd = 1 where fieldname in ('purchase_rate', 'warehouse') and parent = 'Serial No'")
881elif patch_no == 222:
882 sql("update tabDocField set options = '\nDelivery Note\nReceivable Voucher\nStock Entry' where fieldname = 'delivery_document_type' and parent = 'Serial No'")
883elif patch_no == 223:
884 sql("update tabDocField set hidden = 0 where fieldname in ('pay_to_recd_from', 'total_amount', 'total_amount_in_words') and parent = 'Journal Voucher'")
885 sql("update tabDocField set permlevel = 0 where fieldname = 'pay_to_recd_from' and parent = 'Journal Voucher'")
886elif patch_no == 224:
887 import_from_files(record_list = [['stock', 'doctype', 'delivery_note_packing_detail'], ['accounts', 'Print Format', 'Payment Receipt Voucher']])
888elif patch_no == 225:
889 import_from_files(record_list = [['stock', 'doctype', 'delivery_note_packing_detail']])
890elif patch_no == 226:
891 import_from_files(record_list = [['stock', 'doctype', 'delivery_note_packing_detail']])
892elif patch_no == 227:
893 reload_doc('stock', 'doctype', 'item')
894 if webnotes.conn.get_value('Control Panel', None, 'account_id') != 'axjanak2011':
895 sql("delete from tabDocField where parent = 'Item' and fieldname='alternate_description' limit 1")
896elif patch_no == 228:
897 # knowledge base patch
898 reload_doc('knowledge_base', 'doctype', 'question')
899 reload_doc('knowledge_base', 'doctype', 'answer')
900 reload_doc('knowledge_base', 'page', 'questions')
901 reload_doc('knowledge_base', 'Module Def', 'Knowledge Base')
902 sql("update `tabModule Def` set disabled='No' where name='Knowledge Base'")
903elif patch_no == 229:
904 reload_doc('knowledge_base', 'page', 'question_view')
905elif patch_no == 230:
906 reload_doc('buying', 'doctype', 'indent')
907 reload_doc('buying', 'doctype', 'indent_detail')
908 reload_doc('Mapper', 'DocType Mapper', 'Sales Order-Indent')
909elif patch_no == 231:
910 reload_doc('Mapper', 'DocType Mapper', 'Sales Order-Indent')
911elif patch_no == 232:
912 sql("update `tabDocField` set options = 'Sales Order' where fieldname = 'sales_order_no' and parent = 'Indent'")
913elif patch_no == 233:
914 reload_doc('Mapper', 'DocType Mapper', 'Sales Order-Receivable Voucher')
915 reload_doc('Mapper', 'DocType Mapper', 'Delivery Note-Receivable Voucher')
916elif patch_no == 234:
917 sql("update `tabTable Mapper Detail` set validation_logic = 'docstatus=1' where parent = 'Sales Order-Indent' and from_table = 'Sales Order Detail'")
918elif patch_no == 235:
919 for sc in sql("""select name from `tabSearch Criteria` where ifnull(name,'')
920 like 'srch%' or ifnull(name,'') like '%stdsrch'"""):
921 try:
922 get_obj('Search Criteria', sc[0]).rename()
923 except AttributeError, e:
924 pass
925 reload_doc('core', 'doctype', 'system_console')
926elif patch_no == 236:
927 # warehouse not mandatory for delivered serial nos
928 sql("update tabDocField set reqd=0 where parent='Serial No' and fieldname='warehouse'")
929elif patch_no == 237:
930 sql("update tabDocField set depends_on = 'eval:doc.is_pos==1' where fieldname = 'cash_bank_account' and parent = 'Receivable Voucher'")
931elif patch_no == 238:
932 reload_doc('accounts', 'doctype', 'receivable_voucher')
933 reload_doc('accounts', 'GL Mapper', 'POS with write off')
934elif patch_no == 239:
935 reload_doc('core', 'doctype', 'docfield')
936 reload_doc('core', 'doctype', 'doctype')
937 from patches.old_patches.feed_patch import set_subjects_and_tagfields
938
939 set_subjects_and_tagfields()
940elif patch_no == 240:
941 # again for sales order (status)
942 from patches.old_patches.feed_patch import set_subjects_and_tagfields
943 set_subjects_and_tagfields()
944elif patch_no == 241:
945 sql("update `tabDocField` set fieldtype = 'Text', options = '', in_filter = '' where fieldname = 'serial_no' and parent = 'Stock Ledger Entry'")
946elif patch_no == 242:
947 if webnotes.conn.get_value('Control Panel', None, 'account_id') not in ['axjanak2011']:
948 sql("commit")
949 try:
950 sql("alter table `tabStock Ledger Entry` drop index serial_no")
951 except:
952 pass
953
954 sql("alter table `tabStock Ledger Entry` change serial_no serial_no text")
955elif patch_no == 243:
956 # moving custom script and custom fields to framework
957 webnotes.conn.set_value('DocType', 'Custom Script', 'module', 'Core')
958 webnotes.conn.set_value('DocType', 'Custom Field', 'module', 'Core')
959 reload_doc('setup', 'doctype', 'company')
960elif patch_no == 244:
961 reload_doc('stock', 'search_criteria', 'shortage_to_indent')
962elif patch_no == 245:
963 from patches.old_patches.doctype_permission_patch import set_doctype_permissions
964 set_doctype_permissions()
965
966 from patches.old_patches.feed_patch import set_subjects_and_tagfields
967 set_subjects_and_tagfields()
968elif patch_no == 246:
969 webnotes.conn.set_value('DocType','Stock Entry','tag_fields','purpose')
970 webnotes.conn.set_value('DocType','Stock Entry','subject','%(remarks)s')
971elif patch_no == 247:
972 webnotes.conn.set_value('DocType','Stock Entry','subject','%(remarks)s')
973elif patch_no == 248:
974 reload_doc('setup', 'doctype', 'manage_account')
975elif patch_no == 249:
976 sql("update `tabDocPerm` t1, `tabDocType` t2 set t1.role = 'System Manager' where t1.role = 'Administrator' and t1.parent = t2.name and t2.module != 'Core'")
977elif patch_no == 250:
978 from patches.old_patches.feed_patch import support_patch
979 support_patch()
980elif patch_no == 251:
981 from webnotes.model import db_schema
982 db_schema.remove_all_foreign_keys()
983 from patches.old_patches.customer_address import run_patch
984 run_patch()
985elif patch_no == 252:
986 reload_doc('support','doctype','support_ticket')
987 reload_doc('support','doctype','support_ticket_response')
988elif patch_no == 253:
989 reload_doc('accounts','doctype','ledger_balance_export')
990 reload_doc('accounts','doctype','ledger_detail')
991 reload_doc('accounts', 'Module Def', 'Accounts')
992
993 from webnotes.model.db_schema import updatedb
994 updatedb('Ledger Balance Export')
995 updatedb('Ledger Detail')
996elif patch_no == 254:
997 reload_doc('setup', 'doctype', 'sms_settings')
998 reload_doc('setup', 'doctype', 'static_parameter_detail')
999
1000 from webnotes.model.db_schema import updatedb
1001 updatedb('SMS Settings')
1002 updatedb('Static Parameter Detail')
1003elif patch_no == 255:
1004 from patches.old_patches.customer_address import run_old_data_sync_patch
1005 run_old_data_sync_patch()
1006elif patch_no == 256:
1007 sql("update `tabLetter Head` set content = replace(content, 'http://46.4.50.84/v170-test/', '')")
1008 sql("update `tabSingles` set value = replace(value, 'http://46.4.50.84/v170-test/', '') where field in ('letter_head', 'client_name') and doctype = 'Control Panel'")
1009 sql("update `tabItem` set description_html = replace(description_html, 'http://46.4.50.84/v170-test/', '')")
1010elif patch_no == 257:
1011 from patches.old_patches.customer_address import run_old_data_sync_patch
1012 run_old_data_sync_patch()
1013elif patch_no == 258:
1014 sql("update tabDocField set `default`=NULL where fieldname = 'naming_series'")
1015elif patch_no == 259:
1016 sql("update `tabQuotation Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1017 sql("update `tabSales Order Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1018 sql("update `tabRV Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1019 sql("update `tabDelivery Note Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1020elif patch_no == 260:
1021 sql("update `tabLetter Head` set content = replace(content, 'http://46.4.50.84/v170/', '')")
1022 sql("update `tabSingles` set value = replace(value, 'http://46.4.50.84/v170/', '') where field in ('letter_head', 'client_name') and doctype = 'Control Panel'")
1023 sql("update `tabItem` set description_html = replace(description_html, 'http://46.4.50.84/v170/', '')")
1024 sql("update `tabQuotation Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1025 sql("update `tabSales Order Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1026 sql("update `tabRV Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1027 sql("update `tabDelivery Note Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1028elif patch_no == 261:
1029 sql("update `tabPrint Format` set html = replace(html, 'customer_address', 'address_display')")
1030elif patch_no == 262:
1031 from patches.old_patches.customer_address import sync_lead_phone
1032 sync_lead_phone()
1033elif patch_no == 263:
1034 ol = ['','Open','To Reply','Waiting for Customer','Hold','Closed']
1035 sql("update tabDocField set options=%s where parent=%s and fieldname=%s", ('\n'.join(ol), 'Support Ticket', 'status'))
1036elif patch_no == 264:
1037 sql("delete from tabDocField where parent = 'Customer Issue' and (fieldname = 'issue_in' or fieldname = 'issue_category')")
1038 sql("update tabDocField set options=NULL where parent='Support Ticket' and label = 'Send'")
1039elif patch_no == 266:
1040 reload_doc('setup','doctype','support_email_settings')
1041elif patch_no == 267:
1042 sql("update `tabPrint Format` set html = replace(html, 'supplier_address', 'address_display')")
1043elif patch_no == 268:
1044 sql("update `tabDocPerm` set permlevel = 0 where permlevel is null")
1045elif patch_no == 269:
1046 p = get_obj('Patch Util')
1047 p.add_permission('GL Entry', 'Accounts User', 0, read = 1)
1048elif patch_no == 270:
1049 pages = ['Accounts Setup', 'Accounts', 'Accounting Reports','GeneralLedger','How do I - Accounts','Making Opening Entries',\
1050 'Analysis','How do I - CRM','How do I - Inventory','Inventory Setup', 'Stock','HR','HR & Payroll Setup',\
1051 'Payroll Setup','Production Setup','Production','Buying','SRM Setup','Contact Page','Forum','Messages','Test Toolbar',\
1052 'Trend Analyzer']
1053 from webnotes.model import delete_doc
1054 sql("delete from `tabPage Visit`")
1055 for p in pages:
1056 try: delete_doc('Page', p)
1057 except: pass
1058elif patch_no == 271:
1059 # tags patch
1060 reload_doc('selling','doctype','sales_order')
1061 reload_doc('stock','doctype','delivery_note')
1062 sql("delete from tabDocField where fieldname='per_amt_billed' and parent in ('Sales Order', 'Delivery Note')")
1063
1064 sql("""update `tabSales Order` set delivery_status = if(ifnull(per_delivered,0) < 0.001, 'Not Delivered',
1065 if(per_delivered >= 99.99, 'Fully Delivered', 'Partly Delivered'))""")
1066 sql("""update `tabSales Order` set billing_status = if(ifnull(per_billed,0) < 0.001, 'Not Billed',
1067 if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""")
1068 sql("""update `tabDelivery Note` set billing_status = if(ifnull(per_billed,0) < 0.001, 'Not Billed',
1069 if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""")
1070elif patch_no == 272:
1071 from webnotes.model import delete_doc
1072 try:
1073 delete_doc('Search Criteria', '_SRCH00003')
1074 except:
1075 pass
1076 reload_doc('accounts', 'search_criteria', 'purchase_register')
1077elif patch_no == 276:
1078 from webnotes.model import delete_doc
1079 sn = sql("select name from `tabSearch Criteria` where criteria_name = 'Sales Personwise Transaction Summary'")
1080 for d in sn:
1081 delete_doc('Search Criteria', d[0])
1082 reload_doc('selling', 'search_criteria', 'sales_personwise_transaction_summary')
1083elif patch_no == 277:
1084 webnotes.model.delete_doc('DocType','HomePage Settings')
1085 webnotes.model.delete_doc('DocType','Badge Settings')
1086 sql("update tabDocType set module='Home' where module in ('Event Updates', 'My Company')")
1087 sql("update tabPage set module='Home' where module in ('Event Updates', 'My Company')")
1088 sql("update `tabSearch Criteria` set module='Home' where module in ('Event Updates', 'My Company')")
1089
1090
1091 delete_pages = ('Chat User Gallery', 'Badge Info', 'Home', 'Website Setup', 'Test Page', 'Setup Masters', 'Service', 'Selling', 'Sales Reports', 'Organize','My Cart', 'My Activity', 'Manage Users', 'Maintenance', 'Getting Started', 'Gantt Test', 'Custom Reports - Stock', 'Custom Reports - Selling', 'Custom Reports - Production', 'Custom Reports - Payroll', 'Custom Reports - Maintenance', 'Custom Reports - Buying', 'Custom Reports - Accounts', 'CRM Setup', 'CRM Reports')
1092 for p in delete_pages:
1093 webnotes.model.delete_doc('Page',p)
1094elif patch_no == 278:
1095 sql("update tabDocTrigger set method = 'home.update_feed' where method = 'event_updates.update_feed'")
1096elif patch_no == 279:
1097 dt = ['GL Entry', 'Stock Ledger Entry']
1098 for t in dt:
1099 rec = sql("select voucher_type, voucher_no, ifnull(is_cancelled, 'No') from `tab%s` where modified >= '2011-06-15 01:00:00' group by voucher_no" % t)
1100 for d in rec:
1101 sql("update `tab%s` set docstatus = %s where name = '%s'" % (d[0], d[2]=='No' and 1 or 2, d[1]))
1102
1103 other_dt = ['Enquiry', 'Quotation', 'Sales Order', 'Indent', 'Purchase Order', 'Production Order', 'Customer Issue', 'Installation Note']
1104 for dt in other_dt:
1105 rec = sql("select name, status from `tab%s` where modified >= '2011-06-15 01:00:00'" % dt)
1106 for r in rec:
1107 sql("update `tab%s` set docstatus = %s where name = '%s'" % (dt, (r[1] in ['Submitted', 'Closed'] and 1 or r[1]=='Cancelled' and 2 or 0), r[0]))
1108elif patch_no == 280:
1109 reload_doc('accounts', 'doctype', 'form_16a')
1110elif patch_no == 281:
1111 dt_list = ['Delivery Note', 'Purchase Receipt']
1112 for dt in dt_list:
1113 sql("update `tab%s` set status = 'Submitted' where docstatus = 1 and modified >='2011-06-15 01:00:00'" % dt)
1114 sql("update `tab%s` set status = 'Cancelled' where docstatus = 2 and modified >='2011-06-15 01:00:00'" % dt)
1115elif patch_no == 282:
1116 dt_list = ['Enquiry', 'Quotation', 'Sales Order', 'Indent', 'Purchase Order', 'Production Order', 'Customer Issue', 'Installation Note', 'Receivable Voucher', 'Payable Voucher', 'Delivery Note', 'Purchase Receipt', 'Journal Voucher', 'Stock Entry']
1117 for d in dt_list:
1118 tbl = sql("select options from `tabDocField` where fieldtype = 'Table' and parent = '%s'" % d)
1119 for t in tbl:
1120 sql("update `tab%s` t1, `tab%s` t2 set t1.docstatus = t2.docstatus where t1.parent = t2.name" % (t[0], d))
1121elif patch_no == 283:
1122 rec = sql("select voucher_type, voucher_no, ifnull(is_cancelled, 'No') from `tabGL Entry` where modified >= '2011-06-15 01:00:00' order by name ASC")
1123 for d in rec:
1124 sql("update `tab%s` set docstatus = %s where name = '%s'" % (d[0], d[2]=='No' and 1 or 2, d[1]))
1125elif patch_no == 284:
1126 reload_doc('support', 'doctype', 'support_ticket')
1127 sql("update `tabDocField` set in_filter = 1 where fieldname in ('raised_by', 'subject') and parent = 'Support Ticket'")
1128elif patch_no == 286:
1129 reload_doc('accounts', 'search_criteria', 'itemwise_sales_register')
1130 reload_doc('accounts', 'search_criteria', 'itemwise_purchase_register')
1131elif patch_no == 287:
1132 sql("update `tabDocField` set no_copy = 1 where fieldname in ('per_received', 'per_billed', 'per_delivered') and parent in ('Purchase Order', 'Purchase Receipt', 'Sales Order', 'Delivery Note')")
1133elif patch_no == 288:
1134 reload_doc('accounts', 'doctype', 'payable_voucher')
1135elif patch_no == 289:
1136 sql("update `tabDocType` set subject = 'From %(supplier_name)s worth %(grand_total)s due on %(due_date)s | %(outstanding_amount)s outstanding' where name = 'Payable Voucher'")
1137 sql("update `tabDocType` set search_fields = 'status,transaction_date,customer,lead,order_type' where name = 'Quotation'")
1138elif patch_no == 290:
1139 count = sql("""SELECT * FROM `tabModule Def`
1140 WHERE `module_name` LIKE 'Home'""")
1141 if not count:
1142 md = Document('Module Def')
1143 md.module_name = 'Home'
1144 md.module_label = 'Home'
1145 md.save(1)
1146elif patch_no == 291:
1147 reload_doc('utilities','doctype','rename_tool')
1148elif patch_no == 292:
1149 reload_doc('accounts', 'search_criteria', 'trial_balance')
1150elif patch_no == 293:
1151 sql("delete from tabDocField where parent='Account' and fieldname='address'")
1152 reload_doc('accounts', 'doctype', 'account')
1153elif patch_no == 294:
1154 # new account profile fix
1155 ul = sql("select name from tabProfile where ifnull(name,'') not in ('Administrator', 'Guest', '')")
1156 # if one user and one user has no roles
1157 if len(ul)==1 and not sql("select parent from tabUserRole where role='System Manager' and parent=%s", ul[0][0]):
1158 get_obj('Setup Control').add_roles(Document('Profile', ul[0][0]))
1159elif patch_no == 295:
1160 sql("update `tabDocField` set options = 'Delivered\nNot Delivered\nPartly Delivered\nClosed\nNot Applicable' where parent = 'Sales Order' and fieldname = 'delivery_status'")
1161 sql("update `tabDocField` set options = 'Billed\nNot Billed\nPartly Billed\nClosed' where parent = 'Sales Order' and fieldname = 'billing_status'")
1162elif patch_no == 296:
1163 sql("delete from tabDocField where parent='Support Ticket' and fieldname='contact_no'")
1164 reload_doc('support', 'doctype', 'support_ticket')
1165elif patch_no == 297:
1166 reload_doc('hr', 'doctype', 'employee')
1167 reload_doc('hr', 'doctype', 'attendance')
1168 reload_doc('hr', 'doctype', 'expense_voucher')
1169 reload_doc('hr', 'doctype', 'appraisal')
1170 reload_doc('hr', 'doctype', 'salary_structure')
1171 reload_doc('hr', 'doctype', 'salary_slip')
1172elif patch_no == 298:
1173 sql("update `tabDocField` set options = 'link:Company' where parent = 'Attendance' and fieldname = 'company'")
1174 sql("update `tabDocField` set options = 'link:Company' where parent = 'Expense Voucher' and fieldname = 'company'")
1175 sql("update `tabDocField` set options = 'link:Company' where parent = 'Appraisal' and fieldname = 'company'")
1176elif patch_no == 299:
1177 sql("update `tabDocPerm` set `match` = NULL where parent = 'Employee' and role = 'Employee'")
1178elif patch_no == 300:
1179 sql("""DELETE FROM `tabSearch Criteria` WHERE name IN
1180 ('sales_register1', 'sales_register2', 'purchase_register1')""")