blob: 18272fced5fd0f5fe2e08c75a20e8746905b39f9 [file] [log] [blame]
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301# REMEMBER to update this
2# ========================
nabinhaita56fc002011-07-01 16:32:03 +05303
nabinhaitde9826c2011-07-20 18:02:59 +05304last_patch = 329
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05305
6#-------------------------------------------
7
8def execute(patch_no):
9 import webnotes
10 from webnotes.modules.import_module import import_from_files
11 from webnotes.modules.module_manager import reload_doc
12
13 from webnotes.model.code import get_obj
14 sql = webnotes.conn.sql
15 from webnotes.utils import cint, cstr, flt
16 from webnotes.model.doc import Document
17
18 if patch_no==33:
19 pass
20 elif patch_no==34:
21 webnotes.conn.sql("update `tabDocField` set options = 'Letter Head', print_hide = 1 where fieldname = 'letter_head' and fieldtype = 'Link'")
22 elif patch_no==35:
23 webnotes.conn.sql("update tabDocType set module = 'Event Updates' where name = 'Feed Control'")
24 elif patch_no==36:
25 # remove delivery note foreign key in Serial Number
26 from webnotes.model.db_schema import DbTable
27 t = DbTable('Serial No')
28 fk_list = t.get_foreign_keys()
29 for f in fk_list:
30 if f[0]=='delivery_note_no':
31 webnotes.conn.commit()
32 webnotes.conn.sql("alter table `tabSerial No` drop foreign key `%s`" % f[1])
33 webnotes.conn.begin()
34 webnotes.conn.sql("update tabDocField set fieldtype='Data' where fieldname='delivery_note_no' and parent='Serial No' limit 1")
35 elif patch_no==37:
36 import os
37 mod_path = webnotes.defs.modules_path
38 path_list = []
39 for m in os.listdir(mod_path):
40 for t in ['doctype', 'page', 'search_criteria']:
41 dt_path = os.path.join(mod_path, m, t)
42 if os.path.exists(dt_path):
43 for dt in os.listdir(dt_path):
44 if '.' not in dt and os.path.exists(os.path.join(dt_path, dt, dt+ '.txt')):
45 path_list.append(os.path.join(dt_path, dt, dt+ '.txt'))
46
47 for d in path_list:
48 doclist = eval(open(d,'r').read())
49 webnotes.conn.sql("update `tab%s` set module = '%s' where name = '%s'" % (doclist[0]['doctype'], doclist[0]['module'], doclist[0]['name']))
50
51 elif patch_no==38:
52 import webnotes
53 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.")
54 webnotes.conn.set_global("system_message_id", "1")
55
56 elif patch_no == 39:
57 pass
58
59 elif patch_no == 40:
60
61 import_from_files(record_list=[['material_management','doctype','item']])
62 elif patch_no == 42:
63 acc = sql("select name, lft, rgt from tabAccount where account_name in ('Incomes', 'Expenses')")
64 for d in acc:
65 sql("update tabAccount set is_pl_account = 'Yes' where lft >= '%s' and rgt <= '%s'" % (d[1], d[2]))
66 elif patch_no == 43:
67 import webnotes.model
68 webnotes.model.delete_doc('Page', 'Module Manager')
69
70 # cleanup of Service, Customer Support, Utilities Modules
71 # -------------------------------------------------------
72 elif patch_no == 44:
73 from webnotes.model import delete_doc
74
75 for dt in sql("select name from tabDocType where module in ('Customer Support')"):
76 delete_doc('DocType', dt[0])
77
78 for dt in sql("select name from `tabSearch Criteria` where module in ('Customer Support')"):
79 delete_doc('Search Criteria', dt[0])
80
81 for dt in sql("select name from tabPage where module in ('Customer Support')"):
82 delete_doc('Page', dt[0])
83
84 # move a couple
85 webnotes.conn.sql("update `tab%s` set module=%s where name=%s" % ('DocType', '%s', '%s'), ('Application Internal', 'Patch Util'))
86 webnotes.conn.sql("update `tab%s` set module=%s where name=%s" % ('DocType', '%s', '%s'), ('Application Internal', 'DocType Property Setter'))
87
88 # remove utilities
89 webnotes.conn.sql('delete from `tabModule Def` where name in ("Customer Support", "Utilities")')
90
91 elif patch_no == 45:
92 webnotes.conn.sql('delete from tabDocField where options="Ticket Response Detail"')
93
94 elif patch_no == 46:
95 import webnotes
96 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.")
97 webnotes.conn.set_global("system_message_id", "2")
98
99 elif patch_no == 47:
100 import webnotes
101 webnotes.conn.set_global("system_message", "")
102 webnotes.conn.set_global("system_message_id", "3")
103
104 elif patch_no == 48:
105 webnotes.conn.sql("update tabDocField set options = 'Print Heading' where fieldname = 'select_print_heading'")
106
107 elif patch_no == 49:
108 webnotes.conn.sql("update tabDocType set autoname = '' where name = 'Search Criteria'")
109 elif patch_no == 50:
110 sql("update tabDocField set in_filter = 1 where fieldname in ('cost_center', 'income_account', 'Item Group') and parent = 'RV Detail'")
111 elif patch_no == 51:
112 sql("update tabDocField set options = 'link:Print Heading' where fieldtype = 'Select' and fieldname = 'select_print_heading' and parent = 'POS Setting'")
113 elif patch_no == 52:
114 sql("update tabDocField set print_hide = 1 where fieldname = 'letter_head'")
115 elif patch_no == 53:
116 sql("update tabDocType set search_fields = 'lead_name,lead_owner,status,contact_by,contact_date' where name = 'Lead'")
117 elif patch_no == 54:
118 sql("delete from tabDocField where parent = 'Supplier' and label = 'Supplier Contacts' and fieldtype = 'Section Break'")
119 elif patch_no == 55:
120 sql("commit")
121 try:
122 sql("alter table tabFeed add column `_user_tags` varchar(180)")
123 except Exception, e:
124 if e.args[0]!=1060:
125 raise e
126 elif patch_no == 56:
127 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'")
128 elif patch_no == 57:
129
130 import_from_files(record_list=[['crm','doctype','sales_order_detail']])
131 elif patch_no == 58:
132 # module def patches
133 sql("update `tabModule Def` set module_page = NULL where name not in ('Event Updates', 'Setup', 'My Company')")
134 sql("delete from `tabModule Def Item` where doc_type in ('Separator', 'Setup Forms', 'More Reports')")
135 sql("delete from `tabModule Def Item` where doc_name = 'Project Activity'")
136 sql("update `tabModule Def` set module_label = 'People', disabled='No', is_hidden='No' where name = 'My Company'")
137
138 # insert new module items
139 from webnotes.model.doc import make_autoname
140 if not sql("select name from `tabModule Def Item` where parent='Projects' and doc_name='Ticket'"):
141 sql("""insert into `tabModule Def Item`
142 (name, parent, parenttype, parentfield, docstatus, doc_type, doc_name, display_name, idx) values
143 (%s, 'Projects', 'Module Def', 'items', 0, 'Forms', 'Ticket', 'Task', 1)""", make_autoname('MDI.#####'))
144
145 if not sql("select name from `tabModule Def Item` where parent='Projects' and doc_name='Timesheet'"):
146 sql("""insert into `tabModule Def Item`
147 (name, parent, parenttype, parentfield, docstatus, doc_type, doc_name, display_name, idx) values
148 (%s, 'Projects', 'Module Def', 'items', 0, 'Forms', 'Timesheet', 'Timesheet', 2)""", make_autoname('MDI.#####'))
149
150 if not sql("select name from `tabModule Def Item` where parent='Projects' and doc_name='Projects'"):
151 sql("""insert into `tabModule Def Item`
152 (name, parent, parenttype, parentfield, docstatus, doc_type, doc_name, display_name, idx) values
153 (%s, 'Projects', 'Module Def', 'items', 0, 'Pages', 'Projects', 'Gantt Chart', 1)""", make_autoname('MDI.#####'))
154
155 elif patch_no == 59:
156 webnotes.conn.set_value('Control Panel',None,'mail_footer','')
157 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>')
158 elif patch_no == 60:
159 sql("delete from `tabModule Def Item` where display_name = 'Point of Sales'")
160 elif patch_no == 61:
161 sql("delete from `tabTDS Category Account` where company not in (select name from tabCompany)")
162 elif patch_no == 62:
163 # Import Supplier Quotation
164
165 import_from_files(record_list=[['srm','doctype','supplier_quotation']])
166 # Adding Status Filter
167 sql("update tabDocType set search_fields = concat('status,',search_fields) where name IN ('Delivery Note','Leave Transaction')")
168 # Import Other Charges
169
170 import_from_files(record_list=[['setup','doctype','other_charges']])
171 elif patch_no == 63:
172 sql("update `tabDocField` set permlevel = 1 where fieldname in ('return_date', 'return_details') and parent = 'Sales and Purchase Return Wizard'")
173
174 import_from_files(record_list = [['accounts', 'doctype', 'rv_detail'], ['material_management', 'doctype', 'sales_and_purchase_return_wizard'], ['material_management', 'doctype', 'stock_entry']])
175 elif patch_no == 64:
176 sql("update tabDocField set `hidden` = 1, `print_hide` = 1, `report_hide` = 1 where options in ('RFQ','Supplier Quotation')")
177 sql("update tabDocType set `read_only` = 1, in_create = 1 where name in ('RFQ','Supplier Quotation')")
178 sql("update tabDocField set `report_hide` = 0 where fieldname in ('email_id','phone_1','fax_1') and parent = 'Customer'")
179 elif patch_no == 65:
180 # Monthly Trend Analyzer <-> Trend Analyzer
181 sql("update `tabSearch Criteria` set criteria_name = 'Trend Analyzer' where criteria_name = 'Monthly Trend Analyzer' and name = 'SRCH/00159'")
182 sql("update `tabModule Def Item` set display_name = 'Trend Analyzer' where parent = 'Analysis' and display_name = 'Monthly Trend Analyzer'")
183 elif patch_no == 66:
184 import webnotes
185 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!""")
186 webnotes.conn.set_global("system_message_id", "4")
187
188 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')")
189 from webnotes.session_cache import clear_cache
190 clear_cache(webnotes.session['user'])
191 elif patch_no == 67:
192 sql("update `tabDocField` set in_filter = 1 where fieldname = 'brand' and parent = 'RV Detail'")
193 sql("delete from `tabModule Def Item` where (display_name = 'Sales Invoice' and parent = 'CRM') or (display_name = 'Purchase Invoice' and parent = 'SRM')")
194 elif patch_no == 68:
195 from webnotes.modules.import_module import import_from_files
196 import_from_files(record_list=[['payroll','doctype','employee'],['roles','Role','Employee']])
197 elif patch_no == 69:
198 # delete flds from employee master
199 p = get_obj('Patch Util')
200 emp_del_flds = ['month_of_birth']
201 for f in emp_del_flds:
202 p.delete_field('Employee', f)
203
204 sql("Update tabDocField set `default` = 'Active' where fieldname = 'status' and parent = 'Employee'")
205
206 # map parent flds
207 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']
208
209 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")
210 for e in emp_prof:
211 prof_obj = get_obj('Employee Profile', e[0])
212 emp_obj = get_obj('Employee', e[1])
213 for d in fld_map:
214 emp_obj.doc.fields[d] = prof_obj.doc.fields[d]
215 emp_obj.doc.current_accommodation_type = prof_obj.doc.present_accommodation_type
216
217 # address
218 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])
219 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])
220 emp_obj.doc.permanent_address = per_addr
221 emp_obj.doc.current_address = cur_addr
222 #family
223 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])
224 emp_obj.doc.family_background = fam
225 # health
226 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])
227 emp_obj.doc.health_details = health
228 emp_obj.doc.save()
229
230
231 # map tables
232 tbl_list = ['Experience In Company Detail', 'Previous Experience Detail', 'Educational Qualifications Detail']
233 for t in tbl_list:
234 sql("update `tab%s` t1, `tabEmployee Profile` t2 set t1.parent = t2.employee, t1.parenttype = 'Employee' where t1.parent = t2.name" % t)
235
236
237 # overwrite idx?????????
238
239
240 # delete emp profile
241 webnotes.model.delete_doc('DocType', 'Employee Profile')
242 for e in emp_prof:
243 webnotes.model.delete_doc('Employee Profile', e[0])
244
245 elif patch_no == 70:
246 # update search criteria module -> System
247 sql("update tabDocType set module='System' where name='Search Criteria'")
248
249 # Cleanups to Contact
250 sql("update tabDocField set fieldtype='Data' where options='Designation' and parent='Contact'")
251 sql("update tabDocField set fieldtype='Data' where options='Department' and parent='Contact'")
252 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'")
253
254 # import Contact, Employee
255 from webnotes.modules.import_module import import_from_files
256 import_from_files(record_list=[['tools','doctype','contact']])
257
258
259 # remove last_contact_date from Lead
260 sql("delete from tabDocField where fieldname='last_contact_date' and parent='Lead'")
261
262 elif patch_no == 71:
263 # Make Stock Qty and Conversion Factor field editable. Also no need to mention Conversion factor in table can do it directly
264 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')")
265 sql("update `tabDocField` set `width` = '100px' where parent IN ('PO Detail','Purchase Receipt Detail') and fieldname = 'stock_uom'")
266
267 elif patch_no == 72:
268 # Core Patch
269 # ----------
270
271 from webnotes.modules.import_module import import_from_files
272
273 # import module def
274 import_from_files(record_list = [['core', 'Module Def', 'Core']])
275 elif patch_no == 73:
276 # set module in DocTypes
277 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')")
278
279 # set module in Page
280 sql("update tabPage set module='Core' where name='Login Page'")
281
282 # move file browser to Tools
283 sql("update tabPage set module='Tools' where name='File Browser'")
284 sql("update tabDocType set module='Tools' where name='File Browser Control'")
285 sql("update tabDocType set module='Application Internal' where name='Profile Control'")
286 elif patch_no == 74:
287 p = get_obj('Patch Util')
288 # permission
289 p.delete_permission('Employee', 'Administrator', 0)
290 p.delete_permission('Employee', 'Administrator', 1)
291 p.add_permission('Employee', 'Employee', 0, read = 1, match = 'owner')
292 p.add_permission('Employee', 'Employee', 1, read = 1, match = 'owner')
293 sql("delete from `tabDocField` where parent = 'Employee' and label = 'Payroll Rule'")
294 elif patch_no == 75:
295 #sal structure patch
296 # import
297 from webnotes.modules.import_module import import_from_files
298 import_from_files(record_list=[['payroll','doctype','salary_structure'], ['payroll','doctype','earning_detail'],['payroll','doctype','deduction_detail']])
299 elif patch_no == 76:
300 # property
301 p = get_obj('Patch Util')
302 p.set_field_property('Salary Structure', 'is_active', 'default', 'Yes')
303 p.set_field_property('Salary Structure', 'ctc', 'reqd', '1')
304 p.set_field_property('Earning Detail', 'modified_value', 'width', '')
305 p.set_field_property('Earning Detail', 'modified_value', 'trigger', 'Client')
306 p.set_field_property('Deduction Detail', 'd_modified_amt', 'width', '')
307 p.set_field_property('Earning Detail', 'd_modified_amt', 'trigger', 'Client')
308 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'")
309
310 # delete
311 sql("update `tabSalary Structure` set net_pay = total")
312 sql("delete from tabDocField where label in ('LWP Help', 'Calculate Total', 'Total') and parent = 'Salary Structure'")
313 sql("delete from tabDocPerm where parent in ('Earning Detail', 'Deduction Detail')")
314
315
316 # permission
317 p.delete_permission('Salary Structure', 'Administrator', 0)
318 p.delete_permission('Salary Structure', 'Administrator', 1)
319 p.add_permission('Salary Structure', 'Employee', 0, read = 1, match = 'owner')
320 p.add_permission('Salary Structure', 'Employee', 1, read = 1, match = 'owner')
321 elif patch_no == 77:
322 # sal slip patch
323 # import
324 from webnotes.modules.import_module import import_from_files
325 import_from_files(record_list=[['payroll','doctype','salary_slip'], ['payroll','doctype','ss_earning_detail'],['payroll','doctype','ss_deduction_detail'], ['mapper', 'DocType Mapper', 'Salary Structure-Salary Slip']])
326 elif patch_no == 78:
327 p = get_obj('Patch Util')
328 # delete
329 sql("update `tabSalary Slip` set leave_encashment_amount = encashment_amount")
330 p.delete_field('Salary Slip', 'encashment_amount')
331 p.delete_field('Salary Slip', 'year')
332 p.delete_field('Salary Slip', 'flag')
333 sql("delete from tabDocField where label = 'Process Payroll' and parent = 'Salary Slip'")
334
335 # field property
336 p.set_field_property('Salary Slip', 'bank_name', 'permlevel', '1')
337 p.set_field_property('Salary Slip', 'leave_without_pay', 'permlevel', '0')
338 p.set_field_property('Salary Slip', 'leave_without_pay', 'trigger', 'Client')
339 p.set_field_property('SS Earning Detail', 'e_type', 'permlevel', '0')
340 p.set_field_property('SS Earning Detail', 'e_type', 'fieldtype', 'Link')
341 p.set_field_property('SS Earning Detail', 'e_type', 'options', 'Earning Type')
342 p.set_field_property('SS Deduction Detail', 'd_type', 'permlevel', '0')
343 p.set_field_property('SS Deduction Detail', 'd_type', 'fieldtype', 'Link')
344 p.set_field_property('SS Deduction Detail', 'd_type', 'options', 'Deduction Type')
345 sql("update `tabSS Earning Detail` set e_modified_amount = e_amount")
346 sql("update `tabSS Deduction Detail` set d_modified_amount = d_amount")
347
348 # permission
349 p.delete_permission('Salary Slip', 'Administrator', 0)
350 p.delete_permission('Salary Slip', 'Administrator', 1)
351 p.add_permission('Salary Slip', 'Employee', 0, read = 1, match = 'owner')
352 p.add_permission('Salary Slip', 'Employee', 1, read = 1, match = 'owner')
353 elif patch_no == 79:
354 # Import Modules
355
356 import_from_files(record_list=[['payroll','doctype','leave_application'],['payroll','doctype','leave_allocation'],['payroll','doctype','leave_control_panel'],['payroll','doctype','holiday_list'],['payroll','doctype','holiday_list_detail'],['payroll','Module Def','Payroll']])
357 elif patch_no == 80:
358 # Holiday List
359 sql("update `tabHoliday List Detail` set description = holiday_name")
360 sql("delete from tabDocField where parent = 'Holiday List Detail' and fieldname = 'holiday_name'")
361 sql("update tabDocField set fieldtype = 'Select', options = 'link:Fiscal Year' where parent = 'Holiday List' and fieldname = 'fiscal_year'")
362 sql("delete from tabDocPerm where role in ('Administrator','HR User') and parent = 'Holiday List'")
363
364 # Leave Control Panel
365 # --------------------
366 sql("delete from `tabDocField` where parent = 'Leave Control Panel' and label in ('Leave Control Panel','Allocation Details') and fieldtype = 'Section Break'")
367 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')")
368 sql("update tabDocField set fieldtype = 'Select', options = 'link:Fiscal Year' where parent = 'Leave Control Panel' and fieldname = 'fiscal_year'")
369 sql("update tabDocField set fieldtype = 'Select', options = 'link:Leave Type' where parent = 'Leave Control Panel' and fieldname = 'leave_type'")
370 sql("update tabDocField set reqd = 1 where parent = 'Leave Control Panel' and fieldname = 'no_of_days'")
371
372 # Leave Application
373 # ------------------
374 for d in sql("select * from `tabLeave Transaction` where leave_transaction_type = 'Deduction' and ifnull(deduction_type, '') = 'Leave'", as_dict = 1):
375 lp = Document('Leave Application')
376 lp.employee = d['employee']
377 lp.leave_type = d['leave_type']
378 lp.posting_date = d['date']
379 lp.fiscal_year = d['fiscal_year']
380 lp.leave_balance = d['pre_balance']
381 lp.half_day = d['half_day']
382 lp.from_date = d['from_date']
383 lp.to_date = d['to_date']
384 lp.total_leave_days = d['total_leave']
385 lp.description = d['reason']
386 lp.docstatus = cint(d['docstatus'])
387 lp.save(1)
388
389 # Leave Allocation
390 # -----------------
391 for d in sql("select * from `tabLeave Transaction` where leave_transaction_type = 'Allocation'", as_dict = 1):
392 la = Document('Leave Allocation')
393 la.employee = d['employee']
394 la.leave_type = d['leave_type']
395 la.posting_date = d['date']
396 la.fiscal_year = d['fiscal_year']
397 la.new_leaves_allocated = d['total_leave']
398 la.total_leaves_allocated = d['total_leave']
399 la.description = d['reason']
400 la.docstatus = cint(d['docstatus'])
401 la.save(1)
402
403 # Payroll Module Def
404 # -------------------
405 sql("delete from `tabModule Def Item` where doc_name = 'Leave Transaction' and display_name = 'Leave Transaction' and parent = 'Payroll' and doc_type = 'Forms'")
406
407 elif patch_no == 81:
408 # Import Modules
409
410 import_from_files(record_list=[['payroll','Module Def','Payroll']])
411 elif patch_no == 82:
412 sql("update tabDocType set search_fields = 'employee,leave_type,total_leaves_allocated,fiscal_year' where name = 'Leave Allocation'")
413 sql("update tabDocType set search_fields = 'employee,leave_type,from_date,to_date,total_leave_days,fiscal_year' where name = 'Leave Application'")
414 elif patch_no == 83:
415 # delete leave transaction
416 webnotes.conn.sql("set foreign_key_checks=0")
417 sql("delete from `tabLeave Transaction`")
418 import webnotes.model
419 webnotes.model.delete_doc('DocType','Badge Settings Detail')
420 webnotes.model.delete_doc('DocType','Leave Transaction')
421 webnotes.conn.sql("set foreign_key_checks=1")
422 elif patch_no == 84:
423 p = get_obj('Patch Util')
424 p.set_field_property('SS Earning Detail', 'e_amount', 'permlevel', '1')
425 p.set_field_property('SS Deduction Detail', 'd_amount', 'permlevel', '1')
426 elif patch_no == 85:
427 # permission
428 p = get_obj('Patch Util')
429 p.add_permission('Leave Application', 'Employee', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1, match = 'owner')
430 p.add_permission('Leave Application', 'Employee', 1, read = 1, match = 'owner')
431 p.add_permission('Leave Allocation', 'HR User', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1, match = 'owner')
432 p.add_permission('Leave Allocation', 'HR User', 1, read = 1)
433 sql("update tabDocPerm set `match` = '' where parent = 'Leave Application' and role = 'HR User'")
434 elif patch_no == 86:
435 # Import Modules
436
437 import_from_files(record_list=[['payroll','doctype','leave_type']])
438 elif patch_no == 87:
439 sql("update `tabLeave Type` set is_lwp = 1 where name = 'Leave Without Pay'")
440 elif patch_no == 88:
441 # Import Modules
442
443 import_from_files(record_list=[['payroll','doctype','leave_allocation']])
444 elif patch_no == 89:
445 sql("delete from `tabModule Def Item` where doc_type = 'Setup Forms' and doc_name in ('Payroll Rule', 'IT Checklist', 'Employee Profile') and parent = 'Payroll'")
446 sql("update `tabDocField` set `hidden` = 1, `print_hide` = 1, `report_hide` = 1 where parent = 'Leave Type' and fieldname = 'is_encash'")
447 elif patch_no == 90:
448 sql("update `tabLeave Allocation` set docstatus = 1")
449 elif patch_no == 91:
450 import webnotes
451 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!""")
452 webnotes.conn.set_global("system_message_id", "5")
453 elif patch_no == 92:
454 sql("update tabDocField set label = 'Get Charges' where parent IN ('Sales Order','Delivery Note','Receivable Voucher') and label = 'Get Other Charges' and fieldtype = 'Button'")
455 # Automated Other Charges Calculation basis
456 sql("update tabDocField set options = '', `trigger` = 'Client' where parent IN ('Quotation','Sales Order','Delivery Note','Receivable Voucher') and label = 'Get Charges' and fieldtype = 'Button'")
457 elif patch_no == 93:
458 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'")
459 sql("update `tabField Mapper Detail` set from_field = 'customer' where to_field = 'customer' and parent = 'Sales Order-Receivable Voucher'")
460 elif patch_no == 94:
461
462 import_from_files(record_list=[['crm','doctype','sms_center']])
463 elif patch_no == 95:
464
465 import_from_files(record_list=[['mapper','DocType Mapper','Sales Order-Receivable Voucher'], ['mapper','DocType Mapper','Delivery Note-Receivable Voucher']])
466 elif patch_no == 96:
467 sql("delete from `tabModule Def Item` where doc_type = 'Reports' and display_name = 'Cenvat Credit - Input or Capital Goods' and parent = 'Accounts'")
468 elif patch_no == 97:
469 sql("update tabFeed set doc_label = 'Feed', doc_name = name where ifnull(doc_name,'') = '' and ifnull(doc_label,'') = ''")
470 elif patch_no == 98:
471 import_from_files(record_list=[['accounts','doctype','payable_voucher']])
472 elif patch_no == 99:
473 import_from_files(record_list=[['accounts','doctype','account']])
474 elif patch_no == 100:
475 p = get_obj('Patch Util')
476 p.set_field_property('Account', 'level', 'hidden', '1')
477 p.set_field_property('Account', 'level', 'print_hide', '1')
478 p.set_field_property('Account', 'account_type', 'search_index', '0')
479 p.set_field_property('TDS Detail', 'tds_category', 'width', '150px')
480 p.set_field_property('TDS Detail', 'special_tds_rate_applicable', 'width', '150px')
481 p.set_field_property('TDS Detail', 'special_tds_rate', 'width', '150px')
482 p.set_field_property('TDS Detail', 'special_tds_limit', 'width', '150px')
483 elif patch_no == 101:
484 # Leave Application Details and Leave Allocation Details
485 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')")
486 get_obj('DocType','Leave Application').doc.save()
487 get_obj('DocType','Leave Allocation').doc.save()
488 elif patch_no == 102:
489 # make item description field editable in production order
490 sql("update tabDocField set permlevel = 0 where fieldname = 'description' and parent = 'Production Order'")
491 elif patch_no == 103:
492 sql("update tabDocField set fieldname = '' where fieldtype = 'HTML'")
493 elif patch_no == 104:
494
495 import_from_files(record_list=[['payroll','search_criteria','stdsrch_00001'],['payroll','search_criteria','stdsrch_00002'],['payroll','search_criteria','stdsrch_00003'],['payroll','Module Def','Payroll'],['payroll','doctype','leave_application'],['payroll','doctype','leave_allocation']])
496 elif patch_no == 105:
497 # Employee Leave Balance
498 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')")
499 # Update Search Fields
500 sql("update tabDocType set search_fields = 'employee,employee_name,leave_type,from_date,to_date,total_leave_days,fiscal_year' where name = 'Leave Application'")
501 sql("update tabDocType set search_fields = 'employee,employee_name,leave_type,total_leaves_allocated,fiscal_year' where name = 'Leave Allocation'")
502 elif patch_no == 106:
503 for d in sql("select name,employee,employee_name from `tabLeave Allocation`"):
504 if not cstr(d[2]):
505 sql("update `tabLeave Allocation` set employee_name = '%s' where name = '%s'" % (webnotes.conn.get_value('Employee',cstr(d[1]),'employee_name'), cstr(d[0])))
506 for d in sql("select name,employee,employee_name from `tabLeave Application`"):
507 if not cstr(d[2]):
508 sql("update `tabLeave Application` set employee_name = '%s' where name = '%s'" % (webnotes.conn.get_value('Employee',cstr(d[1]),'employee_name'), cstr(d[0])))
509 elif patch_no == 107:
510 sql("delete from `tabDocField` where fieldname = 'fiscal_year' and parent = 'Employee'")
511 elif patch_no == 108:
512 import_from_files(record_list=[['payroll','search_criteria','srch_std_00013']])
513 elif patch_no == 109:
514 import_from_files(record_list=[['payroll','search_criteria','srch_std_00015']])
515 elif patch_no == 110:
516 import_from_files(record_list=[['payroll','doctype','salary_structure'], ['payroll', 'doctype', 'salary_slip']])
517 elif patch_no == 111:
518 sql("update tabDocType set search_fields = 'transfer_date, from_warehouse, to_warehouse, purpose, remarks' where name = 'Stock Entry'")
519 elif patch_no == 112:
520 sql("delete from tabDocField where label = 'Get Other Charges' and fieldtype = 'Button' and parent = 'Receivable Voucher'")
521 elif patch_no == 113:
522 sql("update tabDocField set reqd = 1 where parent = 'Customer' and fieldname = 'phone_1'")
523 elif patch_no == 114:
524 for d in sql("select name, master_name, credit_days, credit_limit from tabAccount where master_type = 'Customer'"):
525 if cstr(d[1]):
526 days, limit = cint(d[2]), flt(d[3])
527 cust_det = sql("select credit_days, credit_limit from tabCustomer where name = '%s'" % (cstr(d[1])))
528 if not days: days = cust_det and cint(cust_det[0][0]) or 0
529 if not limit: limit = cust_det and flt(cust_det[0][1]) or 0
530 sql("COMMIT")
531 sql("START TRANSACTION")
532 sql("update tabAccount set credit_days = '%s', credit_limit = '%s' where name = '%s'" % (days, limit, cstr(d[0])))
533 sql("COMMIT")
534
535 elif patch_no == 115:
536 # patch for timesheet cleanup
537 from webnotes.model import delete_doc
538 delete_doc('DocType', 'Timesheet Detail')
539
540 from webnotes.modules.import_module import import_from_files
541 import_from_files(record_list = [['Projects', 'DocType', 'Timesheet'], ['Projects', 'DocType', 'Timesheet Detail'], ['Projects', 'DocType', 'Activity Type']])
542
543 elif patch_no == 116:
544 # again!
545 from webnotes.model import delete_doc
546 delete_doc('DocType', 'Timesheet Detail')
547
548 from webnotes.modules.import_module import import_from_files
549 import_from_files(record_list = [['Projects', 'DocType', 'Timesheet Detail']])
550 elif patch_no == 117:
551 op = '\n' + 'Walk In'
552 sql("update `tabDocField` set `options` = concat(options, %s) where parent = 'Enquiry' and fieldname = 'source' and options not like '%%Walk%%'", op)
553 elif patch_no == 118:
554 from webnotes.utils import get_defaults
555 ss = sql("select name, net_pay from `tabSalary Slip`")
556 for d in ss:
557 if d[1]:
558 w = get_obj('Sales Common').get_total_in_words(get_defaults()['currency'], d[1])
559 sql("update `tabSalary Slip` set net_pay_in_words = '%s' where name = '%s'" % (w, d[0]))
560 elif patch_no == 119:
561 sql("update tabDocType set in_create = 1 where name = 'Profile'")
562 elif patch_no == 120:
563 sql("update tabDocField set permlevel = 0 where parent = 'Sales and Purchase Return Wizard' and fieldname = 'return_date'")
564 elif patch_no == 121:
565 import_from_files(record_list = [['CRM', 'DocType', 'Return Detail'], ['Material Management', 'DocType', 'Sales and Purchase Return Wizard']])
566 elif patch_no == 122:
567 sql("delete from tabDocField where (fieldname = 'serial_no' or label = 'Warrany Status') and parent = 'Sales Order'")
568 elif patch_no == 123:
569 import_from_files(record_list = [['CRM', 'Module Def', 'CRM'], ['CRM', 'Search Criteria', 'STDSRCH/00004']])
570 elif patch_no == 124:
571 import webnotes
572 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!""")
573 webnotes.conn.set_global("system_message_id", "5")
574 elif patch_no == 125:
575 import_from_files(record_list = [['Material Management', 'DocType', 'Delivery Note']])
576 elif patch_no == 126:
577 sql("delete from tabDocField where parent = 'Delivery Note' and label in ('Make Sales Invoice', 'Make Installation Note', 'Intro Note')")
578 elif patch_no == 127:
579 sql("delete from tabDocPerm where role = 'All' and parent = 'Expense Voucher' and (permlevel = 0 or permlevel = 2)")
580 p = get_obj('Patch Util')
581 p.add_permission('Expense Voucher', 'Employee', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1, match = 'owner')
582 p.add_permission('Expense Voucher', 'HR Manager', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1)
583 p.add_permission('Expense Voucher', 'HR User', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1)
584 elif patch_no == 128:
585 from webnotes.modules import import_module
586 import_module.import_from_files(record_list=[['crm','doctype','sales_order'], ['crm','doctype','sales_order_detail'], ['material_management','doctype','delivery_note'], ['material_management','doctype','delivery_note_detail']])
587 elif patch_no == 129:
588 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'")
589 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'")
590 elif patch_no == 130:
591 # update from rv
592 from webnotes.model.code import get_obj
593 from webnotes.utils import cstr
594 for d in sql("select name, docstatus from `tabReceivable Voucher` where ifnull(docstatus,0) != 0"):
595 sql("COMMIT")
596 sql("START TRANSACTION")
597 try:
598 obj = get_obj('Receivable Voucher', cstr(d[0]), with_children = 1)
599 is_submit = 1
600 if cint(d[1]) == 2: is_submit = 0
601 get_obj('Sales Common').update_prevdoc_detail(is_submit, obj)
602 except:
603 pass
604 sql("COMMIT")
605
606 # update from dn
607 from webnotes.model.code import get_obj
608 for d in sql("select name, docstatus from `tabDelivery Note` where ifnull(docstatus,0) != 0"):
609 sql("COMMIT")
610 sql("START TRANSACTION")
611 try:
612 obj = get_obj('Delivery Note', cstr(d[0]), with_children = 1)
613 is_submit = 1
614 if cint(d[1]) == 2: is_submit = 0
615 get_obj('Sales Common').update_prevdoc_detail(is_submit, obj)
616 except:
617 pass
618 sql("COMMIT")
619 elif patch_no == 131:
620 sql("update `tabDocType` set allow_trash = 1 where name = 'Purchase Other Charges'")
621 sql("update tabDocPerm set `cancel` = 1 where parent = 'Purchase Other Charges' and permlevel = 0 and `read` = 1 and `write` = 1")
622 elif patch_no == 132:
623 sql("update tabDocField set no_copy = 0 where parent = 'Receivable Voucher' and fieldname = 'customer'")
624 elif patch_no == 133:
625 from webnotes.modules import import_module
626 import_module.import_from_files(record_list=[['accounts','doctype','receivable_voucher']])
627 elif patch_no == 134:
628 sql("update tabDocField set no_copy = 1 where parent = 'Receivable Voucher' and fieldname = 'posting_time'")
629 elif patch_no == 135:
630 sql("update tabDocField set `default` = 'Today' where parent = 'Receivable Voucher' and fieldname = 'due_date'")
631 elif patch_no == 136:
632 from webnotes.modules import import_module
633 import_module.import_from_files(record_list=[['accounts','doctype','rv_detail']])
634 elif patch_no == 137:
635 from webnotes.modules import import_module
636 import_module.import_from_files(record_list=[['setup','doctype','price_list']])
637 elif patch_no == 138:
638 sql("update `tabDocType` set allow_attach = 1 where name = 'Price List'")
639 elif patch_no == 139:
640 from webnotes.modules import import_module
641 import_module.import_from_files(record_list=[['mapper','DocType Mapper','Sales Order-Receivable Voucher'], ['mapper','DocType Mapper','Delivery Note-Receivable Voucher']])
642 elif patch_no == 140:
643 from webnotes.modules import import_module
644 import_module.import_from_files(record_list=[['accounts','doctype','rv_detail']])
645 elif patch_no == 141:
646 sql("delete from tabDocField where (fieldname = 'letter_head' or label = 'Letter Head') and parent = 'Company'")
647 elif patch_no == 142:
648 # fixes to letter head and personalize
649 from webnotes.model import delete_doc
650
651 delete_doc('DocType', 'Batch Settings')
652 delete_doc('DocType', 'Batch Settings Detail')
653 delete_doc('DocType', 'Social Badge')
654 delete_doc('Page', 'Personalize Page')
655 delete_doc('DocType', 'Personalize Page Control')
656
657 import_from_files(record_list=[['core','doctype','letter_head'], ['setup','doctype','personalize']])
658 elif patch_no == 144:
659 webnotes.conn.sql("update tabDocField set fieldtype='Code' where parent='Letter Head' and fieldname='content'")
660 elif patch_no == 145:
661 sql("update `tabDocField` set permlevel=1 where fieldname = 'group_or_ledger' and parent = 'Account'")
662 elif patch_no == 146:
663 import_from_files(record_list=[['accounts','doctype','account']])
664 elif patch_no == 147:
665 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']])
666 elif patch_no == 148:
667 sql("delete from `tabDocField` where (fieldname = 'account_balances' or label = 'Balances') and parent = 'Account'")
668 sql("update tabDocType set istable = 0, section_style = 'Simple', search_fields = 'account, period, fiscal_year, balance' where name = 'Account Balance'")
669 sql("update tabDocField set permlevel = 0 where parent = 'Account Balance'")
670 p = get_obj('Patch Util')
671 p.add_permission('Account Balance', 'Accounts User', 0, read = 1)
672 p.add_permission('Account Balance', 'Accounts Manager', 0, read = 1)
673 import_from_files(record_list=[['accounts','doctype','account_balance']])
674 elif patch_no == 149:
675 sql("update `tabAccount Balance` set account = parent")
676 elif patch_no == 150:
677 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')")
678 ac_bal = Document("DocType", "Account Balance")
679 ac_bal.save()
680 elif patch_no == 151:
681 sql("delete from tabDocField where label = 'Add / Manage Contacts' and fieldtype = 'Button' and parent = 'Customer'")
682 sql("delete from `tabField Mapper Detail` where parent = 'Sales Order-Delivery Note' and from_field = 'note' and to_field = 'note'")
683 elif patch_no == 152:
684 import_from_files(record_list=[['crm','doctype','sales_order'], ['material_management','doctype','delivery_note'], ['crm','doctype','customer'], ['crm','doctype','shipping_address'], ['mapper', 'DocType Mapper', 'Sales Order-Delivery Note']])
685 elif patch_no == 153:
686 sql("delete from `tabDocField` where fieldname = 'sales_person' and parent = 'Customer'")
687 elif patch_no == 154:
688 import_from_files(record_list=[['material_management','doctype','serial_no'], ['maintenance','doctype','customer_issue']])
689 elif patch_no == 155:
690 for d in sql("select name, item_code from `tabSerial No`"):
691 sql("COMMIT")
692 sql("START TRANSACTION")
693 sql("update `tabSerial No` set item_name = '%s' where name = '%s'" % (webnotes.conn.get_value('Item',cstr(d[1]),'item_name'), cstr(d[0])))
694 sql("COMMIT")
695 elif patch_no == 156:
696 sql("update tabDocField set fieldtype = 'Code' where fieldname = 'html' and parent = 'Print Format'")
697 elif patch_no == 157:
698 import_from_files(record_list=[['accounts', 'doctype', 'journal_voucher'], ['accounts', 'Print Format', 'Payment Receipt Voucher'], ['accounts', 'Print Format', 'Cheque Printing Format']])
699 elif patch_no == 158:
700 from webnotes.model.doc import addchild
701 sql("delete from tabDocField where parent = 'Customer Issue' and fieldname = 'customer_group'")
702 elif patch_no == 159:
703 sql("update tabAccount set account_type = 'Chargeable' where account_name in ('Advertising and Publicity', 'Freight & Forwarding Charges', 'Miscellaneous Expenses', 'Sales Promotion Expenses')")
704 elif patch_no == 160:
705 sql("update `tabDocType` set search_fields = 'posting_date, due_date, debit_to, fiscal_year, grand_total, outstanding_amount' where name = 'Receivable Voucher'")
706 sql("update `tabDocType` set search_fields = 'posting_date, credit_to, fiscal_year, bill_no, grand_total, outstanding_amount' where name = 'Payable Voucher'")
707 elif patch_no == 161:
708 sql("update tabDocType set autoname = 'field:batch_id' where name = 'Batch'")
709 sql("update tabDocField set no_copy = 1 where parent = 'Batch' and fieldname = 'batch_id'")
710 elif patch_no == 162:
711 import_from_files(record_list=[['crm', 'search_criteria', 'sales_order_pending_items1']])
712 elif patch_no == 163:
713 sql("delete from `tabModule Def Item` where display_name = 'Sales Orderwise Pending Packing Item Summary' and parent = 'CRM'")
714 import_from_files(record_list=[['crm', 'search_criteria', 'sales_orderwise_pending_qty_to_deliver'], ['crm', 'search_criteria', 'sales_orderwise_pending_amount_to_bill'], ['crm', 'search_criteria', 'delivered_items_to_be_install']])
715 elif patch_no == 164:
716 import_from_files(record_list=[['srm', 'search_criteria', 'pending_po_items_to_receive'], ['srm', 'search_criteria', 'pending_po_items_to_bill']])
717 elif patch_no == 165:
718 pass
719 elif patch_no == 166:
720 import_from_files(record_list=[['srm', 'doctype', 'purchase_order']])
721 elif patch_no == 167:
722 if webnotes.conn.get_value('Control Panel', None, 'account_id') not in ['ax0000956', 'ax0001338']:
723 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')")
724 elif patch_no == 168:
725 sql("update tabDocField set fieldtype = 'Data', options = 'Suggest' where fieldname = 'bank_name' and parent = 'Employee'")
726 elif patch_no == 169:
727 import_from_files(record_list=[['accounts', 'doctype', 'pv_detail'], ['accounts', 'doctype', 'rv_detail']])
728 elif patch_no == 170:
729 import_from_files(record_list=[['mapper', 'DocType Mapper', 'Delivery Note-Receivable Voucher']])
730 elif patch_no == 171:
731 import_from_files(record_list=[['srm', 'doctype', 'supplier']])
732 elif patch_no == 172:
733 import webnotes
734 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>""")
735 webnotes.conn.set_global("system_message_id", "6")
736 elif patch_no == 173:
737 sql("delete from tabDocField where label = 'Get Other Charges' and parent = 'Delivery Note'")
738 sql("update tabDocField set reqd = 0 where fieldname = 'posting_time' and parent = 'Serial No'")
739 elif patch_no == 174:
740 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")
741 if c and cint(c[0][0]) > 1:
742 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")
743 elif patch_no == 175:
744 import webnotes
745 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>""")
746 webnotes.conn.set_global("system_message_id", "6")
747 elif patch_no == 176:
748 sql("update tabDocPerm set role='Guest', `write`=0, `create`=0 where role='Administrator' and parent='Notification Control' limit 1")
749 elif patch_no == 177:
750 sql("delete from `tabDocField` where label = 'Next Steps' and parent = 'Purchase Order'")
751 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'")
752 elif patch_no == 178:
753 import_from_files(record_list = [['payroll', 'doctype', 'salary_slip']])
754 elif patch_no == 179:
755 from webnotes.utils import get_defaults
756 sl = sql("select name, net_pay from `tabSalary Slip`")
757 for d in sl:
758 in_words = get_obj('Sales Common').get_total_in_words(get_defaults()['currency'], round(flt(d[1])))
759 sql("update `tabSalary Slip` set rounded_total = '%s', total_in_words = '%s' where name = '%s'" % (round(flt(d[1])), in_words, d[0]))
760 elif patch_no == 180:
761 sql("delete from tabDocField where parent = 'Salary Slip' and fieldname = 'net_pay_in_words'")
762 elif patch_no == 181:
763 import_from_files(record_list = [['accounts', 'doctype', 'journal_voucher']])
764 elif patch_no == 182:
765 sql("update tabDocField set options = CONCAT(options, '\nWrite Off Voucher') where fieldname = 'voucher_type' and parent = 'Journal Voucher'")
766 elif patch_no == 183:
767 sql("delete from tabDocField where label = 'SMS' and fieldtype = 'Section Break' and parent in ('Enquiry', 'Lead', 'Sales Order', 'Delivery Note')")
768 elif patch_no == 184:
769 from webnotes.model import delete_doc
770 delete_doc('DocType', 'Feed')
771 delete_doc('DocType', 'Feed List')
772 delete_doc('DocType', 'Feed Control')
773
774 # add trigger
775 from webnotes.model.triggers import add_trigger
776 add_trigger('*','*','*','event_updates.update_feed')
777
778 webnotes.conn.commit()
779
780 try:
781 sql("drop table tabFeed")
782 sql("drop table `tabFeed List`")
783 except: pass
784
785 # import
786 from webnotes.modules.module_manager import reload_doc
787 reload_doc('event_updates','doctype','feed')
788 elif patch_no==185:
789 sql("delete from tabDocTrigger where method = 'webnotes.widgets.follow.on_docsave'")
790 elif patch_no==186:
791 from webnotes.modules.module_manager import reload_doc
792 reload_doc('event_updates','doctype','feed')
793 elif patch_no == 187:
794 sql("update tabDocType set autoname = '' where name = 'QA Inspection Report'")
795 elif patch_no == 188:
796 import_from_files(record_list = [['srm', 'doctype', 'qa_inspection_report']])
797 elif patch_no == 189:
798 sql("update `tabDocField` set allow_on_submit = 1 where fieldname in ('entries', 'other_charges') and parent = 'Receivable Voucher'")
799 elif patch_no == 190:
800 sql("update tabDocField set permlevel=0 where fieldname = 'fiscal_year' and parent = 'Stock Entry'")
801 elif patch_no == 191:
802 import_from_files(record_list = [['maintenance', 'doctype', 'customer_issue']])
803 elif patch_no == 192:
804 sql("delete from `tabModule Def Item` where parent = 'Material Management' and doc_name = 'Landed Cost Wizard' and display_name = 'Landed Cost Wizard'")
805 import_from_files(record_list = [['srm', 'Module Def', 'SRM']])
806 elif patch_no == 193:
807 sql("update tabDocField set fieldtype='Button', `trigger`='Client' where parent='Letter Head' and fieldname='set_from_image'")
808 elif patch_no == 194:
809 sql("delete from `tabModule Def Item` where parent = 'SRM' and doc_name = 'Landed Cost Wizard' and display_name = 'Landed Cost Wizard'")
810 import_from_files(record_list = [['material_management', 'Module Def', 'Material Management']])
811 elif patch_no == 195:
812 from webnotes.modules.module_manager import reload_doc
813 reload_doc('setup','doctype','manage_account')
814 elif patch_no == 196:
815 sql("update `tabModule Def` set module_page = null where name = 'Material Management'")
816 elif patch_no == 197:
817 sql("update `tabDocField` set permlevel = 0, in_filter = 1 where fieldname = 'warranty_amc_status' and parent = 'Customer Issue'")
818 import_from_files(record_list = [['maintenance', 'doctype', 'customer_issue']])
819 elif patch_no == 198:
820 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')")
821 sql("delete from `tabDocField` where label in ('SMS', 'Send SMS') and parent = 'Purchase Order'")
822 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')")
823 from webnotes.model import delete_doc
824 delete_doc('DocType', 'Lead SMS Detail')
825 delete_doc('DocType', 'Enquiry SMS Detail')
826 elif patch_no == 199:
827 sql("update tabDocField set reqd = 0 where parent = 'Attendance' and fieldname = 'shifts'")
828 elif patch_no == 200:
829 reload_doc('event_updates','page','profile_settings')
830 elif patch_no == 201:
831 reload_doc('setup','doctype','price_list')
832 elif patch_no == 202:
833 name1 = sql("select name from tabDocField where parent='Price List' and label='Clear Prices' limit 1,1")
834 name2 = sql("select name from tabDocField where parent='Price List' and label='Update Prices' limit 1,1")
835 if name1:
836 sql("delete from tabDocField where name=%s limit 1", name1[0][0])
837 if name2:
838 sql("delete from tabDocField where name=%s limit 1", name2[0][0])
839 elif patch_no == 203:
840 sql("delete from tabDocField where parent = 'Company' and fieldname = 'default_salary_account' limit 1")
841 elif patch_no == 204:
842 sql("delete from tabDocField where parent = 'Company' and fieldname = 'default_salary_acount' limit 1")
843 elif patch_no == 205:
844 sql("update `tabDocField` set `default` = '' where fieldname = 'naming_series' and parent = 'Installation Note'")
845 elif patch_no == 206:
846 reload_doc('crm','doctype','installation_note')
847 elif patch_no == 207:
848 import_from_files(record_list = [['setup', 'doctype', 'company']])
849 elif patch_no == 208:
850 sql("delete from `tabDocField` where (label in ('SMS', 'Send SMS') or fieldname in ('message', 'customer_mobile_no')) and parent ='Quotation'")
851 default_currency = get_obj('Manage Account').doc.default_currency
852 sql("update tabCompany set default_currency = '%s'" % default_currency)
853 elif patch_no == 209:
854 import_from_files(record_list = [['setup', 'doctype', 'company']])
855 elif patch_no == 210:
856 sql("delete FROM `tabDocField` WHERE parent = 'Lead' AND label in ('CC:','Attachment Html','Create New File','Attachment')")
857 elif patch_no == 212:
858 # reload company because of disturbed UI
859 import_from_files(record_list = [['setup', 'doctype', 'company']])
860 elif patch_no == 213:
861 reload_doc('crm','doctype','lead')
862 reload_doc('setup','doctype','company')
863 elif patch_no == 214:
864 reload_doc('crm','doctype','sales_order')
865 elif patch_no == 215:
866 # patch for item and image in description
867 sql("update tabDocField set width = '300px' where fieldname='description'")
868 reload_doc('material_management', 'doctype', 'item')
869 sql("delete from __DocTypeCache")
870 elif patch_no == 216:
871 import_from_files(record_list = [['material_management', 'doctype', 'serial_no'], ['material_management', 'doctype', 'stock_ledger_entry']])
872 elif patch_no == 217:
873 sql("update tabDocField set options = '\nIn Store\nDelivered\nNot in Use' where fieldname = 'status' and parent = 'Serial No'")
874 sql("update tabDocField set no_copy = 1 where fieldname = 'serial_no' and parent = 'Delivery Note Detail'")
875 sql("update tabDocField set no_copy = 1 where fieldname = 'serial_no' and parent = 'Stock Entry Detail'")
876 elif patch_no == 218:
877 for d in sql("select name from `tabSerial No`"):
878 sql("Commit")
879 sql("Start Transaction")
880 s = Document('Serial No', d[0])
881 if s.pr_no:
882 s.purchase_document_type = 'Purchase Receipt'
883 s.purchase_document_no = s.pr_no
884 if s.delivery_note_no:
885 s.delivery_document_type = 'Delivery Note'
886 s.delivery_document_no = s.delivery_note_no
887 if s.notes:
888 s.delivery_note_no = s.notes
889 s.company = webnotes.utils.get_defaults()['company']
890 s.fiscal_year = webnotes.utils.get_defaults()['fiscal_year']
891 s.save()
892 elif patch_no == 219:
893 sql("delete from tabDocField where fieldname in ('pr_no', 'make', 'label', 'delivery_note_no', 'notes') and parent = 'Serial No'")
894 elif patch_no == 220:
895 sql("update tabDocField set label = 'Incoming Rate' where fieldname = 'purchase_rate' and parent = 'Serial No'")
896 sql("update tabDocField set label = 'Incoming Time' where fieldname = 'purchase_time' and parent = 'Serial No'")
897 elif patch_no == 221:
898 sql("update tabDocField set reqd = 1 where fieldname in ('purchase_rate', 'warehouse') and parent = 'Serial No'")
899 elif patch_no == 222:
900 sql("update tabDocField set options = '\nDelivery Note\nReceivable Voucher\nStock Entry' where fieldname = 'delivery_document_type' and parent = 'Serial No'")
901 elif patch_no == 223:
902 sql("update tabDocField set hidden = 0 where fieldname in ('pay_to_recd_from', 'total_amount', 'total_amount_in_words') and parent = 'Journal Voucher'")
903 sql("update tabDocField set permlevel = 0 where fieldname = 'pay_to_recd_from' and parent = 'Journal Voucher'")
904 elif patch_no == 224:
905 import_from_files(record_list = [['material_management', 'doctype', 'delivery_note_packing_detail'], ['accounts', 'Print Format', 'Payment Receipt Voucher']])
906 elif patch_no == 225:
907 import_from_files(record_list = [['material_management', 'doctype', 'delivery_note_packing_detail']])
908 elif patch_no == 226:
909 import_from_files(record_list = [['material_management', 'doctype', 'delivery_note_packing_detail']])
910 elif patch_no == 227:
911 reload_doc('material_management', 'doctype', 'item')
912 if webnotes.conn.get_value('Control Panel', None, 'account_id') != 'axjanak2011':
913 sql("delete from tabDocField where parent = 'Item' and fieldname='alternate_description' limit 1")
914 elif patch_no == 228:
915 # knowledge base patch
916 reload_doc('knowledge_base', 'doctype', 'question')
917 reload_doc('knowledge_base', 'doctype', 'answer')
918 reload_doc('knowledge_base', 'page', 'questions')
919 reload_doc('knowledge_base', 'Module Def', 'Knowledge Base')
920 sql("update `tabModule Def` set disabled='No' where name='Knowledge Base'")
921 elif patch_no == 229:
922 reload_doc('knowledge_base', 'page', 'question_view')
923 elif patch_no == 230:
924 reload_doc('srm', 'doctype', 'indent')
925 reload_doc('srm', 'doctype', 'indent_detail')
926 reload_doc('Mapper', 'DocType Mapper', 'Sales Order-Indent')
927 elif patch_no == 231:
928 reload_doc('Mapper', 'DocType Mapper', 'Sales Order-Indent')
929 elif patch_no == 232:
930 sql("update `tabDocField` set options = 'Sales Order' where fieldname = 'sales_order_no' and parent = 'Indent'")
931 elif patch_no == 233:
932 reload_doc('Mapper', 'DocType Mapper', 'Sales Order-Receivable Voucher')
933 reload_doc('Mapper', 'DocType Mapper', 'Delivery Note-Receivable Voucher')
934 elif patch_no == 234:
935 sql("update `tabTable Mapper Detail` set validation_logic = 'docstatus=1' where parent = 'Sales Order-Indent' and from_table = 'Sales Order Detail'")
936 elif patch_no == 235:
937 for sc in sql("""select name from `tabSearch Criteria` where ifnull(name,'')
938 like 'srch%' or ifnull(name,'') like '%stdsrch'"""):
939 try:
940 get_obj('Search Criteria', sc[0]).rename()
941 except AttributeError, e:
942 pass
943 reload_doc('core', 'doctype', 'system_console')
944 elif patch_no == 236:
945 # warehouse not mandatory for delivered serial nos
946 sql("update tabDocField set reqd=0 where parent='Serial No' and fieldname='warehouse'")
947 elif patch_no == 237:
948 sql("update tabDocField set depends_on = 'eval:doc.is_pos==1' where fieldname = 'cash_bank_account' and parent = 'Receivable Voucher'")
949 elif patch_no == 238:
950 reload_doc('accounts', 'doctype', 'receivable_voucher')
951 reload_doc('accounts', 'GL Mapper', 'POS with write off')
952 elif patch_no == 239:
953 reload_doc('core', 'doctype', 'docfield')
954 reload_doc('core', 'doctype', 'doctype')
955
956 from patches.feed_patch import set_subjects_and_tagfields
957 set_subjects_and_tagfields()
958 elif patch_no == 240:
959 # again for sales order (status)
960 from patches.feed_patch import set_subjects_and_tagfields
961 set_subjects_and_tagfields()
962 elif patch_no == 241:
963 sql("update `tabDocField` set fieldtype = 'Text', options = '', in_filter = '' where fieldname = 'serial_no' and parent = 'Stock Ledger Entry'")
964 elif patch_no == 242:
965 if webnotes.conn.get_value('Control Panel', None, 'account_id') not in ['axjanak2011']:
966 sql("commit")
967 try:
968 sql("alter table `tabStock Ledger Entry` drop index serial_no")
969 except:
970 pass
971
972 sql("alter table `tabStock Ledger Entry` change serial_no serial_no text")
973 elif patch_no == 243:
974 # moving custom script and custom fields to framework
975 webnotes.conn.set_value('DocType', 'Custom Script', 'module', 'Core')
976 webnotes.conn.set_value('DocType', 'Custom Field', 'module', 'Core')
977 reload_doc('setup', 'doctype', 'company')
978 elif patch_no == 244:
979 reload_doc('material_management', 'search_criteria', 'shortage_to_indent')
980 elif patch_no == 245:
981 from patches.doctype_permission_patch import set_doctype_permissions
982 set_doctype_permissions()
983
984 from patches.feed_patch import set_subjects_and_tagfields
985 set_subjects_and_tagfields()
986 elif patch_no == 246:
987 webnotes.conn.set_value('DocType','Stock Entry','tag_fields','purpose')
988 webnotes.conn.set_value('DocType','Stock Entry','subject','%(remarks)s')
989 elif patch_no == 247:
990 webnotes.conn.set_value('DocType','Stock Entry','subject','%(remarks)s')
991 elif patch_no == 248:
992 reload_doc('setup', 'doctype', 'manage_account')
993 elif patch_no == 249:
994 sql("update `tabDocPerm` t1, `tabDocType` t2 set t1.role = 'System Manager' where t1.role = 'Administrator' and t1.parent = t2.name and t2.module != 'Core'")
995 elif patch_no == 250:
996 from patches.feed_patch import support_patch
997 support_patch()
998 elif patch_no == 251:
999 from webnotes.model import db_schema
1000 db_schema.remove_all_foreign_keys()
1001 from patches.customer_address import run_patch
1002 run_patch()
1003 elif patch_no == 252:
1004 reload_doc('maintenance','doctype','support_ticket')
1005 reload_doc('maintenance','doctype','support_ticket_response')
1006 elif patch_no == 253:
1007 reload_doc('accounts','doctype','ledger_balance_export')
1008 reload_doc('accounts','doctype','ledger_detail')
1009 reload_doc('accounts', 'Module Def', 'Accounts')
1010
1011 from webnotes.model.db_schema import updatedb
1012 updatedb('Ledger Balance Export')
1013 updatedb('Ledger Detail')
1014 elif patch_no == 254:
1015 reload_doc('settings', 'doctype', 'sms_settings')
1016 reload_doc('settings', 'doctype', 'static_parameter_detail')
1017
1018 from webnotes.model.db_schema import updatedb
1019 updatedb('SMS Settings')
1020 updatedb('Static Parameter Detail')
1021 elif patch_no == 255:
1022 from patches.customer_address import run_old_data_sync_patch
1023 run_old_data_sync_patch()
1024 elif patch_no == 256:
1025 sql("update `tabLetter Head` set content = replace(content, 'http://46.4.50.84/v170-test/', '')")
1026 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'")
1027 sql("update `tabItem` set description_html = replace(description_html, 'http://46.4.50.84/v170-test/', '')")
1028 elif patch_no == 257:
1029 from patches.customer_address import run_old_data_sync_patch
1030 run_old_data_sync_patch()
1031 elif patch_no == 258:
1032 sql("update tabDocField set `default`=NULL where fieldname = 'naming_series'")
1033 elif patch_no == 259:
1034 sql("update `tabQuotation Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1035 sql("update `tabSales Order Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1036 sql("update `tabRV Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1037 sql("update `tabDelivery Note Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1038 elif patch_no == 260:
1039 sql("update `tabLetter Head` set content = replace(content, 'http://46.4.50.84/v170/', '')")
1040 sql("update `tabSingles` set value = replace(value, 'http://46.4.50.84/v170/', '') where field in ('letter_head', 'client_name') and doctype = 'Control Panel'")
1041 sql("update `tabItem` set description_html = replace(description_html, 'http://46.4.50.84/v170/', '')")
1042 sql("update `tabQuotation Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1043 sql("update `tabSales Order Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1044 sql("update `tabRV Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1045 sql("update `tabDelivery Note Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1046 elif patch_no == 261:
1047 sql("update `tabPrint Format` set html = replace(html, 'customer_address', 'address_display')")
1048 elif patch_no == 262:
1049 from patches.customer_address import sync_lead_phone
1050 sync_lead_phone()
1051 elif patch_no == 263:
1052 ol = ['','Open','To Reply','Waiting for Customer','Hold','Closed']
1053 sql("update tabDocField set options=%s where parent=%s and fieldname=%s", ('\n'.join(ol), 'Support Ticket', 'status'))
1054 elif patch_no == 264:
1055 sql("delete from tabDocField where parent = 'Customer Issue' and (fieldname = 'issue_in' or fieldname = 'issue_category')")
1056 sql("update tabDocField set options=NULL where parent='Support Ticket' and label = 'Send'")
1057 elif patch_no == 266:
1058 reload_doc('setup','doctype','support_email_settings')
1059 elif patch_no == 267:
1060 sql("update `tabPrint Format` set html = replace(html, 'supplier_address', 'address_display')")
1061 elif patch_no == 268:
1062 sql("update `tabDocPerm` set permlevel = 0 where permlevel is null")
1063 elif patch_no == 269:
1064 p = get_obj('Patch Util')
1065 p.add_permission('GL Entry', 'Accounts User', 0, read = 1)
1066 elif patch_no == 270:
1067 pages = ['Accounts Setup', 'Accounts', 'Accounting Reports','GeneralLedger','How do I - Accounts','Making Opening Entries',\
1068 'Analysis','How do I - CRM','How do I - Inventory','Inventory Setup', 'Stock','HR','HR & Payroll Setup',\
1069 'Payroll Setup','Production Setup','Production','Buying','SRM Setup','Contact Page','Forum','Messages','Test Toolbar',\
1070 'Trend Analyzer']
1071 from webnotes.model import delete_doc
1072 sql("delete from `tabPage Visit`")
1073 for p in pages:
1074 try: delete_doc('Page', p)
1075 except: pass
1076 elif patch_no == 271:
1077 # tags patch
1078 reload_doc('crm','doctype','sales_order')
1079 reload_doc('material_management','doctype','delivery_note')
1080 sql("delete from tabDocField where fieldname='per_amt_billed' and parent in ('Sales Order', 'Delivery Note')")
1081
1082 sql("""update `tabSales Order` set delivery_status = if(ifnull(per_delivered,0) < 0.001, 'Not Delivered',
1083 if(per_delivered >= 99.99, 'Fully Delivered', 'Partly Delivered'))""")
1084 sql("""update `tabSales Order` set billing_status = if(ifnull(per_billed,0) < 0.001, 'Not Billed',
1085 if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""")
1086 sql("""update `tabDelivery Note` set billing_status = if(ifnull(per_billed,0) < 0.001, 'Not Billed',
1087 if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""")
1088 elif patch_no == 272:
1089 from webnotes.model import delete_doc
1090 try:
1091 delete_doc('Search Criteria', '_SRCH00003')
1092 except:
1093 pass
1094 reload_doc('accounts', 'search_criteria', 'purchase_register')
1095 elif patch_no == 276:
1096 from webnotes.model import delete_doc
1097 sn = sql("select name from `tabSearch Criteria` where criteria_name = 'Sales Personwise Transaction Summary'")
1098 for d in sn:
1099 delete_doc('Search Criteria', d[0])
1100 reload_doc('crm', 'search_criteria', 'sales_personwise_transaction_summary')
nabinhaite0250fb2011-06-14 13:35:31 +05301101 elif patch_no == 277:
1102 webnotes.model.delete_doc('DocType','HomePage Settings')
1103 webnotes.model.delete_doc('DocType','Badge Settings')
1104 sql("update tabDocType set module='Home' where module in ('Event Updates', 'My Company')")
1105 sql("update tabPage set module='Home' where module in ('Event Updates', 'My Company')")
1106 sql("update `tabSearch Criteria` set module='Home' where module in ('Event Updates', 'My Company')")
1107
1108
1109 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')
1110 for p in delete_pages:
1111 webnotes.model.delete_doc('Page',p)
nabinhaitb7789a52011-06-14 17:33:12 +05301112 elif patch_no == 278:
1113 sql("update tabDocTrigger set method = 'home.update_feed' where method = 'event_updates.update_feed'")
nabinhaitc43ece72011-06-15 11:55:32 +05301114 elif patch_no == 279:
1115 dt = ['GL Entry', 'Stock Ledger Entry']
1116 for t in dt:
1117 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)
1118 for d in rec:
1119 sql("update `tab%s` set docstatus = %s where name = '%s'" % (d[0], d[2]=='No' and 1 or 2, d[1]))
1120
1121 other_dt = ['Enquiry', 'Quotation', 'Sales Order', 'Indent', 'Purchase Order', 'Production Order', 'Customer Issue', 'Installation Note']
1122 for dt in other_dt:
1123 rec = sql("select name, status from `tab%s` where modified >= '2011-06-15 01:00:00'" % dt)
1124 for r in rec:
1125 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]))
nabinhait75e67cf2011-06-15 13:13:27 +05301126 elif patch_no == 280:
1127 reload_doc('accounts', 'doctype', 'form_16a')
nabinhaite7221212011-06-15 14:39:31 +05301128 elif patch_no == 281:
1129 dt_list = ['Delivery Note', 'Purchase Receipt']
1130 for dt in dt_list:
nabinhaite7221212011-06-15 14:39:31 +05301131 sql("update `tab%s` set status = 'Submitted' where docstatus = 1 and modified >='2011-06-15 01:00:00'" % dt)
1132 sql("update `tab%s` set status = 'Cancelled' where docstatus = 2 and modified >='2011-06-15 01:00:00'" % dt)
nabinhait5f4ea812011-06-15 15:17:57 +05301133 elif patch_no == 282:
1134 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']
1135 for d in dt_list:
1136 tbl = sql("select options from `tabDocField` where fieldtype = 'Table' and parent = '%s'" % d)
1137 for t in tbl:
1138 sql("update `tab%s` t1, `tab%s` t2 set t1.docstatus = t2.docstatus where t1.parent = t2.name" % (t[0], d))
nabinhait746d29b2011-06-16 12:41:39 +05301139 elif patch_no == 283:
1140 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")
1141 for d in rec:
1142 sql("update `tab%s` set docstatus = %s where name = '%s'" % (d[0], d[2]=='No' and 1 or 2, d[1]))
nabinhaitf7d80002011-06-20 13:51:26 +05301143 elif patch_no == 284:
1144 reload_doc('maintenance', 'doctype', 'support_ticket')
1145 sql("update `tabDocField` set in_filter = 1 where fieldname in ('raised_by', 'subject') and parent = 'Support Ticket'")
nabinhait6150e652011-06-20 16:34:48 +05301146 elif patch_no == 286:
nabinhait4b59bea2011-06-20 14:07:04 +05301147 reload_doc('accounts', 'search_criteria', 'itemwise_sales_register')
1148 reload_doc('accounts', 'search_criteria', 'itemwise_purchase_register')
nabinhait58f01022011-06-21 15:05:43 +05301149 elif patch_no == 287:
nabinhait8b849fe2011-06-21 15:09:55 +05301150 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')")
nabinhait5559ed92011-06-21 17:04:22 +05301151 elif patch_no == 288:
1152 reload_doc('accounts', 'doctype', 'payable_voucher')
nabinhait33dee782011-06-21 17:17:39 +05301153 elif patch_no == 289:
1154 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'")
1155 sql("update `tabDocType` set search_fields = 'status,transaction_date,customer,lead,order_type' where name = 'Quotation'")
Anand Doshib9f7e392011-06-22 12:11:47 +05301156 elif patch_no == 290:
Anand Doshif14abfb2011-06-22 12:24:40 +05301157 count = sql("""SELECT * FROM `tabModule Def`
Anand Doshib9f7e392011-06-22 12:11:47 +05301158 WHERE `module_name` LIKE 'Home'""")
1159 if not count:
1160 md = Document('Module Def')
1161 md.module_name = 'Home'
1162 md.module_label = 'Home'
Rushabh Mehta64b6c2c2011-06-22 16:38:11 +05301163 md.save(1)
1164 elif patch_no == 291:
nabinhaitaeee6ba2011-06-22 18:25:29 +05301165 reload_doc('tools','doctype','rename_tool')
1166 elif patch_no == 292:
1167 reload_doc('accounts', 'search_criteria', 'trial_balance')
Ravi Dey560ee3d2011-06-23 13:03:24 +05301168 elif patch_no == 293:
1169 sql("delete from tabDocField where parent='Account' and fieldname='address'")
1170 reload_doc('accounts', 'doctype', 'account')
Rushabh Mehta3e037432011-06-23 22:47:04 +05301171 elif patch_no == 294:
1172 # new account profile fix
1173 ul = sql("select name from tabProfile where ifnull(name,'') not in ('Administrator', 'Guest', '')")
1174 # if one user and one user has no roles
1175 if len(ul)==1 and not sql("select parent from tabUserRole where role='System Manager' and parent=%s", ul[0][0]):
1176 get_obj('Setup Control').add_roles(Document('Profile', ul[0][0]))
Ravi Dey0b6c5652011-06-24 14:44:21 +05301177 elif patch_no == 295:
1178 sql("update `tabDocField` set options = 'Delivered\nNot Delivered\nPartly Delivered\nClosed\nNot Applicable' where parent = 'Sales Order' and fieldname = 'delivery_status'")
1179 sql("update `tabDocField` set options = 'Billed\nNot Billed\nPartly Billed\nClosed' where parent = 'Sales Order' and fieldname = 'billing_status'")
Ravi Dey71771332011-06-24 16:15:37 +05301180 elif patch_no == 296:
Ravi Dey26c160f2011-06-24 15:53:51 +05301181 sql("delete from tabDocField where parent='Support Ticket' and fieldname='contact_no'")
1182 reload_doc('maintenance', 'doctype', 'support_ticket')
Ravi Dey74c9c4d2011-06-27 11:26:39 +05301183 elif patch_no == 297:
1184 reload_doc('payroll', 'doctype', 'employee')
1185 reload_doc('payroll', 'doctype', 'attendance')
1186 reload_doc('payroll', 'doctype', 'expense_voucher')
1187 reload_doc('payroll', 'doctype', 'appraisal')
1188 reload_doc('payroll', 'doctype', 'salary_structure')
1189 reload_doc('payroll', 'doctype', 'salary_slip')
Ravi Dey48671df2011-06-27 12:03:36 +05301190 elif patch_no == 298:
Ravi Dey94a332a2011-07-01 13:50:34 +05301191 sql("update `tabDocField` set options = 'link:Company' where parent = 'Attendance' and fieldname = 'company'")
1192 sql("update `tabDocField` set options = 'link:Company' where parent = 'Expense Voucher' and fieldname = 'company'")
1193 sql("update `tabDocField` set options = 'link:Company' where parent = 'Appraisal' and fieldname = 'company'")
Ravi Dey8d3f4b62011-06-27 12:48:56 +05301194 elif patch_no == 299:
1195 sql("update `tabDocPerm` set `match` = NULL where parent = 'Employee' and role = 'Employee'")
nabinhait690c6972011-06-28 14:42:07 +05301196 elif patch_no == 300:
Anand Doshib74eec82011-06-28 13:42:08 +05301197 sql("""DELETE FROM `tabSearch Criteria` WHERE name IN
1198 ('sales_register1', 'sales_register2', 'purchase_register1')""")
nabinhait78f5bf62011-06-28 16:21:58 +05301199 elif patch_no == 301:
nabinhait690c6972011-06-28 14:42:07 +05301200 from patches.delivery_billing_status_patch import run_patch
1201 run_patch()
nabinhaitb3930002011-06-28 16:50:38 +05301202 elif patch_no == 302:
1203 sql("update `tabDocField` set no_copy = 1 where fieldname = 'naming_series'")
Ravi Dey4c651192011-06-28 19:36:18 +05301204 elif patch_no == 303:
Ravi Dey27c5b402011-06-29 18:05:18 +05301205 pass
1206 elif patch_no == 304:
Rushabh Mehtac71eeb62011-06-30 08:28:36 +05301207 sql("delete from `tabDocField` where parent = 'company' and label = 'Trash Company' and fieldtype = 'button'")
Ravi Deyc674e432011-06-29 18:15:12 +05301208 reload_doc('setup', 'doctype', 'company')
Ravi Dey79c28652011-06-29 18:55:19 +05301209 elif patch_no == 305:
1210 sql("update `tabDocField` set options = 'link:Company' where options='link:Company' and fieldname='company' and fieldtype='Select'")
nabinhaitec097972011-07-01 13:34:41 +05301211 elif patch_no == 306:
Ravi Dey94a332a2011-07-01 13:50:34 +05301212 sql("update `tabDocField` set options = '\nAccount\nCompany\nCustomer\nSupplier\nEmployee\nWarehouse\nItem' where parent = 'Rename Tool' and fieldname = 'select_doctype'")
1213 sql("update `tabDocField` set options = 'link:Item' where parent = 'Raw Materials Supplied' and fieldname = 'po_item'")
1214 sql("update `tabDocField` set options = 'Sales Order' where parent = 'Indent Detail' and fieldname = 'sales_order_no'")
1215 sql("update `tabDocField` set options = 'link:Company', fieldtype = 'Select' where parent = 'Stock Ledger Entry' and fieldname = 'company'")
Ravi Dey627d01b2011-07-01 14:05:43 +05301216 reload_doc('tools', 'doctype', 'rename_tool')
1217 elif patch_no == 307:
1218 sql("delete from `tabDocField` where parent = 'company' and label = 'Trash Company' and fieldtype = 'Button'")
1219 reload_doc('setup', 'doctype', 'company')
nabinhaita56fc002011-07-01 16:32:03 +05301220 elif patch_no == 308:
Ravi Deyc1886b52011-07-04 16:53:42 +05301221 sql("update `tabDocField` set reqd = 0 where fieldname = 'select_item' and parent = 'Property Setter'")
nabinhait1bd56b12011-07-05 14:41:36 +05301222 elif patch_no == 309:
1223 sql("delete from `tabDocField` where fieldname = 'item_attachments_details' and parent = 'Item'")
nabinhait7f339e02011-07-05 15:43:17 +05301224 sql("delete from `tabModule Def Item` where parent = 'Stock' and doc_name = 'Landed Cost Wizard'")
nabinhait5deab242011-07-06 09:23:02 +05301225 elif patch_no == 310:
1226 from erpnext_structure_cleanup import run_patches
1227 run_patches()
nabinhait4bb8bf42011-07-06 10:11:11 +05301228 elif patch_no == 311:
1229 sql("update `tabDocField` set reqd = 0 where fieldname = 'select_item' and parent = 'Property Setter'")
nabinhait4c38fbb2011-07-06 10:36:53 +05301230 #reload_doc('core', 'doctype', 'property_setter')
nabinhait4bb8bf42011-07-06 10:11:11 +05301231 elif patch_no == 312:
1232 sql("delete from `tabSessions`")
1233 sql("delete from `__SessionCache`")
nabinhaitd54ec522011-07-06 12:20:21 +05301234 elif patch_no == 313:
1235 dt = ['GL Entry', 'Stock Ledger Entry']
1236 for t in dt:
1237 rec = sql("select voucher_type, voucher_no, ifnull(is_cancelled, 'No') from `tab%s` where modified >= '2011-07-06 10:00:00' group by voucher_no" % t)
1238 for d in rec:
nabinhaitfccbb092011-07-06 12:23:27 +05301239 sql("update `tab%s` set docstatus = %s where name = '%s'" % (d[0], d[2]=='No' and 1 or 2, d[1]))
nabinhaitd54ec522011-07-06 12:20:21 +05301240
1241 other_dt = ['Enquiry', 'Quotation', 'Sales Order', 'Indent', 'Purchase Order', 'Production Order', 'Customer Issue', 'Installation Note']
1242 for dt in other_dt:
1243 rec = sql("select name, status from `tab%s` where modified >= '2011-07-06 10:00:00'" % dt)
1244 for r in rec:
1245 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]))
1246
1247
1248 dt_list = ['Delivery Note', 'Purchase Receipt']
1249 for dt in dt_list:
1250 sql("update `tab%s` set status = 'Submitted' where docstatus = 1 and modified >='2011-07-06 10:00:00'" % dt)
1251 sql("update `tab%s` set status = 'Cancelled' where docstatus = 2 and modified >='2011-07-06 10:00:00'" % dt)
1252
1253 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']
1254 for d in dt_list:
1255 tbl = sql("select options from `tabDocField` where fieldtype = 'Table' and parent = '%s'" % d)
1256 for t in tbl:
1257 sql("update `tab%s` t1, `tab%s` t2 set t1.docstatus = t2.docstatus where t1.parent = t2.name" % (t[0], d))
nabinhait22f7edd2011-07-06 12:45:02 +05301258
1259 elif patch_no == 314:
1260 # delete double feed
1261 sql("delete from tabFeed where subject like 'New %'")
nabinhaiteb315402011-07-06 13:03:31 +05301262 elif patch_no == 315:
1263 # delete double feed
1264 sql("delete from tabFeed where doc_name like 'New %'")
1265 reload_doc('core', 'doctype', 'property_setter')
1266
1267 from webnotes.model.doc import Document
1268 m = Document('Module Def Role')
1269 m.role = 'All'
1270 m.parent = 'Home'
1271 m.parenttype = 'Module Def'
1272 m.parentfield = 'roles'
1273 m.save(1)
Ravi Dey7a6211d2011-07-07 15:49:24 +05301274 elif patch_no == 316:
Ravi Dey89822722011-07-07 15:52:35 +05301275 pass
1276 elif patch_no == 317:
1277 sql("update `tabPage` set name = 'profile-settings' where page_name = 'Profile Settings'")
Anand Doshi56ab7e42011-07-07 18:37:58 +05301278 elif patch_no == 318:
Ravi Deycfc5dff2011-07-07 16:48:54 +05301279 reload_doc('utilities', 'doctype', 'bulk_rename_tool')
Anand Doshi52b1d5a2011-07-07 18:41:12 +05301280 elif patch_no == 319:
Anand Doshi56ab7e42011-07-07 18:37:58 +05301281 sql("delete from tabFeed where doc_name like 'New %'")
nabinhait63cf2b92011-07-08 13:30:46 +05301282 elif patch_no == 320:
1283 reload_doc('setup', 'doctype', 'series_detail')
Ravi Deyfac96e12011-07-08 13:38:16 +05301284 elif patch_no == 321:
Ravi Dey84913842011-07-08 13:46:09 +05301285 reload_doc('hr','doctype','leave_application')
1286 elif patch_no == 322:
1287 sql("delete from `tabDocField` where parent = 'Leave Application' and fieldname = 'latter_head'")
Nabin Hait2acac4b2011-07-10 13:52:05 +05301288 elif patch_no == 323:
1289 reload_doc('stock', 'doctype', 'stock_entry')
Nabin Haite079a6e2011-07-10 14:15:52 +05301290 sql("update `tabDocField` set options = 'get_stock_and_rate' where parent = 'Stock Entry' and label = 'Get Stock and Rate'")
1291 sql("delete from `tabDocField` where label = 'Get Current Stock' and parent = 'Stock Entry'")
nabinhait54b0e7d2011-07-13 16:40:03 +05301292 elif patch_no == 324:
1293 sql("delete from `tabDocField` where fieldname = 'test_field' and parent = 'Customer'")
Ravi Dey9dd0c0b2011-07-13 18:08:38 +05301294 elif patch_no == 325:
1295 sql("update `tabDocField` set fieldtype = 'Data' where parent = 'Salary Slip' and fieldname = 'total_days_in_month'")
1296 reload_doc('hr', 'doctype', 'salary_slip')
Rushabh Mehta61790802011-07-17 10:52:47 +05301297 elif patch_no == 326:
1298 # load the new billing page
1299 if cint(webnotes.conn.get_value('Control Panel',None,'sync_with_gateway')):
1300 reload_doc('server_tools','page','billing')
nabinhaite6526362011-07-19 18:09:26 +05301301 elif patch_no == 327:
1302 if webnotes.conn.get_value('Control Panel', None, 'account_id') != 'axjanak2011':
1303 sql("delete from `tabDocField` where fieldname = 'supplier_status' and parent = 'Supplier'")
nabinhait1458af02011-07-20 10:31:19 +05301304 elif patch_no == 328:
1305 from index_patch import create_proper_index
1306 create_proper_index()
nabinhaitde9826c2011-07-20 18:02:59 +05301307 elif patch_no == 329:
1308 reload_doc('utilities', 'doctype', 'rename_tool')
1309 reload_doc('utilities', 'doctype', 'bulk_rename_tool')