blob: 40e7d3a00461391cb0ddc78978bf56079fc190c4 [file] [log] [blame]
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301# REMEMBER to update this
2# ========================
nabinhaita56fc002011-07-01 16:32:03 +05303
Nabin Haitc4e579c2011-08-05 11:21:35 +05304last_patch = 334
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05305
6#-------------------------------------------
7
8def execute(patch_no):
9 import webnotes
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +053010 from webnotes.modules.module_manager import reload_doc
11
12 from webnotes.model.code import get_obj
13 sql = webnotes.conn.sql
14 from webnotes.utils import cint, cstr, flt
15 from webnotes.model.doc import Document
16
17 if patch_no==33:
18 pass
19 elif patch_no==34:
20 webnotes.conn.sql("update `tabDocField` set options = 'Letter Head', print_hide = 1 where fieldname = 'letter_head' and fieldtype = 'Link'")
21 elif patch_no==35:
22 webnotes.conn.sql("update tabDocType set module = 'Event Updates' where name = 'Feed Control'")
23 elif patch_no==36:
24 # remove delivery note foreign key in Serial Number
25 from webnotes.model.db_schema import DbTable
26 t = DbTable('Serial No')
27 fk_list = t.get_foreign_keys()
28 for f in fk_list:
29 if f[0]=='delivery_note_no':
30 webnotes.conn.commit()
31 webnotes.conn.sql("alter table `tabSerial No` drop foreign key `%s`" % f[1])
32 webnotes.conn.begin()
33 webnotes.conn.sql("update tabDocField set fieldtype='Data' where fieldname='delivery_note_no' and parent='Serial No' limit 1")
34 elif patch_no==37:
35 import os
36 mod_path = webnotes.defs.modules_path
37 path_list = []
38 for m in os.listdir(mod_path):
39 for t in ['doctype', 'page', 'search_criteria']:
40 dt_path = os.path.join(mod_path, m, t)
41 if os.path.exists(dt_path):
42 for dt in os.listdir(dt_path):
43 if '.' not in dt and os.path.exists(os.path.join(dt_path, dt, dt+ '.txt')):
44 path_list.append(os.path.join(dt_path, dt, dt+ '.txt'))
45
46 for d in path_list:
47 doclist = eval(open(d,'r').read())
48 webnotes.conn.sql("update `tab%s` set module = '%s' where name = '%s'" % (doclist[0]['doctype'], doclist[0]['module'], doclist[0]['name']))
Brahma K09307622011-07-27 12:03:34 +053049
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +053050 elif patch_no==38:
51 import webnotes
52 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.")
53 webnotes.conn.set_global("system_message_id", "1")
54
55 elif patch_no == 39:
56 pass
57
58 elif patch_no == 40:
Nabin Hait31a407d2011-07-28 11:47:45 +053059 import_from_files(record_list=[['stock','doctype','item']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +053060 elif patch_no == 42:
61 acc = sql("select name, lft, rgt from tabAccount where account_name in ('Incomes', 'Expenses')")
62 for d in acc:
63 sql("update tabAccount set is_pl_account = 'Yes' where lft >= '%s' and rgt <= '%s'" % (d[1], d[2]))
64 elif patch_no == 43:
65 import webnotes.model
66 webnotes.model.delete_doc('Page', 'Module Manager')
Brahma K09307622011-07-27 12:03:34 +053067
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +053068 # cleanup of Service, Customer Support, Utilities Modules
69 # -------------------------------------------------------
70 elif patch_no == 44:
71 from webnotes.model import delete_doc
72
73 for dt in sql("select name from tabDocType where module in ('Customer Support')"):
74 delete_doc('DocType', dt[0])
75
76 for dt in sql("select name from `tabSearch Criteria` where module in ('Customer Support')"):
77 delete_doc('Search Criteria', dt[0])
78
79 for dt in sql("select name from tabPage where module in ('Customer Support')"):
80 delete_doc('Page', dt[0])
81
82 # move a couple
83 webnotes.conn.sql("update `tab%s` set module=%s where name=%s" % ('DocType', '%s', '%s'), ('Application Internal', 'Patch Util'))
84 webnotes.conn.sql("update `tab%s` set module=%s where name=%s" % ('DocType', '%s', '%s'), ('Application Internal', 'DocType Property Setter'))
85
86 # remove utilities
87 webnotes.conn.sql('delete from `tabModule Def` where name in ("Customer Support", "Utilities")')
Brahma K09307622011-07-27 12:03:34 +053088
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +053089 elif patch_no == 45:
90 webnotes.conn.sql('delete from tabDocField where options="Ticket Response Detail"')
91
92 elif patch_no == 46:
93 import webnotes
94 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.")
95 webnotes.conn.set_global("system_message_id", "2")
96
97 elif patch_no == 47:
98 import webnotes
99 webnotes.conn.set_global("system_message", "")
100 webnotes.conn.set_global("system_message_id", "3")
101
102 elif patch_no == 48:
103 webnotes.conn.sql("update tabDocField set options = 'Print Heading' where fieldname = 'select_print_heading'")
104
105 elif patch_no == 49:
106 webnotes.conn.sql("update tabDocType set autoname = '' where name = 'Search Criteria'")
107 elif patch_no == 50:
108 sql("update tabDocField set in_filter = 1 where fieldname in ('cost_center', 'income_account', 'Item Group') and parent = 'RV Detail'")
109 elif patch_no == 51:
110 sql("update tabDocField set options = 'link:Print Heading' where fieldtype = 'Select' and fieldname = 'select_print_heading' and parent = 'POS Setting'")
111 elif patch_no == 52:
112 sql("update tabDocField set print_hide = 1 where fieldname = 'letter_head'")
113 elif patch_no == 53:
114 sql("update tabDocType set search_fields = 'lead_name,lead_owner,status,contact_by,contact_date' where name = 'Lead'")
115 elif patch_no == 54:
116 sql("delete from tabDocField where parent = 'Supplier' and label = 'Supplier Contacts' and fieldtype = 'Section Break'")
117 elif patch_no == 55:
118 sql("commit")
119 try:
120 sql("alter table tabFeed add column `_user_tags` varchar(180)")
121 except Exception, e:
122 if e.args[0]!=1060:
123 raise e
124 elif patch_no == 56:
125 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'")
126 elif patch_no == 57:
Nabin Hait31a407d2011-07-28 11:47:45 +0530127 import_from_files(record_list=[['selling','doctype','sales_order_detail']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530128 elif patch_no == 58:
129 # module def patches
130 sql("update `tabModule Def` set module_page = NULL where name not in ('Event Updates', 'Setup', 'My Company')")
131 sql("delete from `tabModule Def Item` where doc_type in ('Separator', 'Setup Forms', 'More Reports')")
132 sql("delete from `tabModule Def Item` where doc_name = 'Project Activity'")
133 sql("update `tabModule Def` set module_label = 'People', disabled='No', is_hidden='No' where name = 'My Company'")
Brahma K09307622011-07-27 12:03:34 +0530134
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530135 # insert new module items
136 from webnotes.model.doc import make_autoname
137 if not sql("select name from `tabModule Def Item` where parent='Projects' and doc_name='Ticket'"):
Brahma K09307622011-07-27 12:03:34 +0530138 sql("""insert into `tabModule Def Item`
139 (name, parent, parenttype, parentfield, docstatus, doc_type, doc_name, display_name, idx) values
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530140 (%s, 'Projects', 'Module Def', 'items', 0, 'Forms', 'Ticket', 'Task', 1)""", make_autoname('MDI.#####'))
141
142 if not sql("select name from `tabModule Def Item` where parent='Projects' and doc_name='Timesheet'"):
Brahma K09307622011-07-27 12:03:34 +0530143 sql("""insert into `tabModule Def Item`
144 (name, parent, parenttype, parentfield, docstatus, doc_type, doc_name, display_name, idx) values
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530145 (%s, 'Projects', 'Module Def', 'items', 0, 'Forms', 'Timesheet', 'Timesheet', 2)""", make_autoname('MDI.#####'))
Brahma K09307622011-07-27 12:03:34 +0530146
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530147 if not sql("select name from `tabModule Def Item` where parent='Projects' and doc_name='Projects'"):
Brahma K09307622011-07-27 12:03:34 +0530148 sql("""insert into `tabModule Def Item`
149 (name, parent, parenttype, parentfield, docstatus, doc_type, doc_name, display_name, idx) values
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530150 (%s, 'Projects', 'Module Def', 'items', 0, 'Pages', 'Projects', 'Gantt Chart', 1)""", make_autoname('MDI.#####'))
Brahma K09307622011-07-27 12:03:34 +0530151
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530152 elif patch_no == 59:
153 webnotes.conn.set_value('Control Panel',None,'mail_footer','')
154 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>')
155 elif patch_no == 60:
156 sql("delete from `tabModule Def Item` where display_name = 'Point of Sales'")
157 elif patch_no == 61:
158 sql("delete from `tabTDS Category Account` where company not in (select name from tabCompany)")
159 elif patch_no == 62:
160 # Import Supplier Quotation
Nabin Hait31a407d2011-07-28 11:47:45 +0530161 import_from_files(record_list=[['buying','doctype','supplier_quotation']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530162 # Adding Status Filter
163 sql("update tabDocType set search_fields = concat('status,',search_fields) where name IN ('Delivery Note','Leave Transaction')")
164 # Import Other Charges
Brahma K09307622011-07-27 12:03:34 +0530165
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530166 import_from_files(record_list=[['setup','doctype','other_charges']])
167 elif patch_no == 63:
168 sql("update `tabDocField` set permlevel = 1 where fieldname in ('return_date', 'return_details') and parent = 'Sales and Purchase Return Wizard'")
Nabin Hait31a407d2011-07-28 11:47:45 +0530169 import_from_files(record_list = [['accounts', 'doctype', 'rv_detail'], ['stock', 'doctype', 'sales_and_purchase_return_wizard'], ['stock', 'doctype', 'stock_entry']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530170 elif patch_no == 64:
171 sql("update tabDocField set `hidden` = 1, `print_hide` = 1, `report_hide` = 1 where options in ('RFQ','Supplier Quotation')")
172 sql("update tabDocType set `read_only` = 1, in_create = 1 where name in ('RFQ','Supplier Quotation')")
173 sql("update tabDocField set `report_hide` = 0 where fieldname in ('email_id','phone_1','fax_1') and parent = 'Customer'")
174 elif patch_no == 65:
175 # Monthly Trend Analyzer <-> Trend Analyzer
176 sql("update `tabSearch Criteria` set criteria_name = 'Trend Analyzer' where criteria_name = 'Monthly Trend Analyzer' and name = 'SRCH/00159'")
177 sql("update `tabModule Def Item` set display_name = 'Trend Analyzer' where parent = 'Analysis' and display_name = 'Monthly Trend Analyzer'")
178 elif patch_no == 66:
179 import webnotes
180 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!""")
181 webnotes.conn.set_global("system_message_id", "4")
Brahma K09307622011-07-27 12:03:34 +0530182
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530183 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')")
184 from webnotes.session_cache import clear_cache
185 clear_cache(webnotes.session['user'])
186 elif patch_no == 67:
187 sql("update `tabDocField` set in_filter = 1 where fieldname = 'brand' and parent = 'RV Detail'")
188 sql("delete from `tabModule Def Item` where (display_name = 'Sales Invoice' and parent = 'CRM') or (display_name = 'Purchase Invoice' and parent = 'SRM')")
189 elif patch_no == 68:
190 from webnotes.modules.import_module import import_from_files
Nabin Hait31a407d2011-07-28 11:47:45 +0530191 import_from_files(record_list=[['hr','doctype','employee'],['roles','Role','Employee']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530192 elif patch_no == 69:
193 # delete flds from employee master
194 p = get_obj('Patch Util')
195 emp_del_flds = ['month_of_birth']
196 for f in emp_del_flds:
197 p.delete_field('Employee', f)
198
199 sql("Update tabDocField set `default` = 'Active' where fieldname = 'status' and parent = 'Employee'")
200
201 # map parent flds
202 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']
203
204 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")
205 for e in emp_prof:
206 prof_obj = get_obj('Employee Profile', e[0])
207 emp_obj = get_obj('Employee', e[1])
208 for d in fld_map:
209 emp_obj.doc.fields[d] = prof_obj.doc.fields[d]
210 emp_obj.doc.current_accommodation_type = prof_obj.doc.present_accommodation_type
Brahma K09307622011-07-27 12:03:34 +0530211
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530212 # address
213 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])
214 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])
215 emp_obj.doc.permanent_address = per_addr
216 emp_obj.doc.current_address = cur_addr
217 #family
218 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])
219 emp_obj.doc.family_background = fam
220 # health
221 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])
222 emp_obj.doc.health_details = health
223 emp_obj.doc.save()
224
225
226 # map tables
227 tbl_list = ['Experience In Company Detail', 'Previous Experience Detail', 'Educational Qualifications Detail']
228 for t in tbl_list:
229 sql("update `tab%s` t1, `tabEmployee Profile` t2 set t1.parent = t2.employee, t1.parenttype = 'Employee' where t1.parent = t2.name" % t)
230
231
232 # overwrite idx?????????
233
234
235 # delete emp profile
236 webnotes.model.delete_doc('DocType', 'Employee Profile')
237 for e in emp_prof:
238 webnotes.model.delete_doc('Employee Profile', e[0])
239
240 elif patch_no == 70:
241 # update search criteria module -> System
242 sql("update tabDocType set module='System' where name='Search Criteria'")
Brahma K09307622011-07-27 12:03:34 +0530243
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530244 # Cleanups to Contact
245 sql("update tabDocField set fieldtype='Data' where options='Designation' and parent='Contact'")
246 sql("update tabDocField set fieldtype='Data' where options='Department' and parent='Contact'")
247 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'")
248
249 # import Contact, Employee
250 from webnotes.modules.import_module import import_from_files
Nabin Hait31a407d2011-07-28 11:47:45 +0530251 import_from_files(record_list=[['utilities','doctype','contact']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530252
Brahma K09307622011-07-27 12:03:34 +0530253
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530254 # remove last_contact_date from Lead
255 sql("delete from tabDocField where fieldname='last_contact_date' and parent='Lead'")
Brahma K09307622011-07-27 12:03:34 +0530256
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530257 elif patch_no == 71:
258 # Make Stock Qty and Conversion Factor field editable. Also no need to mention Conversion factor in table can do it directly
259 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')")
260 sql("update `tabDocField` set `width` = '100px' where parent IN ('PO Detail','Purchase Receipt Detail') and fieldname = 'stock_uom'")
261
262 elif patch_no == 72:
263 # Core Patch
264 # ----------
Brahma K09307622011-07-27 12:03:34 +0530265
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530266 from webnotes.modules.import_module import import_from_files
Brahma K09307622011-07-27 12:03:34 +0530267
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530268 # import module def
269 import_from_files(record_list = [['core', 'Module Def', 'Core']])
270 elif patch_no == 73:
271 # set module in DocTypes
272 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')")
Brahma K09307622011-07-27 12:03:34 +0530273
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530274 # set module in Page
275 sql("update tabPage set module='Core' where name='Login Page'")
Brahma K09307622011-07-27 12:03:34 +0530276
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530277 # move file browser to Tools
278 sql("update tabPage set module='Tools' where name='File Browser'")
279 sql("update tabDocType set module='Tools' where name='File Browser Control'")
280 sql("update tabDocType set module='Application Internal' where name='Profile Control'")
281 elif patch_no == 74:
282 p = get_obj('Patch Util')
283 # permission
284 p.delete_permission('Employee', 'Administrator', 0)
285 p.delete_permission('Employee', 'Administrator', 1)
286 p.add_permission('Employee', 'Employee', 0, read = 1, match = 'owner')
287 p.add_permission('Employee', 'Employee', 1, read = 1, match = 'owner')
288 sql("delete from `tabDocField` where parent = 'Employee' and label = 'Payroll Rule'")
289 elif patch_no == 75:
290 #sal structure patch
291 # import
292 from webnotes.modules.import_module import import_from_files
Nabin Hait31a407d2011-07-28 11:47:45 +0530293 import_from_files(record_list=[['hr','doctype','salary_structure'], ['hr','doctype','earning_detail'],['hr','doctype','deduction_detail']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530294 elif patch_no == 76:
295 # property
296 p = get_obj('Patch Util')
297 p.set_field_property('Salary Structure', 'is_active', 'default', 'Yes')
298 p.set_field_property('Salary Structure', 'ctc', 'reqd', '1')
299 p.set_field_property('Earning Detail', 'modified_value', 'width', '')
300 p.set_field_property('Earning Detail', 'modified_value', 'trigger', 'Client')
301 p.set_field_property('Deduction Detail', 'd_modified_amt', 'width', '')
302 p.set_field_property('Earning Detail', 'd_modified_amt', 'trigger', 'Client')
303 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'")
304
305 # delete
306 sql("update `tabSalary Structure` set net_pay = total")
307 sql("delete from tabDocField where label in ('LWP Help', 'Calculate Total', 'Total') and parent = 'Salary Structure'")
308 sql("delete from tabDocPerm where parent in ('Earning Detail', 'Deduction Detail')")
309
310
311 # permission
312 p.delete_permission('Salary Structure', 'Administrator', 0)
313 p.delete_permission('Salary Structure', 'Administrator', 1)
314 p.add_permission('Salary Structure', 'Employee', 0, read = 1, match = 'owner')
315 p.add_permission('Salary Structure', 'Employee', 1, read = 1, match = 'owner')
316 elif patch_no == 77:
317 # sal slip patch
318 # import
319 from webnotes.modules.import_module import import_from_files
Nabin Hait31a407d2011-07-28 11:47:45 +0530320 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']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530321 elif patch_no == 78:
322 p = get_obj('Patch Util')
323 # delete
324 sql("update `tabSalary Slip` set leave_encashment_amount = encashment_amount")
325 p.delete_field('Salary Slip', 'encashment_amount')
326 p.delete_field('Salary Slip', 'year')
327 p.delete_field('Salary Slip', 'flag')
328 sql("delete from tabDocField where label = 'Process Payroll' and parent = 'Salary Slip'")
329
330 # field property
331 p.set_field_property('Salary Slip', 'bank_name', 'permlevel', '1')
332 p.set_field_property('Salary Slip', 'leave_without_pay', 'permlevel', '0')
333 p.set_field_property('Salary Slip', 'leave_without_pay', 'trigger', 'Client')
334 p.set_field_property('SS Earning Detail', 'e_type', 'permlevel', '0')
335 p.set_field_property('SS Earning Detail', 'e_type', 'fieldtype', 'Link')
336 p.set_field_property('SS Earning Detail', 'e_type', 'options', 'Earning Type')
337 p.set_field_property('SS Deduction Detail', 'd_type', 'permlevel', '0')
338 p.set_field_property('SS Deduction Detail', 'd_type', 'fieldtype', 'Link')
339 p.set_field_property('SS Deduction Detail', 'd_type', 'options', 'Deduction Type')
340 sql("update `tabSS Earning Detail` set e_modified_amount = e_amount")
341 sql("update `tabSS Deduction Detail` set d_modified_amount = d_amount")
342
343 # permission
344 p.delete_permission('Salary Slip', 'Administrator', 0)
345 p.delete_permission('Salary Slip', 'Administrator', 1)
346 p.add_permission('Salary Slip', 'Employee', 0, read = 1, match = 'owner')
347 p.add_permission('Salary Slip', 'Employee', 1, read = 1, match = 'owner')
348 elif patch_no == 79:
349 # Import Modules
Nabin Hait31a407d2011-07-28 11:47:45 +0530350 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','Payroll']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530351 elif patch_no == 80:
352 # Holiday List
353 sql("update `tabHoliday List Detail` set description = holiday_name")
354 sql("delete from tabDocField where parent = 'Holiday List Detail' and fieldname = 'holiday_name'")
355 sql("update tabDocField set fieldtype = 'Select', options = 'link:Fiscal Year' where parent = 'Holiday List' and fieldname = 'fiscal_year'")
356 sql("delete from tabDocPerm where role in ('Administrator','HR User') and parent = 'Holiday List'")
357
358 # Leave Control Panel
359 # --------------------
360 sql("delete from `tabDocField` where parent = 'Leave Control Panel' and label in ('Leave Control Panel','Allocation Details') and fieldtype = 'Section Break'")
361 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')")
362 sql("update tabDocField set fieldtype = 'Select', options = 'link:Fiscal Year' where parent = 'Leave Control Panel' and fieldname = 'fiscal_year'")
363 sql("update tabDocField set fieldtype = 'Select', options = 'link:Leave Type' where parent = 'Leave Control Panel' and fieldname = 'leave_type'")
364 sql("update tabDocField set reqd = 1 where parent = 'Leave Control Panel' and fieldname = 'no_of_days'")
365
366 # Leave Application
367 # ------------------
368 for d in sql("select * from `tabLeave Transaction` where leave_transaction_type = 'Deduction' and ifnull(deduction_type, '') = 'Leave'", as_dict = 1):
369 lp = Document('Leave Application')
370 lp.employee = d['employee']
371 lp.leave_type = d['leave_type']
372 lp.posting_date = d['date']
373 lp.fiscal_year = d['fiscal_year']
374 lp.leave_balance = d['pre_balance']
375 lp.half_day = d['half_day']
376 lp.from_date = d['from_date']
377 lp.to_date = d['to_date']
378 lp.total_leave_days = d['total_leave']
379 lp.description = d['reason']
380 lp.docstatus = cint(d['docstatus'])
381 lp.save(1)
382
383 # Leave Allocation
384 # -----------------
385 for d in sql("select * from `tabLeave Transaction` where leave_transaction_type = 'Allocation'", as_dict = 1):
386 la = Document('Leave Allocation')
387 la.employee = d['employee']
388 la.leave_type = d['leave_type']
389 la.posting_date = d['date']
390 la.fiscal_year = d['fiscal_year']
391 la.new_leaves_allocated = d['total_leave']
392 la.total_leaves_allocated = d['total_leave']
393 la.description = d['reason']
394 la.docstatus = cint(d['docstatus'])
395 la.save(1)
396
397 # Payroll Module Def
398 # -------------------
399 sql("delete from `tabModule Def Item` where doc_name = 'Leave Transaction' and display_name = 'Leave Transaction' and parent = 'Payroll' and doc_type = 'Forms'")
400
401 elif patch_no == 81:
402 # Import Modules
Nabin Hait31a407d2011-07-28 11:47:45 +0530403 import_from_files(record_list=[['hr','Module Def','Payroll']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530404 elif patch_no == 82:
405 sql("update tabDocType set search_fields = 'employee,leave_type,total_leaves_allocated,fiscal_year' where name = 'Leave Allocation'")
406 sql("update tabDocType set search_fields = 'employee,leave_type,from_date,to_date,total_leave_days,fiscal_year' where name = 'Leave Application'")
407 elif patch_no == 83:
408 # delete leave transaction
409 webnotes.conn.sql("set foreign_key_checks=0")
410 sql("delete from `tabLeave Transaction`")
411 import webnotes.model
412 webnotes.model.delete_doc('DocType','Badge Settings Detail')
413 webnotes.model.delete_doc('DocType','Leave Transaction')
414 webnotes.conn.sql("set foreign_key_checks=1")
415 elif patch_no == 84:
416 p = get_obj('Patch Util')
417 p.set_field_property('SS Earning Detail', 'e_amount', 'permlevel', '1')
418 p.set_field_property('SS Deduction Detail', 'd_amount', 'permlevel', '1')
419 elif patch_no == 85:
420 # permission
421 p = get_obj('Patch Util')
422 p.add_permission('Leave Application', 'Employee', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1, match = 'owner')
423 p.add_permission('Leave Application', 'Employee', 1, read = 1, match = 'owner')
424 p.add_permission('Leave Allocation', 'HR User', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1, match = 'owner')
425 p.add_permission('Leave Allocation', 'HR User', 1, read = 1)
426 sql("update tabDocPerm set `match` = '' where parent = 'Leave Application' and role = 'HR User'")
427 elif patch_no == 86:
428 # Import Modules
Nabin Hait31a407d2011-07-28 11:47:45 +0530429 import_from_files(record_list=[['hr','doctype','leave_type']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530430 elif patch_no == 87:
431 sql("update `tabLeave Type` set is_lwp = 1 where name = 'Leave Without Pay'")
432 elif patch_no == 88:
433 # Import Modules
Nabin Hait31a407d2011-07-28 11:47:45 +0530434 import_from_files(record_list=[['hr','doctype','leave_allocation']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530435 elif patch_no == 89:
436 sql("delete from `tabModule Def Item` where doc_type = 'Setup Forms' and doc_name in ('Payroll Rule', 'IT Checklist', 'Employee Profile') and parent = 'Payroll'")
437 sql("update `tabDocField` set `hidden` = 1, `print_hide` = 1, `report_hide` = 1 where parent = 'Leave Type' and fieldname = 'is_encash'")
438 elif patch_no == 90:
439 sql("update `tabLeave Allocation` set docstatus = 1")
440 elif patch_no == 91:
441 import webnotes
442 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!""")
443 webnotes.conn.set_global("system_message_id", "5")
444 elif patch_no == 92:
445 sql("update tabDocField set label = 'Get Charges' where parent IN ('Sales Order','Delivery Note','Receivable Voucher') and label = 'Get Other Charges' and fieldtype = 'Button'")
446 # Automated Other Charges Calculation basis
447 sql("update tabDocField set options = '', `trigger` = 'Client' where parent IN ('Quotation','Sales Order','Delivery Note','Receivable Voucher') and label = 'Get Charges' and fieldtype = 'Button'")
448 elif patch_no == 93:
449 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'")
450 sql("update `tabField Mapper Detail` set from_field = 'customer' where to_field = 'customer' and parent = 'Sales Order-Receivable Voucher'")
451 elif patch_no == 94:
Nabin Hait31a407d2011-07-28 11:47:45 +0530452 import_from_files(record_list=[['selling','doctype','sms_center']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530453 elif patch_no == 95:
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530454 import_from_files(record_list=[['mapper','DocType Mapper','Sales Order-Receivable Voucher'], ['mapper','DocType Mapper','Delivery Note-Receivable Voucher']])
455 elif patch_no == 96:
456 sql("delete from `tabModule Def Item` where doc_type = 'Reports' and display_name = 'Cenvat Credit - Input or Capital Goods' and parent = 'Accounts'")
457 elif patch_no == 97:
458 sql("update tabFeed set doc_label = 'Feed', doc_name = name where ifnull(doc_name,'') = '' and ifnull(doc_label,'') = ''")
459 elif patch_no == 98:
460 import_from_files(record_list=[['accounts','doctype','payable_voucher']])
461 elif patch_no == 99:
462 import_from_files(record_list=[['accounts','doctype','account']])
463 elif patch_no == 100:
464 p = get_obj('Patch Util')
465 p.set_field_property('Account', 'level', 'hidden', '1')
466 p.set_field_property('Account', 'level', 'print_hide', '1')
467 p.set_field_property('Account', 'account_type', 'search_index', '0')
468 p.set_field_property('TDS Detail', 'tds_category', 'width', '150px')
469 p.set_field_property('TDS Detail', 'special_tds_rate_applicable', 'width', '150px')
470 p.set_field_property('TDS Detail', 'special_tds_rate', 'width', '150px')
471 p.set_field_property('TDS Detail', 'special_tds_limit', 'width', '150px')
472 elif patch_no == 101:
473 # Leave Application Details and Leave Allocation Details
474 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')")
475 get_obj('DocType','Leave Application').doc.save()
476 get_obj('DocType','Leave Allocation').doc.save()
477 elif patch_no == 102:
478 # make item description field editable in production order
479 sql("update tabDocField set permlevel = 0 where fieldname = 'description' and parent = 'Production Order'")
480 elif patch_no == 103:
481 sql("update tabDocField set fieldname = '' where fieldtype = 'HTML'")
482 elif patch_no == 104:
Nabin Hait31a407d2011-07-28 11:47:45 +0530483 import_from_files(record_list=[['hr','search_criteria','stdsrch_00001'],['hr','search_criteria','stdsrch_00002'],['hr','search_criteria','stdsrch_00003'],['hr','Module Def','Payroll'],['hr','doctype','leave_application'],['hr','doctype','leave_allocation']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530484 elif patch_no == 105:
485 # Employee Leave Balance
486 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')")
487 # Update Search Fields
488 sql("update tabDocType set search_fields = 'employee,employee_name,leave_type,from_date,to_date,total_leave_days,fiscal_year' where name = 'Leave Application'")
489 sql("update tabDocType set search_fields = 'employee,employee_name,leave_type,total_leaves_allocated,fiscal_year' where name = 'Leave Allocation'")
490 elif patch_no == 106:
491 for d in sql("select name,employee,employee_name from `tabLeave Allocation`"):
492 if not cstr(d[2]):
493 sql("update `tabLeave Allocation` set employee_name = '%s' where name = '%s'" % (webnotes.conn.get_value('Employee',cstr(d[1]),'employee_name'), cstr(d[0])))
494 for d in sql("select name,employee,employee_name from `tabLeave Application`"):
495 if not cstr(d[2]):
496 sql("update `tabLeave Application` set employee_name = '%s' where name = '%s'" % (webnotes.conn.get_value('Employee',cstr(d[1]),'employee_name'), cstr(d[0])))
497 elif patch_no == 107:
498 sql("delete from `tabDocField` where fieldname = 'fiscal_year' and parent = 'Employee'")
499 elif patch_no == 108:
Nabin Hait31a407d2011-07-28 11:47:45 +0530500 import_from_files(record_list=[['hr','search_criteria','srch_std_00013']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530501 elif patch_no == 109:
Nabin Hait31a407d2011-07-28 11:47:45 +0530502 import_from_files(record_list=[['hr','search_criteria','srch_std_00015']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530503 elif patch_no == 110:
Nabin Hait31a407d2011-07-28 11:47:45 +0530504 import_from_files(record_list=[['hr','doctype','salary_structure'], ['hr', 'doctype', 'salary_slip']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530505 elif patch_no == 111:
506 sql("update tabDocType set search_fields = 'transfer_date, from_warehouse, to_warehouse, purpose, remarks' where name = 'Stock Entry'")
507 elif patch_no == 112:
508 sql("delete from tabDocField where label = 'Get Other Charges' and fieldtype = 'Button' and parent = 'Receivable Voucher'")
509 elif patch_no == 113:
510 sql("update tabDocField set reqd = 1 where parent = 'Customer' and fieldname = 'phone_1'")
511 elif patch_no == 114:
512 for d in sql("select name, master_name, credit_days, credit_limit from tabAccount where master_type = 'Customer'"):
513 if cstr(d[1]):
514 days, limit = cint(d[2]), flt(d[3])
515 cust_det = sql("select credit_days, credit_limit from tabCustomer where name = '%s'" % (cstr(d[1])))
516 if not days: days = cust_det and cint(cust_det[0][0]) or 0
517 if not limit: limit = cust_det and flt(cust_det[0][1]) or 0
518 sql("COMMIT")
519 sql("START TRANSACTION")
520 sql("update tabAccount set credit_days = '%s', credit_limit = '%s' where name = '%s'" % (days, limit, cstr(d[0])))
521 sql("COMMIT")
522
523 elif patch_no == 115:
524 # patch for timesheet cleanup
525 from webnotes.model import delete_doc
526 delete_doc('DocType', 'Timesheet Detail')
Brahma K09307622011-07-27 12:03:34 +0530527
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530528 from webnotes.modules.import_module import import_from_files
529 import_from_files(record_list = [['Projects', 'DocType', 'Timesheet'], ['Projects', 'DocType', 'Timesheet Detail'], ['Projects', 'DocType', 'Activity Type']])
530
531 elif patch_no == 116:
532 # again!
533 from webnotes.model import delete_doc
534 delete_doc('DocType', 'Timesheet Detail')
Brahma K09307622011-07-27 12:03:34 +0530535
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530536 from webnotes.modules.import_module import import_from_files
537 import_from_files(record_list = [['Projects', 'DocType', 'Timesheet Detail']])
538 elif patch_no == 117:
539 op = '\n' + 'Walk In'
540 sql("update `tabDocField` set `options` = concat(options, %s) where parent = 'Enquiry' and fieldname = 'source' and options not like '%%Walk%%'", op)
541 elif patch_no == 118:
542 from webnotes.utils import get_defaults
543 ss = sql("select name, net_pay from `tabSalary Slip`")
544 for d in ss:
545 if d[1]:
546 w = get_obj('Sales Common').get_total_in_words(get_defaults()['currency'], d[1])
547 sql("update `tabSalary Slip` set net_pay_in_words = '%s' where name = '%s'" % (w, d[0]))
548 elif patch_no == 119:
549 sql("update tabDocType set in_create = 1 where name = 'Profile'")
550 elif patch_no == 120:
551 sql("update tabDocField set permlevel = 0 where parent = 'Sales and Purchase Return Wizard' and fieldname = 'return_date'")
552 elif patch_no == 121:
553 import_from_files(record_list = [['CRM', 'DocType', 'Return Detail'], ['Material Management', 'DocType', 'Sales and Purchase Return Wizard']])
554 elif patch_no == 122:
555 sql("delete from tabDocField where (fieldname = 'serial_no' or label = 'Warrany Status') and parent = 'Sales Order'")
556 elif patch_no == 123:
557 import_from_files(record_list = [['CRM', 'Module Def', 'CRM'], ['CRM', 'Search Criteria', 'STDSRCH/00004']])
558 elif patch_no == 124:
559 import webnotes
560 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!""")
561 webnotes.conn.set_global("system_message_id", "5")
562 elif patch_no == 125:
563 import_from_files(record_list = [['Material Management', 'DocType', 'Delivery Note']])
564 elif patch_no == 126:
565 sql("delete from tabDocField where parent = 'Delivery Note' and label in ('Make Sales Invoice', 'Make Installation Note', 'Intro Note')")
566 elif patch_no == 127:
567 sql("delete from tabDocPerm where role = 'All' and parent = 'Expense Voucher' and (permlevel = 0 or permlevel = 2)")
568 p = get_obj('Patch Util')
569 p.add_permission('Expense Voucher', 'Employee', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1, match = 'owner')
570 p.add_permission('Expense Voucher', 'HR Manager', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1)
571 p.add_permission('Expense Voucher', 'HR User', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1)
572 elif patch_no == 128:
573 from webnotes.modules import import_module
Nabin Hait31a407d2011-07-28 11:47:45 +0530574 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']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530575 elif patch_no == 129:
576 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'")
577 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'")
578 elif patch_no == 130:
579 # update from rv
580 from webnotes.model.code import get_obj
581 from webnotes.utils import cstr
582 for d in sql("select name, docstatus from `tabReceivable Voucher` where ifnull(docstatus,0) != 0"):
583 sql("COMMIT")
584 sql("START TRANSACTION")
585 try:
586 obj = get_obj('Receivable Voucher', cstr(d[0]), with_children = 1)
587 is_submit = 1
588 if cint(d[1]) == 2: is_submit = 0
589 get_obj('Sales Common').update_prevdoc_detail(is_submit, obj)
590 except:
591 pass
592 sql("COMMIT")
593
594 # update from dn
595 from webnotes.model.code import get_obj
596 for d in sql("select name, docstatus from `tabDelivery Note` where ifnull(docstatus,0) != 0"):
597 sql("COMMIT")
598 sql("START TRANSACTION")
599 try:
600 obj = get_obj('Delivery Note', cstr(d[0]), with_children = 1)
601 is_submit = 1
602 if cint(d[1]) == 2: is_submit = 0
603 get_obj('Sales Common').update_prevdoc_detail(is_submit, obj)
604 except:
605 pass
606 sql("COMMIT")
607 elif patch_no == 131:
608 sql("update `tabDocType` set allow_trash = 1 where name = 'Purchase Other Charges'")
609 sql("update tabDocPerm set `cancel` = 1 where parent = 'Purchase Other Charges' and permlevel = 0 and `read` = 1 and `write` = 1")
610 elif patch_no == 132:
611 sql("update tabDocField set no_copy = 0 where parent = 'Receivable Voucher' and fieldname = 'customer'")
612 elif patch_no == 133:
613 from webnotes.modules import import_module
614 import_module.import_from_files(record_list=[['accounts','doctype','receivable_voucher']])
615 elif patch_no == 134:
616 sql("update tabDocField set no_copy = 1 where parent = 'Receivable Voucher' and fieldname = 'posting_time'")
617 elif patch_no == 135:
618 sql("update tabDocField set `default` = 'Today' where parent = 'Receivable Voucher' and fieldname = 'due_date'")
619 elif patch_no == 136:
620 from webnotes.modules import import_module
621 import_module.import_from_files(record_list=[['accounts','doctype','rv_detail']])
622 elif patch_no == 137:
623 from webnotes.modules import import_module
624 import_module.import_from_files(record_list=[['setup','doctype','price_list']])
625 elif patch_no == 138:
626 sql("update `tabDocType` set allow_attach = 1 where name = 'Price List'")
627 elif patch_no == 139:
628 from webnotes.modules import import_module
629 import_module.import_from_files(record_list=[['mapper','DocType Mapper','Sales Order-Receivable Voucher'], ['mapper','DocType Mapper','Delivery Note-Receivable Voucher']])
630 elif patch_no == 140:
631 from webnotes.modules import import_module
632 import_module.import_from_files(record_list=[['accounts','doctype','rv_detail']])
633 elif patch_no == 141:
634 sql("delete from tabDocField where (fieldname = 'letter_head' or label = 'Letter Head') and parent = 'Company'")
635 elif patch_no == 142:
636 # fixes to letter head and personalize
637 from webnotes.model import delete_doc
Brahma K09307622011-07-27 12:03:34 +0530638
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530639 delete_doc('DocType', 'Batch Settings')
640 delete_doc('DocType', 'Batch Settings Detail')
641 delete_doc('DocType', 'Social Badge')
642 delete_doc('Page', 'Personalize Page')
643 delete_doc('DocType', 'Personalize Page Control')
Brahma K09307622011-07-27 12:03:34 +0530644
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530645 import_from_files(record_list=[['core','doctype','letter_head'], ['setup','doctype','personalize']])
646 elif patch_no == 144:
647 webnotes.conn.sql("update tabDocField set fieldtype='Code' where parent='Letter Head' and fieldname='content'")
648 elif patch_no == 145:
649 sql("update `tabDocField` set permlevel=1 where fieldname = 'group_or_ledger' and parent = 'Account'")
650 elif patch_no == 146:
651 import_from_files(record_list=[['accounts','doctype','account']])
652 elif patch_no == 147:
653 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']])
654 elif patch_no == 148:
655 sql("delete from `tabDocField` where (fieldname = 'account_balances' or label = 'Balances') and parent = 'Account'")
656 sql("update tabDocType set istable = 0, section_style = 'Simple', search_fields = 'account, period, fiscal_year, balance' where name = 'Account Balance'")
657 sql("update tabDocField set permlevel = 0 where parent = 'Account Balance'")
658 p = get_obj('Patch Util')
659 p.add_permission('Account Balance', 'Accounts User', 0, read = 1)
660 p.add_permission('Account Balance', 'Accounts Manager', 0, read = 1)
661 import_from_files(record_list=[['accounts','doctype','account_balance']])
662 elif patch_no == 149:
663 sql("update `tabAccount Balance` set account = parent")
664 elif patch_no == 150:
665 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')")
666 ac_bal = Document("DocType", "Account Balance")
667 ac_bal.save()
668 elif patch_no == 151:
669 sql("delete from tabDocField where label = 'Add / Manage Contacts' and fieldtype = 'Button' and parent = 'Customer'")
670 sql("delete from `tabField Mapper Detail` where parent = 'Sales Order-Delivery Note' and from_field = 'note' and to_field = 'note'")
671 elif patch_no == 152:
Nabin Hait31a407d2011-07-28 11:47:45 +0530672 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']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530673 elif patch_no == 153:
674 sql("delete from `tabDocField` where fieldname = 'sales_person' and parent = 'Customer'")
675 elif patch_no == 154:
Nabin Hait31a407d2011-07-28 11:47:45 +0530676 import_from_files(record_list=[['stock','doctype','serial_no'], ['support','doctype','customer_issue']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530677 elif patch_no == 155:
678 for d in sql("select name, item_code from `tabSerial No`"):
679 sql("COMMIT")
680 sql("START TRANSACTION")
681 sql("update `tabSerial No` set item_name = '%s' where name = '%s'" % (webnotes.conn.get_value('Item',cstr(d[1]),'item_name'), cstr(d[0])))
682 sql("COMMIT")
683 elif patch_no == 156:
684 sql("update tabDocField set fieldtype = 'Code' where fieldname = 'html' and parent = 'Print Format'")
685 elif patch_no == 157:
686 import_from_files(record_list=[['accounts', 'doctype', 'journal_voucher'], ['accounts', 'Print Format', 'Payment Receipt Voucher'], ['accounts', 'Print Format', 'Cheque Printing Format']])
687 elif patch_no == 158:
688 from webnotes.model.doc import addchild
689 sql("delete from tabDocField where parent = 'Customer Issue' and fieldname = 'customer_group'")
690 elif patch_no == 159:
691 sql("update tabAccount set account_type = 'Chargeable' where account_name in ('Advertising and Publicity', 'Freight & Forwarding Charges', 'Miscellaneous Expenses', 'Sales Promotion Expenses')")
692 elif patch_no == 160:
693 sql("update `tabDocType` set search_fields = 'posting_date, due_date, debit_to, fiscal_year, grand_total, outstanding_amount' where name = 'Receivable Voucher'")
694 sql("update `tabDocType` set search_fields = 'posting_date, credit_to, fiscal_year, bill_no, grand_total, outstanding_amount' where name = 'Payable Voucher'")
695 elif patch_no == 161:
696 sql("update tabDocType set autoname = 'field:batch_id' where name = 'Batch'")
697 sql("update tabDocField set no_copy = 1 where parent = 'Batch' and fieldname = 'batch_id'")
698 elif patch_no == 162:
Nabin Hait31a407d2011-07-28 11:47:45 +0530699 import_from_files(record_list=[['selling', 'search_criteria', 'sales_order_pending_items1']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530700 elif patch_no == 163:
701 sql("delete from `tabModule Def Item` where display_name = 'Sales Orderwise Pending Packing Item Summary' and parent = 'CRM'")
Nabin Hait31a407d2011-07-28 11:47:45 +0530702 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']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530703 elif patch_no == 164:
Nabin Hait31a407d2011-07-28 11:47:45 +0530704 import_from_files(record_list=[['buying', 'search_criteria', 'pending_po_items_to_receive'], ['buying', 'search_criteria', 'pending_po_items_to_bill']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530705 elif patch_no == 165:
706 pass
707 elif patch_no == 166:
Nabin Hait31a407d2011-07-28 11:47:45 +0530708 import_from_files(record_list=[['buying', 'doctype', 'purchase_order']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530709 elif patch_no == 167:
710 if webnotes.conn.get_value('Control Panel', None, 'account_id') not in ['ax0000956', 'ax0001338']:
711 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')")
712 elif patch_no == 168:
713 sql("update tabDocField set fieldtype = 'Data', options = 'Suggest' where fieldname = 'bank_name' and parent = 'Employee'")
714 elif patch_no == 169:
715 import_from_files(record_list=[['accounts', 'doctype', 'pv_detail'], ['accounts', 'doctype', 'rv_detail']])
716 elif patch_no == 170:
717 import_from_files(record_list=[['mapper', 'DocType Mapper', 'Delivery Note-Receivable Voucher']])
718 elif patch_no == 171:
Nabin Hait31a407d2011-07-28 11:47:45 +0530719 import_from_files(record_list=[['buying', 'doctype', 'supplier']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530720 elif patch_no == 172:
721 import webnotes
722 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>""")
723 webnotes.conn.set_global("system_message_id", "6")
724 elif patch_no == 173:
725 sql("delete from tabDocField where label = 'Get Other Charges' and parent = 'Delivery Note'")
726 sql("update tabDocField set reqd = 0 where fieldname = 'posting_time' and parent = 'Serial No'")
727 elif patch_no == 174:
728 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")
729 if c and cint(c[0][0]) > 1:
730 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")
731 elif patch_no == 175:
732 import webnotes
733 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>""")
734 webnotes.conn.set_global("system_message_id", "6")
735 elif patch_no == 176:
736 sql("update tabDocPerm set role='Guest', `write`=0, `create`=0 where role='Administrator' and parent='Notification Control' limit 1")
737 elif patch_no == 177:
738 sql("delete from `tabDocField` where label = 'Next Steps' and parent = 'Purchase Order'")
739 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'")
740 elif patch_no == 178:
Nabin Hait31a407d2011-07-28 11:47:45 +0530741 import_from_files(record_list = [['hr', 'doctype', 'salary_slip']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530742 elif patch_no == 179:
743 from webnotes.utils import get_defaults
744 sl = sql("select name, net_pay from `tabSalary Slip`")
745 for d in sl:
746 in_words = get_obj('Sales Common').get_total_in_words(get_defaults()['currency'], round(flt(d[1])))
747 sql("update `tabSalary Slip` set rounded_total = '%s', total_in_words = '%s' where name = '%s'" % (round(flt(d[1])), in_words, d[0]))
748 elif patch_no == 180:
749 sql("delete from tabDocField where parent = 'Salary Slip' and fieldname = 'net_pay_in_words'")
750 elif patch_no == 181:
751 import_from_files(record_list = [['accounts', 'doctype', 'journal_voucher']])
752 elif patch_no == 182:
753 sql("update tabDocField set options = CONCAT(options, '\nWrite Off Voucher') where fieldname = 'voucher_type' and parent = 'Journal Voucher'")
754 elif patch_no == 183:
755 sql("delete from tabDocField where label = 'SMS' and fieldtype = 'Section Break' and parent in ('Enquiry', 'Lead', 'Sales Order', 'Delivery Note')")
756 elif patch_no == 184:
757 from webnotes.model import delete_doc
758 delete_doc('DocType', 'Feed')
759 delete_doc('DocType', 'Feed List')
760 delete_doc('DocType', 'Feed Control')
761
762 # add trigger
763 from webnotes.model.triggers import add_trigger
764 add_trigger('*','*','*','event_updates.update_feed')
765
766 webnotes.conn.commit()
767
768 try:
769 sql("drop table tabFeed")
770 sql("drop table `tabFeed List`")
771 except: pass
772
773 # import
774 from webnotes.modules.module_manager import reload_doc
775 reload_doc('event_updates','doctype','feed')
776 elif patch_no==185:
777 sql("delete from tabDocTrigger where method = 'webnotes.widgets.follow.on_docsave'")
778 elif patch_no==186:
779 from webnotes.modules.module_manager import reload_doc
780 reload_doc('event_updates','doctype','feed')
781 elif patch_no == 187:
782 sql("update tabDocType set autoname = '' where name = 'QA Inspection Report'")
783 elif patch_no == 188:
Nabin Hait31a407d2011-07-28 11:47:45 +0530784 import_from_files(record_list = [['buying', 'doctype', 'qa_inspection_report']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530785 elif patch_no == 189:
786 sql("update `tabDocField` set allow_on_submit = 1 where fieldname in ('entries', 'other_charges') and parent = 'Receivable Voucher'")
787 elif patch_no == 190:
788 sql("update tabDocField set permlevel=0 where fieldname = 'fiscal_year' and parent = 'Stock Entry'")
789 elif patch_no == 191:
Nabin Hait31a407d2011-07-28 11:47:45 +0530790 import_from_files(record_list = [['support', 'doctype', 'customer_issue']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530791 elif patch_no == 192:
792 sql("delete from `tabModule Def Item` where parent = 'Material Management' and doc_name = 'Landed Cost Wizard' and display_name = 'Landed Cost Wizard'")
Nabin Hait31a407d2011-07-28 11:47:45 +0530793 import_from_files(record_list = [['buying', 'Module Def', 'SRM']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530794 elif patch_no == 193:
795 sql("update tabDocField set fieldtype='Button', `trigger`='Client' where parent='Letter Head' and fieldname='set_from_image'")
796 elif patch_no == 194:
797 sql("delete from `tabModule Def Item` where parent = 'SRM' and doc_name = 'Landed Cost Wizard' and display_name = 'Landed Cost Wizard'")
Nabin Hait31a407d2011-07-28 11:47:45 +0530798 import_from_files(record_list = [['stock', 'Module Def', 'Material Management']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530799 elif patch_no == 195:
800 from webnotes.modules.module_manager import reload_doc
801 reload_doc('setup','doctype','manage_account')
802 elif patch_no == 196:
803 sql("update `tabModule Def` set module_page = null where name = 'Material Management'")
804 elif patch_no == 197:
805 sql("update `tabDocField` set permlevel = 0, in_filter = 1 where fieldname = 'warranty_amc_status' and parent = 'Customer Issue'")
Nabin Hait31a407d2011-07-28 11:47:45 +0530806 import_from_files(record_list = [['support', 'doctype', 'customer_issue']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530807 elif patch_no == 198:
808 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')")
809 sql("delete from `tabDocField` where label in ('SMS', 'Send SMS') and parent = 'Purchase Order'")
810 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')")
811 from webnotes.model import delete_doc
812 delete_doc('DocType', 'Lead SMS Detail')
813 delete_doc('DocType', 'Enquiry SMS Detail')
814 elif patch_no == 199:
815 sql("update tabDocField set reqd = 0 where parent = 'Attendance' and fieldname = 'shifts'")
816 elif patch_no == 200:
817 reload_doc('event_updates','page','profile_settings')
818 elif patch_no == 201:
819 reload_doc('setup','doctype','price_list')
820 elif patch_no == 202:
821 name1 = sql("select name from tabDocField where parent='Price List' and label='Clear Prices' limit 1,1")
822 name2 = sql("select name from tabDocField where parent='Price List' and label='Update Prices' limit 1,1")
823 if name1:
824 sql("delete from tabDocField where name=%s limit 1", name1[0][0])
825 if name2:
826 sql("delete from tabDocField where name=%s limit 1", name2[0][0])
827 elif patch_no == 203:
828 sql("delete from tabDocField where parent = 'Company' and fieldname = 'default_salary_account' limit 1")
829 elif patch_no == 204:
830 sql("delete from tabDocField where parent = 'Company' and fieldname = 'default_salary_acount' limit 1")
831 elif patch_no == 205:
832 sql("update `tabDocField` set `default` = '' where fieldname = 'naming_series' and parent = 'Installation Note'")
833 elif patch_no == 206:
Nabin Hait31a407d2011-07-28 11:47:45 +0530834 reload_doc('selling','doctype','installation_note')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530835 elif patch_no == 207:
836 import_from_files(record_list = [['setup', 'doctype', 'company']])
837 elif patch_no == 208:
838 sql("delete from `tabDocField` where (label in ('SMS', 'Send SMS') or fieldname in ('message', 'customer_mobile_no')) and parent ='Quotation'")
839 default_currency = get_obj('Manage Account').doc.default_currency
840 sql("update tabCompany set default_currency = '%s'" % default_currency)
841 elif patch_no == 209:
842 import_from_files(record_list = [['setup', 'doctype', 'company']])
843 elif patch_no == 210:
844 sql("delete FROM `tabDocField` WHERE parent = 'Lead' AND label in ('CC:','Attachment Html','Create New File','Attachment')")
845 elif patch_no == 212:
846 # reload company because of disturbed UI
847 import_from_files(record_list = [['setup', 'doctype', 'company']])
848 elif patch_no == 213:
Nabin Hait31a407d2011-07-28 11:47:45 +0530849 reload_doc('selling','doctype','lead')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530850 reload_doc('setup','doctype','company')
851 elif patch_no == 214:
Nabin Hait31a407d2011-07-28 11:47:45 +0530852 reload_doc('selling','doctype','sales_order')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530853 elif patch_no == 215:
854 # patch for item and image in description
855 sql("update tabDocField set width = '300px' where fieldname='description'")
Nabin Hait31a407d2011-07-28 11:47:45 +0530856 reload_doc('stock', 'doctype', 'item')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530857 sql("delete from __DocTypeCache")
858 elif patch_no == 216:
Nabin Hait31a407d2011-07-28 11:47:45 +0530859 import_from_files(record_list = [['stock', 'doctype', 'serial_no'], ['stock', 'doctype', 'stock_ledger_entry']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530860 elif patch_no == 217:
861 sql("update tabDocField set options = '\nIn Store\nDelivered\nNot in Use' where fieldname = 'status' and parent = 'Serial No'")
862 sql("update tabDocField set no_copy = 1 where fieldname = 'serial_no' and parent = 'Delivery Note Detail'")
863 sql("update tabDocField set no_copy = 1 where fieldname = 'serial_no' and parent = 'Stock Entry Detail'")
864 elif patch_no == 218:
865 for d in sql("select name from `tabSerial No`"):
866 sql("Commit")
867 sql("Start Transaction")
868 s = Document('Serial No', d[0])
869 if s.pr_no:
870 s.purchase_document_type = 'Purchase Receipt'
871 s.purchase_document_no = s.pr_no
872 if s.delivery_note_no:
873 s.delivery_document_type = 'Delivery Note'
874 s.delivery_document_no = s.delivery_note_no
875 if s.notes:
876 s.delivery_note_no = s.notes
877 s.company = webnotes.utils.get_defaults()['company']
878 s.fiscal_year = webnotes.utils.get_defaults()['fiscal_year']
879 s.save()
880 elif patch_no == 219:
881 sql("delete from tabDocField where fieldname in ('pr_no', 'make', 'label', 'delivery_note_no', 'notes') and parent = 'Serial No'")
882 elif patch_no == 220:
883 sql("update tabDocField set label = 'Incoming Rate' where fieldname = 'purchase_rate' and parent = 'Serial No'")
884 sql("update tabDocField set label = 'Incoming Time' where fieldname = 'purchase_time' and parent = 'Serial No'")
885 elif patch_no == 221:
886 sql("update tabDocField set reqd = 1 where fieldname in ('purchase_rate', 'warehouse') and parent = 'Serial No'")
887 elif patch_no == 222:
888 sql("update tabDocField set options = '\nDelivery Note\nReceivable Voucher\nStock Entry' where fieldname = 'delivery_document_type' and parent = 'Serial No'")
889 elif patch_no == 223:
890 sql("update tabDocField set hidden = 0 where fieldname in ('pay_to_recd_from', 'total_amount', 'total_amount_in_words') and parent = 'Journal Voucher'")
891 sql("update tabDocField set permlevel = 0 where fieldname = 'pay_to_recd_from' and parent = 'Journal Voucher'")
892 elif patch_no == 224:
Nabin Hait31a407d2011-07-28 11:47:45 +0530893 import_from_files(record_list = [['stock', 'doctype', 'delivery_note_packing_detail'], ['accounts', 'Print Format', 'Payment Receipt Voucher']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530894 elif patch_no == 225:
Nabin Hait31a407d2011-07-28 11:47:45 +0530895 import_from_files(record_list = [['stock', 'doctype', 'delivery_note_packing_detail']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530896 elif patch_no == 226:
Nabin Hait31a407d2011-07-28 11:47:45 +0530897 import_from_files(record_list = [['stock', 'doctype', 'delivery_note_packing_detail']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530898 elif patch_no == 227:
Nabin Hait31a407d2011-07-28 11:47:45 +0530899 reload_doc('stock', 'doctype', 'item')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530900 if webnotes.conn.get_value('Control Panel', None, 'account_id') != 'axjanak2011':
901 sql("delete from tabDocField where parent = 'Item' and fieldname='alternate_description' limit 1")
902 elif patch_no == 228:
903 # knowledge base patch
904 reload_doc('knowledge_base', 'doctype', 'question')
905 reload_doc('knowledge_base', 'doctype', 'answer')
906 reload_doc('knowledge_base', 'page', 'questions')
907 reload_doc('knowledge_base', 'Module Def', 'Knowledge Base')
908 sql("update `tabModule Def` set disabled='No' where name='Knowledge Base'")
Brahma K09307622011-07-27 12:03:34 +0530909 elif patch_no == 229:
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530910 reload_doc('knowledge_base', 'page', 'question_view')
911 elif patch_no == 230:
Nabin Hait31a407d2011-07-28 11:47:45 +0530912 reload_doc('buying', 'doctype', 'indent')
913 reload_doc('buying', 'doctype', 'indent_detail')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530914 reload_doc('Mapper', 'DocType Mapper', 'Sales Order-Indent')
915 elif patch_no == 231:
916 reload_doc('Mapper', 'DocType Mapper', 'Sales Order-Indent')
917 elif patch_no == 232:
918 sql("update `tabDocField` set options = 'Sales Order' where fieldname = 'sales_order_no' and parent = 'Indent'")
919 elif patch_no == 233:
920 reload_doc('Mapper', 'DocType Mapper', 'Sales Order-Receivable Voucher')
921 reload_doc('Mapper', 'DocType Mapper', 'Delivery Note-Receivable Voucher')
922 elif patch_no == 234:
923 sql("update `tabTable Mapper Detail` set validation_logic = 'docstatus=1' where parent = 'Sales Order-Indent' and from_table = 'Sales Order Detail'")
924 elif patch_no == 235:
Brahma K09307622011-07-27 12:03:34 +0530925 for sc in sql("""select name from `tabSearch Criteria` where ifnull(name,'')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530926 like 'srch%' or ifnull(name,'') like '%stdsrch'"""):
927 try:
928 get_obj('Search Criteria', sc[0]).rename()
929 except AttributeError, e:
930 pass
931 reload_doc('core', 'doctype', 'system_console')
932 elif patch_no == 236:
933 # warehouse not mandatory for delivered serial nos
934 sql("update tabDocField set reqd=0 where parent='Serial No' and fieldname='warehouse'")
935 elif patch_no == 237:
936 sql("update tabDocField set depends_on = 'eval:doc.is_pos==1' where fieldname = 'cash_bank_account' and parent = 'Receivable Voucher'")
937 elif patch_no == 238:
938 reload_doc('accounts', 'doctype', 'receivable_voucher')
939 reload_doc('accounts', 'GL Mapper', 'POS with write off')
940 elif patch_no == 239:
941 reload_doc('core', 'doctype', 'docfield')
942 reload_doc('core', 'doctype', 'doctype')
Nabin Hait31a407d2011-07-28 11:47:45 +0530943 from patches.old_patches.feed_patch import set_subjects_and_tagfields
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530944 set_subjects_and_tagfields()
945 elif patch_no == 240:
946 # again for sales order (status)
Nabin Hait31a407d2011-07-28 11:47:45 +0530947 from patches.old_patches.feed_patch import set_subjects_and_tagfields
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530948 set_subjects_and_tagfields()
949 elif patch_no == 241:
950 sql("update `tabDocField` set fieldtype = 'Text', options = '', in_filter = '' where fieldname = 'serial_no' and parent = 'Stock Ledger Entry'")
951 elif patch_no == 242:
952 if webnotes.conn.get_value('Control Panel', None, 'account_id') not in ['axjanak2011']:
953 sql("commit")
954 try:
955 sql("alter table `tabStock Ledger Entry` drop index serial_no")
956 except:
957 pass
958
959 sql("alter table `tabStock Ledger Entry` change serial_no serial_no text")
960 elif patch_no == 243:
961 # moving custom script and custom fields to framework
962 webnotes.conn.set_value('DocType', 'Custom Script', 'module', 'Core')
963 webnotes.conn.set_value('DocType', 'Custom Field', 'module', 'Core')
964 reload_doc('setup', 'doctype', 'company')
965 elif patch_no == 244:
Nabin Hait31a407d2011-07-28 11:47:45 +0530966 reload_doc('stock', 'search_criteria', 'shortage_to_indent')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530967 elif patch_no == 245:
Nabin Hait31a407d2011-07-28 11:47:45 +0530968 from patches.old_patches.doctype_permission_patch import set_doctype_permissions
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530969 set_doctype_permissions()
970
Nabin Hait31a407d2011-07-28 11:47:45 +0530971 from patches.old_patches.feed_patch import set_subjects_and_tagfields
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530972 set_subjects_and_tagfields()
973 elif patch_no == 246:
974 webnotes.conn.set_value('DocType','Stock Entry','tag_fields','purpose')
975 webnotes.conn.set_value('DocType','Stock Entry','subject','%(remarks)s')
976 elif patch_no == 247:
977 webnotes.conn.set_value('DocType','Stock Entry','subject','%(remarks)s')
978 elif patch_no == 248:
979 reload_doc('setup', 'doctype', 'manage_account')
980 elif patch_no == 249:
981 sql("update `tabDocPerm` t1, `tabDocType` t2 set t1.role = 'System Manager' where t1.role = 'Administrator' and t1.parent = t2.name and t2.module != 'Core'")
982 elif patch_no == 250:
Nabin Hait31a407d2011-07-28 11:47:45 +0530983 from patches.old_patches.feed_patch import support_patch
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530984 support_patch()
985 elif patch_no == 251:
986 from webnotes.model import db_schema
987 db_schema.remove_all_foreign_keys()
Nabin Hait31a407d2011-07-28 11:47:45 +0530988 from patches.old_patches.customer_address import run_patch
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530989 run_patch()
990 elif patch_no == 252:
Nabin Hait31a407d2011-07-28 11:47:45 +0530991 reload_doc('support','doctype','support_ticket')
992 reload_doc('support','doctype','support_ticket_response')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530993 elif patch_no == 253:
994 reload_doc('accounts','doctype','ledger_balance_export')
995 reload_doc('accounts','doctype','ledger_detail')
996 reload_doc('accounts', 'Module Def', 'Accounts')
997
998 from webnotes.model.db_schema import updatedb
999 updatedb('Ledger Balance Export')
1000 updatedb('Ledger Detail')
1001 elif patch_no == 254:
Nabin Hait31a407d2011-07-28 11:47:45 +05301002 reload_doc('setup', 'doctype', 'sms_settings')
1003 reload_doc('setup', 'doctype', 'static_parameter_detail')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301004
1005 from webnotes.model.db_schema import updatedb
1006 updatedb('SMS Settings')
1007 updatedb('Static Parameter Detail')
1008 elif patch_no == 255:
Nabin Hait31a407d2011-07-28 11:47:45 +05301009 from patches.old_patches.customer_address import run_old_data_sync_patch
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301010 run_old_data_sync_patch()
1011 elif patch_no == 256:
1012 sql("update `tabLetter Head` set content = replace(content, 'http://46.4.50.84/v170-test/', '')")
1013 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'")
1014 sql("update `tabItem` set description_html = replace(description_html, 'http://46.4.50.84/v170-test/', '')")
1015 elif patch_no == 257:
Nabin Hait31a407d2011-07-28 11:47:45 +05301016 from patches.old_patches.customer_address import run_old_data_sync_patch
Brahma K09307622011-07-27 12:03:34 +05301017 run_old_data_sync_patch()
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301018 elif patch_no == 258:
1019 sql("update tabDocField set `default`=NULL where fieldname = 'naming_series'")
1020 elif patch_no == 259:
1021 sql("update `tabQuotation Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1022 sql("update `tabSales Order Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1023 sql("update `tabRV Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1024 sql("update `tabDelivery Note Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1025 elif patch_no == 260:
1026 sql("update `tabLetter Head` set content = replace(content, 'http://46.4.50.84/v170/', '')")
1027 sql("update `tabSingles` set value = replace(value, 'http://46.4.50.84/v170/', '') where field in ('letter_head', 'client_name') and doctype = 'Control Panel'")
1028 sql("update `tabItem` set description_html = replace(description_html, 'http://46.4.50.84/v170/', '')")
1029 sql("update `tabQuotation Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1030 sql("update `tabSales Order Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1031 sql("update `tabRV Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1032 sql("update `tabDelivery Note Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1033 elif patch_no == 261:
1034 sql("update `tabPrint Format` set html = replace(html, 'customer_address', 'address_display')")
1035 elif patch_no == 262:
Nabin Hait31a407d2011-07-28 11:47:45 +05301036 from patches.old_patches.customer_address import sync_lead_phone
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301037 sync_lead_phone()
1038 elif patch_no == 263:
1039 ol = ['','Open','To Reply','Waiting for Customer','Hold','Closed']
1040 sql("update tabDocField set options=%s where parent=%s and fieldname=%s", ('\n'.join(ol), 'Support Ticket', 'status'))
Brahma K09307622011-07-27 12:03:34 +05301041 elif patch_no == 264:
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301042 sql("delete from tabDocField where parent = 'Customer Issue' and (fieldname = 'issue_in' or fieldname = 'issue_category')")
1043 sql("update tabDocField set options=NULL where parent='Support Ticket' and label = 'Send'")
1044 elif patch_no == 266:
1045 reload_doc('setup','doctype','support_email_settings')
1046 elif patch_no == 267:
1047 sql("update `tabPrint Format` set html = replace(html, 'supplier_address', 'address_display')")
1048 elif patch_no == 268:
1049 sql("update `tabDocPerm` set permlevel = 0 where permlevel is null")
1050 elif patch_no == 269:
1051 p = get_obj('Patch Util')
1052 p.add_permission('GL Entry', 'Accounts User', 0, read = 1)
1053 elif patch_no == 270:
1054 pages = ['Accounts Setup', 'Accounts', 'Accounting Reports','GeneralLedger','How do I - Accounts','Making Opening Entries',\
1055 'Analysis','How do I - CRM','How do I - Inventory','Inventory Setup', 'Stock','HR','HR & Payroll Setup',\
1056 'Payroll Setup','Production Setup','Production','Buying','SRM Setup','Contact Page','Forum','Messages','Test Toolbar',\
1057 'Trend Analyzer']
1058 from webnotes.model import delete_doc
1059 sql("delete from `tabPage Visit`")
1060 for p in pages:
1061 try: delete_doc('Page', p)
1062 except: pass
1063 elif patch_no == 271:
1064 # tags patch
Nabin Hait31a407d2011-07-28 11:47:45 +05301065 reload_doc('selling','doctype','sales_order')
1066 reload_doc('stock','doctype','delivery_note')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301067 sql("delete from tabDocField where fieldname='per_amt_billed' and parent in ('Sales Order', 'Delivery Note')")
Brahma K09307622011-07-27 12:03:34 +05301068
1069 sql("""update `tabSales Order` set delivery_status = if(ifnull(per_delivered,0) < 0.001, 'Not Delivered',
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301070 if(per_delivered >= 99.99, 'Fully Delivered', 'Partly Delivered'))""")
Brahma K09307622011-07-27 12:03:34 +05301071 sql("""update `tabSales Order` set billing_status = if(ifnull(per_billed,0) < 0.001, 'Not Billed',
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301072 if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""")
Brahma K09307622011-07-27 12:03:34 +05301073 sql("""update `tabDelivery Note` set billing_status = if(ifnull(per_billed,0) < 0.001, 'Not Billed',
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301074 if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""")
1075 elif patch_no == 272:
1076 from webnotes.model import delete_doc
1077 try:
1078 delete_doc('Search Criteria', '_SRCH00003')
1079 except:
1080 pass
1081 reload_doc('accounts', 'search_criteria', 'purchase_register')
1082 elif patch_no == 276:
1083 from webnotes.model import delete_doc
1084 sn = sql("select name from `tabSearch Criteria` where criteria_name = 'Sales Personwise Transaction Summary'")
1085 for d in sn:
1086 delete_doc('Search Criteria', d[0])
Nabin Hait31a407d2011-07-28 11:47:45 +05301087 reload_doc('selling', 'search_criteria', 'sales_personwise_transaction_summary')
nabinhaite0250fb2011-06-14 13:35:31 +05301088 elif patch_no == 277:
1089 webnotes.model.delete_doc('DocType','HomePage Settings')
1090 webnotes.model.delete_doc('DocType','Badge Settings')
1091 sql("update tabDocType set module='Home' where module in ('Event Updates', 'My Company')")
1092 sql("update tabPage set module='Home' where module in ('Event Updates', 'My Company')")
1093 sql("update `tabSearch Criteria` set module='Home' where module in ('Event Updates', 'My Company')")
1094
1095
1096 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')
1097 for p in delete_pages:
1098 webnotes.model.delete_doc('Page',p)
nabinhaitb7789a52011-06-14 17:33:12 +05301099 elif patch_no == 278:
1100 sql("update tabDocTrigger set method = 'home.update_feed' where method = 'event_updates.update_feed'")
nabinhaitc43ece72011-06-15 11:55:32 +05301101 elif patch_no == 279:
1102 dt = ['GL Entry', 'Stock Ledger Entry']
1103 for t in dt:
1104 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)
1105 for d in rec:
1106 sql("update `tab%s` set docstatus = %s where name = '%s'" % (d[0], d[2]=='No' and 1 or 2, d[1]))
Brahma K09307622011-07-27 12:03:34 +05301107
nabinhaitc43ece72011-06-15 11:55:32 +05301108 other_dt = ['Enquiry', 'Quotation', 'Sales Order', 'Indent', 'Purchase Order', 'Production Order', 'Customer Issue', 'Installation Note']
1109 for dt in other_dt:
1110 rec = sql("select name, status from `tab%s` where modified >= '2011-06-15 01:00:00'" % dt)
1111 for r in rec:
1112 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 +05301113 elif patch_no == 280:
1114 reload_doc('accounts', 'doctype', 'form_16a')
nabinhaite7221212011-06-15 14:39:31 +05301115 elif patch_no == 281:
1116 dt_list = ['Delivery Note', 'Purchase Receipt']
1117 for dt in dt_list:
nabinhaite7221212011-06-15 14:39:31 +05301118 sql("update `tab%s` set status = 'Submitted' where docstatus = 1 and modified >='2011-06-15 01:00:00'" % dt)
1119 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 +05301120 elif patch_no == 282:
1121 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']
1122 for d in dt_list:
1123 tbl = sql("select options from `tabDocField` where fieldtype = 'Table' and parent = '%s'" % d)
1124 for t in tbl:
1125 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 +05301126 elif patch_no == 283:
1127 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")
1128 for d in rec:
1129 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 +05301130 elif patch_no == 284:
Nabin Hait31a407d2011-07-28 11:47:45 +05301131 reload_doc('support', 'doctype', 'support_ticket')
nabinhaitf7d80002011-06-20 13:51:26 +05301132 sql("update `tabDocField` set in_filter = 1 where fieldname in ('raised_by', 'subject') and parent = 'Support Ticket'")
nabinhait6150e652011-06-20 16:34:48 +05301133 elif patch_no == 286:
nabinhait4b59bea2011-06-20 14:07:04 +05301134 reload_doc('accounts', 'search_criteria', 'itemwise_sales_register')
1135 reload_doc('accounts', 'search_criteria', 'itemwise_purchase_register')
nabinhait58f01022011-06-21 15:05:43 +05301136 elif patch_no == 287:
nabinhait8b849fe2011-06-21 15:09:55 +05301137 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 +05301138 elif patch_no == 288:
1139 reload_doc('accounts', 'doctype', 'payable_voucher')
nabinhait33dee782011-06-21 17:17:39 +05301140 elif patch_no == 289:
1141 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'")
Brahma K09307622011-07-27 12:03:34 +05301142 sql("update `tabDocType` set search_fields = 'status,transaction_date,customer,lead,order_type' where name = 'Quotation'")
Anand Doshib9f7e392011-06-22 12:11:47 +05301143 elif patch_no == 290:
Brahma K09307622011-07-27 12:03:34 +05301144 count = sql("""SELECT * FROM `tabModule Def`
Anand Doshib9f7e392011-06-22 12:11:47 +05301145 WHERE `module_name` LIKE 'Home'""")
1146 if not count:
1147 md = Document('Module Def')
1148 md.module_name = 'Home'
1149 md.module_label = 'Home'
Rushabh Mehta64b6c2c2011-06-22 16:38:11 +05301150 md.save(1)
1151 elif patch_no == 291:
Nabin Hait31a407d2011-07-28 11:47:45 +05301152 reload_doc('utilities','doctype','rename_tool')
nabinhaitaeee6ba2011-06-22 18:25:29 +05301153 elif patch_no == 292:
1154 reload_doc('accounts', 'search_criteria', 'trial_balance')
Ravi Dey560ee3d2011-06-23 13:03:24 +05301155 elif patch_no == 293:
1156 sql("delete from tabDocField where parent='Account' and fieldname='address'")
1157 reload_doc('accounts', 'doctype', 'account')
Rushabh Mehta3e037432011-06-23 22:47:04 +05301158 elif patch_no == 294:
1159 # new account profile fix
1160 ul = sql("select name from tabProfile where ifnull(name,'') not in ('Administrator', 'Guest', '')")
1161 # if one user and one user has no roles
1162 if len(ul)==1 and not sql("select parent from tabUserRole where role='System Manager' and parent=%s", ul[0][0]):
1163 get_obj('Setup Control').add_roles(Document('Profile', ul[0][0]))
Ravi Dey0b6c5652011-06-24 14:44:21 +05301164 elif patch_no == 295:
1165 sql("update `tabDocField` set options = 'Delivered\nNot Delivered\nPartly Delivered\nClosed\nNot Applicable' where parent = 'Sales Order' and fieldname = 'delivery_status'")
1166 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 +05301167 elif patch_no == 296:
Ravi Dey26c160f2011-06-24 15:53:51 +05301168 sql("delete from tabDocField where parent='Support Ticket' and fieldname='contact_no'")
Nabin Hait31a407d2011-07-28 11:47:45 +05301169 reload_doc('support', 'doctype', 'support_ticket')
Ravi Dey74c9c4d2011-06-27 11:26:39 +05301170 elif patch_no == 297:
Nabin Hait31a407d2011-07-28 11:47:45 +05301171 reload_doc('hr', 'doctype', 'employee')
1172 reload_doc('hr', 'doctype', 'attendance')
1173 reload_doc('hr', 'doctype', 'expense_voucher')
1174 reload_doc('hr', 'doctype', 'appraisal')
1175 reload_doc('hr', 'doctype', 'salary_structure')
1176 reload_doc('hr', 'doctype', 'salary_slip')
Ravi Dey48671df2011-06-27 12:03:36 +05301177 elif patch_no == 298:
Ravi Dey94a332a2011-07-01 13:50:34 +05301178 sql("update `tabDocField` set options = 'link:Company' where parent = 'Attendance' and fieldname = 'company'")
1179 sql("update `tabDocField` set options = 'link:Company' where parent = 'Expense Voucher' and fieldname = 'company'")
1180 sql("update `tabDocField` set options = 'link:Company' where parent = 'Appraisal' and fieldname = 'company'")
Ravi Dey8d3f4b62011-06-27 12:48:56 +05301181 elif patch_no == 299:
1182 sql("update `tabDocPerm` set `match` = NULL where parent = 'Employee' and role = 'Employee'")
nabinhait690c6972011-06-28 14:42:07 +05301183 elif patch_no == 300:
Anand Doshib74eec82011-06-28 13:42:08 +05301184 sql("""DELETE FROM `tabSearch Criteria` WHERE name IN
1185 ('sales_register1', 'sales_register2', 'purchase_register1')""")
nabinhait78f5bf62011-06-28 16:21:58 +05301186 elif patch_no == 301:
nabinhait690c6972011-06-28 14:42:07 +05301187 from patches.delivery_billing_status_patch import run_patch
1188 run_patch()
nabinhaitb3930002011-06-28 16:50:38 +05301189 elif patch_no == 302:
1190 sql("update `tabDocField` set no_copy = 1 where fieldname = 'naming_series'")
Ravi Dey4c651192011-06-28 19:36:18 +05301191 elif patch_no == 303:
Ravi Dey27c5b402011-06-29 18:05:18 +05301192 pass
1193 elif patch_no == 304:
Rushabh Mehtac71eeb62011-06-30 08:28:36 +05301194 sql("delete from `tabDocField` where parent = 'company' and label = 'Trash Company' and fieldtype = 'button'")
Ravi Deyc674e432011-06-29 18:15:12 +05301195 reload_doc('setup', 'doctype', 'company')
Ravi Dey79c28652011-06-29 18:55:19 +05301196 elif patch_no == 305:
1197 sql("update `tabDocField` set options = 'link:Company' where options='link:Company' and fieldname='company' and fieldtype='Select'")
nabinhaitec097972011-07-01 13:34:41 +05301198 elif patch_no == 306:
Ravi Dey94a332a2011-07-01 13:50:34 +05301199 sql("update `tabDocField` set options = '\nAccount\nCompany\nCustomer\nSupplier\nEmployee\nWarehouse\nItem' where parent = 'Rename Tool' and fieldname = 'select_doctype'")
1200 sql("update `tabDocField` set options = 'link:Item' where parent = 'Raw Materials Supplied' and fieldname = 'po_item'")
1201 sql("update `tabDocField` set options = 'Sales Order' where parent = 'Indent Detail' and fieldname = 'sales_order_no'")
1202 sql("update `tabDocField` set options = 'link:Company', fieldtype = 'Select' where parent = 'Stock Ledger Entry' and fieldname = 'company'")
Nabin Hait31a407d2011-07-28 11:47:45 +05301203 reload_doc('utilities', 'doctype', 'rename_tool')
Ravi Dey627d01b2011-07-01 14:05:43 +05301204 elif patch_no == 307:
1205 sql("delete from `tabDocField` where parent = 'company' and label = 'Trash Company' and fieldtype = 'Button'")
1206 reload_doc('setup', 'doctype', 'company')
nabinhaita56fc002011-07-01 16:32:03 +05301207 elif patch_no == 308:
Ravi Deyc1886b52011-07-04 16:53:42 +05301208 sql("update `tabDocField` set reqd = 0 where fieldname = 'select_item' and parent = 'Property Setter'")
nabinhait1bd56b12011-07-05 14:41:36 +05301209 elif patch_no == 309:
1210 sql("delete from `tabDocField` where fieldname = 'item_attachments_details' and parent = 'Item'")
nabinhait7f339e02011-07-05 15:43:17 +05301211 sql("delete from `tabModule Def Item` where parent = 'Stock' and doc_name = 'Landed Cost Wizard'")
nabinhait5deab242011-07-06 09:23:02 +05301212 elif patch_no == 310:
1213 from erpnext_structure_cleanup import run_patches
1214 run_patches()
nabinhait4bb8bf42011-07-06 10:11:11 +05301215 elif patch_no == 311:
1216 sql("update `tabDocField` set reqd = 0 where fieldname = 'select_item' and parent = 'Property Setter'")
nabinhait4c38fbb2011-07-06 10:36:53 +05301217 #reload_doc('core', 'doctype', 'property_setter')
nabinhait4bb8bf42011-07-06 10:11:11 +05301218 elif patch_no == 312:
1219 sql("delete from `tabSessions`")
1220 sql("delete from `__SessionCache`")
nabinhaitd54ec522011-07-06 12:20:21 +05301221 elif patch_no == 313:
1222 dt = ['GL Entry', 'Stock Ledger Entry']
1223 for t in dt:
1224 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)
1225 for d in rec:
nabinhaitfccbb092011-07-06 12:23:27 +05301226 sql("update `tab%s` set docstatus = %s where name = '%s'" % (d[0], d[2]=='No' and 1 or 2, d[1]))
Brahma K09307622011-07-27 12:03:34 +05301227
nabinhaitd54ec522011-07-06 12:20:21 +05301228 other_dt = ['Enquiry', 'Quotation', 'Sales Order', 'Indent', 'Purchase Order', 'Production Order', 'Customer Issue', 'Installation Note']
1229 for dt in other_dt:
1230 rec = sql("select name, status from `tab%s` where modified >= '2011-07-06 10:00:00'" % dt)
1231 for r in rec:
1232 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]))
Brahma K09307622011-07-27 12:03:34 +05301233
1234
nabinhaitd54ec522011-07-06 12:20:21 +05301235 dt_list = ['Delivery Note', 'Purchase Receipt']
1236 for dt in dt_list:
1237 sql("update `tab%s` set status = 'Submitted' where docstatus = 1 and modified >='2011-07-06 10:00:00'" % dt)
1238 sql("update `tab%s` set status = 'Cancelled' where docstatus = 2 and modified >='2011-07-06 10:00:00'" % dt)
1239
1240 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']
1241 for d in dt_list:
1242 tbl = sql("select options from `tabDocField` where fieldtype = 'Table' and parent = '%s'" % d)
1243 for t in tbl:
1244 sql("update `tab%s` t1, `tab%s` t2 set t1.docstatus = t2.docstatus where t1.parent = t2.name" % (t[0], d))
Brahma K09307622011-07-27 12:03:34 +05301245
nabinhait22f7edd2011-07-06 12:45:02 +05301246 elif patch_no == 314:
1247 # delete double feed
1248 sql("delete from tabFeed where subject like 'New %'")
nabinhaiteb315402011-07-06 13:03:31 +05301249 elif patch_no == 315:
1250 # delete double feed
1251 sql("delete from tabFeed where doc_name like 'New %'")
1252 reload_doc('core', 'doctype', 'property_setter')
1253
1254 from webnotes.model.doc import Document
1255 m = Document('Module Def Role')
1256 m.role = 'All'
1257 m.parent = 'Home'
1258 m.parenttype = 'Module Def'
1259 m.parentfield = 'roles'
1260 m.save(1)
Ravi Dey7a6211d2011-07-07 15:49:24 +05301261 elif patch_no == 316:
Ravi Dey89822722011-07-07 15:52:35 +05301262 pass
1263 elif patch_no == 317:
Brahma K09307622011-07-27 12:03:34 +05301264 sql("update `tabPage` set name = 'profile-settings' where page_name = 'Profile Settings'")
Anand Doshi56ab7e42011-07-07 18:37:58 +05301265 elif patch_no == 318:
Ravi Deycfc5dff2011-07-07 16:48:54 +05301266 reload_doc('utilities', 'doctype', 'bulk_rename_tool')
Anand Doshi52b1d5a2011-07-07 18:41:12 +05301267 elif patch_no == 319:
Anand Doshi56ab7e42011-07-07 18:37:58 +05301268 sql("delete from tabFeed where doc_name like 'New %'")
nabinhait63cf2b92011-07-08 13:30:46 +05301269 elif patch_no == 320:
1270 reload_doc('setup', 'doctype', 'series_detail')
Ravi Deyfac96e12011-07-08 13:38:16 +05301271 elif patch_no == 321:
Ravi Dey84913842011-07-08 13:46:09 +05301272 reload_doc('hr','doctype','leave_application')
1273 elif patch_no == 322:
1274 sql("delete from `tabDocField` where parent = 'Leave Application' and fieldname = 'latter_head'")
Nabin Hait2acac4b2011-07-10 13:52:05 +05301275 elif patch_no == 323:
1276 reload_doc('stock', 'doctype', 'stock_entry')
Nabin Haite079a6e2011-07-10 14:15:52 +05301277 sql("update `tabDocField` set options = 'get_stock_and_rate' where parent = 'Stock Entry' and label = 'Get Stock and Rate'")
1278 sql("delete from `tabDocField` where label = 'Get Current Stock' and parent = 'Stock Entry'")
nabinhait54b0e7d2011-07-13 16:40:03 +05301279 elif patch_no == 324:
1280 sql("delete from `tabDocField` where fieldname = 'test_field' and parent = 'Customer'")
Ravi Dey9dd0c0b2011-07-13 18:08:38 +05301281 elif patch_no == 325:
1282 sql("update `tabDocField` set fieldtype = 'Data' where parent = 'Salary Slip' and fieldname = 'total_days_in_month'")
1283 reload_doc('hr', 'doctype', 'salary_slip')
Rushabh Mehta61790802011-07-17 10:52:47 +05301284 elif patch_no == 326:
1285 # load the new billing page
1286 if cint(webnotes.conn.get_value('Control Panel',None,'sync_with_gateway')):
1287 reload_doc('server_tools','page','billing')
nabinhaite6526362011-07-19 18:09:26 +05301288 elif patch_no == 327:
Rushabh Mehta391aa022011-07-25 14:07:50 +05301289 # patch for support email settings now moved to email settings
1290 reload_doc('setup','doctype','email_settings')
Brahma K09307622011-07-27 12:03:34 +05301291
Rushabh Mehta391aa022011-07-25 14:07:50 +05301292 # map fields from support to email settings
1293 field_map = {
1294 'support_email': 'email',
1295 'support_host':'host',
1296 'support_username': 'username',
1297 'support_password': 'password',
Rushabh Mehtab7186d42011-07-25 14:37:48 +05301298 'support_use_ssl': 'use_ssl',
Rushabh Mehta391aa022011-07-25 14:07:50 +05301299 'sync_support_mails': 'integrate_incoming',
1300 'signature': 'support_signature'
1301 }
Brahma K09307622011-07-27 12:03:34 +05301302
Rushabh Mehta391aa022011-07-25 14:07:50 +05301303 for key in field_map:
1304 webnotes.conn.set_value('Email Settings',None,key, \
1305 webnotes.conn.get_value('Support Email Settings',None,field_map[key]))
Brahma K09307622011-07-27 12:03:34 +05301306
Rushabh Mehta391aa022011-07-25 14:07:50 +05301307 # delete support email settings
1308 from webnotes.model import delete_doc
1309 delete_doc('DocType', 'Support Email Settings')
1310
Rushabh Mehta9b8fad22011-07-25 14:45:42 +05301311 reload_doc('support','doctype','support_ticket')
Nabin Hait587ac5c2011-07-26 15:46:10 +05301312 sql("delete from tabDocField where fieldname='problem_description' and parent='Support Ticket'")
1313 elif patch_no == 328:
nabinhaite6526362011-07-19 18:09:26 +05301314 if webnotes.conn.get_value('Control Panel', None, 'account_id') != 'axjanak2011':
1315 sql("delete from `tabDocField` where fieldname = 'supplier_status' and parent = 'Supplier'")
Nabin Hait587ac5c2011-07-26 15:46:10 +05301316 elif patch_no == 329:
nabinhaitde9826c2011-07-20 18:02:59 +05301317 reload_doc('utilities', 'doctype', 'rename_tool')
1318 reload_doc('utilities', 'doctype', 'bulk_rename_tool')
Brahma K09307622011-07-27 12:03:34 +05301319 elif patch_no == 330:
1320 reload_doc('accounts', 'doctype', 'lease_agreement')
1321 reload_doc('accounts', 'doctype', 'lease_installment')
1322
1323 reload_doc('accounts', 'search_criteria', 'lease_agreement_list')
1324 reload_doc('accounts', 'search_criteria', 'lease_monthly_future_installment_inflows')
1325 reload_doc('accounts', 'search_criteria', 'lease_overdue_age_wise')
Nabin Haitf541b742011-07-28 15:33:42 +05301326 reload_doc('accounts', 'search_criteria', 'lease_over_due_list')
Brahma K09307622011-07-27 12:03:34 +05301327 reload_doc('accounts', 'search_criteria', 'lease_receipts_client_wise')
1328 reload_doc('accounts', 'search_criteria', 'lease_receipt_summary_year_to_date')
1329 reload_doc('accounts', 'search_criteria', 'lease_yearly_future_installment_inflows')
Brahma Kbcdade52011-07-27 12:11:09 +05301330
1331 reload_doc('accounts', 'Module Def', 'Accounts')
Brahma K3b1ebe02011-07-27 13:04:11 +05301332 elif patch_no == 331:
1333 p = get_obj('Patch Util')
1334 # permission
1335 p.add_permission('Lease Agreement', 'Accounts Manager', 0, read = 1, write=1,submit=1, cancel=1,amend=1)
1336 p.add_permission('Lease Agreement', 'Accounts Manager', 1, read = 1)
Nabin Haitd29916b2011-07-27 14:26:23 +05301337 elif patch_no == 332:
1338 sql("update `tabDocField` set permlevel=1, hidden = 1 where parent = 'Bulk Rename Tool' and fieldname = 'file_list'")
Nabin Hait812e7182011-08-05 11:10:30 +05301339 elif patch_no == 333:
1340 sql("update `tabDocPerm` set create =1 where role = 'Accounts Manager' and parent = 'Lease Agreement'")
1341
1342 p = get_obj('Patch Util')
1343 p.add_permission('DocType Mapper', 'System Manager', 0, read = 1, write=1, create=1)
1344 p.add_permission('Role', 'System Manager', 0, read = 1, write=1, create=1)
1345 p.add_permission('Print Format', 'System Manager', 0, read = 1, write=1, create=1)
Nabin Haitc4e579c2011-08-05 11:21:35 +05301346 elif patch_no == 334:
1347 reload_doc('knowledge_base', 'doctype', 'answer')