blob: cd68b13e21a536bdc8df59899b793202838a8f4e [file] [log] [blame]
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301# REMEMBER to update this
2# ========================
nabinhaita56fc002011-07-01 16:32:03 +05303
Anand Doshiaabf1742011-08-10 13:27:25 +05304last_patch = 337
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:
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +053059 import_from_files(record_list=[['material_management','doctype','item']])
Rushabh Mehta542da5e2011-08-02 13:31:59 +053060
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +053061 elif patch_no == 42:
62 acc = sql("select name, lft, rgt from tabAccount where account_name in ('Incomes', 'Expenses')")
63 for d in acc:
64 sql("update tabAccount set is_pl_account = 'Yes' where lft >= '%s' and rgt <= '%s'" % (d[1], d[2]))
65 elif patch_no == 43:
66 import webnotes.model
67 webnotes.model.delete_doc('Page', 'Module Manager')
Brahma K09307622011-07-27 12:03:34 +053068
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +053069 # cleanup of Service, Customer Support, Utilities Modules
70 # -------------------------------------------------------
71 elif patch_no == 44:
72 from webnotes.model import delete_doc
73
74 for dt in sql("select name from tabDocType where module in ('Customer Support')"):
75 delete_doc('DocType', dt[0])
76
77 for dt in sql("select name from `tabSearch Criteria` where module in ('Customer Support')"):
78 delete_doc('Search Criteria', dt[0])
79
80 for dt in sql("select name from tabPage where module in ('Customer Support')"):
81 delete_doc('Page', dt[0])
82
83 # move a couple
84 webnotes.conn.sql("update `tab%s` set module=%s where name=%s" % ('DocType', '%s', '%s'), ('Application Internal', 'Patch Util'))
85 webnotes.conn.sql("update `tab%s` set module=%s where name=%s" % ('DocType', '%s', '%s'), ('Application Internal', 'DocType Property Setter'))
86
87 # remove utilities
88 webnotes.conn.sql('delete from `tabModule Def` where name in ("Customer Support", "Utilities")')
Brahma K09307622011-07-27 12:03:34 +053089
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +053090 elif patch_no == 45:
91 webnotes.conn.sql('delete from tabDocField where options="Ticket Response Detail"')
92
93 elif patch_no == 46:
94 import webnotes
95 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.")
96 webnotes.conn.set_global("system_message_id", "2")
97
98 elif patch_no == 47:
99 import webnotes
100 webnotes.conn.set_global("system_message", "")
101 webnotes.conn.set_global("system_message_id", "3")
102
103 elif patch_no == 48:
104 webnotes.conn.sql("update tabDocField set options = 'Print Heading' where fieldname = 'select_print_heading'")
105
106 elif patch_no == 49:
107 webnotes.conn.sql("update tabDocType set autoname = '' where name = 'Search Criteria'")
108 elif patch_no == 50:
109 sql("update tabDocField set in_filter = 1 where fieldname in ('cost_center', 'income_account', 'Item Group') and parent = 'RV Detail'")
110 elif patch_no == 51:
111 sql("update tabDocField set options = 'link:Print Heading' where fieldtype = 'Select' and fieldname = 'select_print_heading' and parent = 'POS Setting'")
112 elif patch_no == 52:
113 sql("update tabDocField set print_hide = 1 where fieldname = 'letter_head'")
114 elif patch_no == 53:
115 sql("update tabDocType set search_fields = 'lead_name,lead_owner,status,contact_by,contact_date' where name = 'Lead'")
116 elif patch_no == 54:
117 sql("delete from tabDocField where parent = 'Supplier' and label = 'Supplier Contacts' and fieldtype = 'Section Break'")
118 elif patch_no == 55:
119 sql("commit")
120 try:
121 sql("alter table tabFeed add column `_user_tags` varchar(180)")
122 except Exception, e:
123 if e.args[0]!=1060:
124 raise e
125 elif patch_no == 56:
126 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'")
127 elif patch_no == 57:
Nabin Hait31a407d2011-07-28 11:47:45 +0530128 import_from_files(record_list=[['selling','doctype','sales_order_detail']])
Brahma K09307622011-07-27 12:03:34 +0530129
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530130 elif patch_no == 58:
131 # module def patches
132 sql("update `tabModule Def` set module_page = NULL where name not in ('Event Updates', 'Setup', 'My Company')")
133 sql("delete from `tabModule Def Item` where doc_type in ('Separator', 'Setup Forms', 'More Reports')")
134 sql("delete from `tabModule Def Item` where doc_name = 'Project Activity'")
135 sql("update `tabModule Def` set module_label = 'People', disabled='No', is_hidden='No' where name = 'My Company'")
Brahma K09307622011-07-27 12:03:34 +0530136
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530137 # insert new module items
138 from webnotes.model.doc import make_autoname
139 if not sql("select name from `tabModule Def Item` where parent='Projects' and doc_name='Ticket'"):
Brahma K09307622011-07-27 12:03:34 +0530140 sql("""insert into `tabModule Def Item`
141 (name, parent, parenttype, parentfield, docstatus, doc_type, doc_name, display_name, idx) values
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530142 (%s, 'Projects', 'Module Def', 'items', 0, 'Forms', 'Ticket', 'Task', 1)""", make_autoname('MDI.#####'))
143
144 if not sql("select name from `tabModule Def Item` where parent='Projects' and doc_name='Timesheet'"):
Brahma K09307622011-07-27 12:03:34 +0530145 sql("""insert into `tabModule Def Item`
146 (name, parent, parenttype, parentfield, docstatus, doc_type, doc_name, display_name, idx) values
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530147 (%s, 'Projects', 'Module Def', 'items', 0, 'Forms', 'Timesheet', 'Timesheet', 2)""", make_autoname('MDI.#####'))
Brahma K09307622011-07-27 12:03:34 +0530148
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530149 if not sql("select name from `tabModule Def Item` where parent='Projects' and doc_name='Projects'"):
Brahma K09307622011-07-27 12:03:34 +0530150 sql("""insert into `tabModule Def Item`
151 (name, parent, parenttype, parentfield, docstatus, doc_type, doc_name, display_name, idx) values
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530152 (%s, 'Projects', 'Module Def', 'items', 0, 'Pages', 'Projects', 'Gantt Chart', 1)""", make_autoname('MDI.#####'))
Brahma K09307622011-07-27 12:03:34 +0530153
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530154 elif patch_no == 59:
155 webnotes.conn.set_value('Control Panel',None,'mail_footer','')
156 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>')
157 elif patch_no == 60:
158 sql("delete from `tabModule Def Item` where display_name = 'Point of Sales'")
159 elif patch_no == 61:
160 sql("delete from `tabTDS Category Account` where company not in (select name from tabCompany)")
161 elif patch_no == 62:
162 # Import Supplier Quotation
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530163 import_from_files(record_list=[['srm','doctype','supplier_quotation']])
Rushabh Mehta542da5e2011-08-02 13:31:59 +0530164
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530165 # Adding Status Filter
166 sql("update tabDocType set search_fields = concat('status,',search_fields) where name IN ('Delivery Note','Leave Transaction')")
167 # Import Other Charges
Brahma K09307622011-07-27 12:03:34 +0530168
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530169 import_from_files(record_list=[['setup','doctype','other_charges']])
170 elif patch_no == 63:
171 sql("update `tabDocField` set permlevel = 1 where fieldname in ('return_date', 'return_details') and parent = 'Sales and Purchase Return Wizard'")
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530172 import_from_files(record_list = [['accounts', 'doctype', 'rv_detail'], ['material_management', 'doctype', 'sales_and_purchase_return_wizard'], ['material_management', 'doctype', 'stock_entry']])
Rushabh Mehta542da5e2011-08-02 13:31:59 +0530173
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530174 elif patch_no == 64:
175 sql("update tabDocField set `hidden` = 1, `print_hide` = 1, `report_hide` = 1 where options in ('RFQ','Supplier Quotation')")
176 sql("update tabDocType set `read_only` = 1, in_create = 1 where name in ('RFQ','Supplier Quotation')")
177 sql("update tabDocField set `report_hide` = 0 where fieldname in ('email_id','phone_1','fax_1') and parent = 'Customer'")
178 elif patch_no == 65:
179 # Monthly Trend Analyzer <-> Trend Analyzer
180 sql("update `tabSearch Criteria` set criteria_name = 'Trend Analyzer' where criteria_name = 'Monthly Trend Analyzer' and name = 'SRCH/00159'")
181 sql("update `tabModule Def Item` set display_name = 'Trend Analyzer' where parent = 'Analysis' and display_name = 'Monthly Trend Analyzer'")
182 elif patch_no == 66:
183 import webnotes
184 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!""")
185 webnotes.conn.set_global("system_message_id", "4")
Brahma K09307622011-07-27 12:03:34 +0530186
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530187 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')")
188 from webnotes.session_cache import clear_cache
189 clear_cache(webnotes.session['user'])
190 elif patch_no == 67:
191 sql("update `tabDocField` set in_filter = 1 where fieldname = 'brand' and parent = 'RV Detail'")
192 sql("delete from `tabModule Def Item` where (display_name = 'Sales Invoice' and parent = 'CRM') or (display_name = 'Purchase Invoice' and parent = 'SRM')")
193 elif patch_no == 68:
194 from webnotes.modules.import_module import import_from_files
Nabin Hait31a407d2011-07-28 11:47:45 +0530195 import_from_files(record_list=[['hr','doctype','employee'],['roles','Role','Employee']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530196 elif patch_no == 69:
197 # delete flds from employee master
198 p = get_obj('Patch Util')
199 emp_del_flds = ['month_of_birth']
200 for f in emp_del_flds:
201 p.delete_field('Employee', f)
202
203 sql("Update tabDocField set `default` = 'Active' where fieldname = 'status' and parent = 'Employee'")
204
205 # map parent flds
206 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']
207
208 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")
209 for e in emp_prof:
210 prof_obj = get_obj('Employee Profile', e[0])
211 emp_obj = get_obj('Employee', e[1])
212 for d in fld_map:
213 emp_obj.doc.fields[d] = prof_obj.doc.fields[d]
214 emp_obj.doc.current_accommodation_type = prof_obj.doc.present_accommodation_type
Brahma K09307622011-07-27 12:03:34 +0530215
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530216 # address
217 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])
218 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])
219 emp_obj.doc.permanent_address = per_addr
220 emp_obj.doc.current_address = cur_addr
221 #family
222 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])
223 emp_obj.doc.family_background = fam
224 # health
225 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])
226 emp_obj.doc.health_details = health
227 emp_obj.doc.save()
228
229
230 # map tables
231 tbl_list = ['Experience In Company Detail', 'Previous Experience Detail', 'Educational Qualifications Detail']
232 for t in tbl_list:
233 sql("update `tab%s` t1, `tabEmployee Profile` t2 set t1.parent = t2.employee, t1.parenttype = 'Employee' where t1.parent = t2.name" % t)
234
235
236 # overwrite idx?????????
237
238
239 # delete emp profile
240 webnotes.model.delete_doc('DocType', 'Employee Profile')
241 for e in emp_prof:
242 webnotes.model.delete_doc('Employee Profile', e[0])
243
244 elif patch_no == 70:
245 # update search criteria module -> System
246 sql("update tabDocType set module='System' where name='Search Criteria'")
Brahma K09307622011-07-27 12:03:34 +0530247
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530248 # Cleanups to Contact
249 sql("update tabDocField set fieldtype='Data' where options='Designation' and parent='Contact'")
250 sql("update tabDocField set fieldtype='Data' where options='Department' and parent='Contact'")
251 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'")
252
253 # import Contact, Employee
254 from webnotes.modules.import_module import import_from_files
Nabin Hait31a407d2011-07-28 11:47:45 +0530255 import_from_files(record_list=[['utilities','doctype','contact']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530256
Brahma K09307622011-07-27 12:03:34 +0530257
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530258 # remove last_contact_date from Lead
259 sql("delete from tabDocField where fieldname='last_contact_date' and parent='Lead'")
Brahma K09307622011-07-27 12:03:34 +0530260
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530261 elif patch_no == 71:
262 # Make Stock Qty and Conversion Factor field editable. Also no need to mention Conversion factor in table can do it directly
263 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')")
264 sql("update `tabDocField` set `width` = '100px' where parent IN ('PO Detail','Purchase Receipt Detail') and fieldname = 'stock_uom'")
265
266 elif patch_no == 72:
267 # Core Patch
268 # ----------
Brahma K09307622011-07-27 12:03:34 +0530269
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530270 from webnotes.modules.import_module import import_from_files
Brahma K09307622011-07-27 12:03:34 +0530271
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530272 # import module def
273 import_from_files(record_list = [['core', 'Module Def', 'Core']])
274 elif patch_no == 73:
275 # set module in DocTypes
276 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 +0530277
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530278 # set module in Page
279 sql("update tabPage set module='Core' where name='Login Page'")
Brahma K09307622011-07-27 12:03:34 +0530280
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530281 # move file browser to Tools
282 sql("update tabPage set module='Tools' where name='File Browser'")
283 sql("update tabDocType set module='Tools' where name='File Browser Control'")
284 sql("update tabDocType set module='Application Internal' where name='Profile Control'")
285 elif patch_no == 74:
286 p = get_obj('Patch Util')
287 # permission
288 p.delete_permission('Employee', 'Administrator', 0)
289 p.delete_permission('Employee', 'Administrator', 1)
290 p.add_permission('Employee', 'Employee', 0, read = 1, match = 'owner')
291 p.add_permission('Employee', 'Employee', 1, read = 1, match = 'owner')
292 sql("delete from `tabDocField` where parent = 'Employee' and label = 'Payroll Rule'")
293 elif patch_no == 75:
294 #sal structure patch
295 # import
296 from webnotes.modules.import_module import import_from_files
Nabin Hait31a407d2011-07-28 11:47:45 +0530297 import_from_files(record_list=[['hr','doctype','salary_structure'], ['hr','doctype','earning_detail'],['hr','doctype','deduction_detail']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530298 elif patch_no == 76:
299 # property
300 p = get_obj('Patch Util')
301 p.set_field_property('Salary Structure', 'is_active', 'default', 'Yes')
302 p.set_field_property('Salary Structure', 'ctc', 'reqd', '1')
303 p.set_field_property('Earning Detail', 'modified_value', 'width', '')
304 p.set_field_property('Earning Detail', 'modified_value', 'trigger', 'Client')
305 p.set_field_property('Deduction Detail', 'd_modified_amt', 'width', '')
306 p.set_field_property('Earning Detail', 'd_modified_amt', 'trigger', 'Client')
307 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'")
308
309 # delete
310 sql("update `tabSalary Structure` set net_pay = total")
311 sql("delete from tabDocField where label in ('LWP Help', 'Calculate Total', 'Total') and parent = 'Salary Structure'")
312 sql("delete from tabDocPerm where parent in ('Earning Detail', 'Deduction Detail')")
313
314
315 # permission
316 p.delete_permission('Salary Structure', 'Administrator', 0)
317 p.delete_permission('Salary Structure', 'Administrator', 1)
318 p.add_permission('Salary Structure', 'Employee', 0, read = 1, match = 'owner')
319 p.add_permission('Salary Structure', 'Employee', 1, read = 1, match = 'owner')
320 elif patch_no == 77:
321 # sal slip patch
322 # import
323 from webnotes.modules.import_module import import_from_files
Nabin Hait31a407d2011-07-28 11:47:45 +0530324 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 +0530325 elif patch_no == 78:
326 p = get_obj('Patch Util')
327 # delete
328 sql("update `tabSalary Slip` set leave_encashment_amount = encashment_amount")
329 p.delete_field('Salary Slip', 'encashment_amount')
330 p.delete_field('Salary Slip', 'year')
331 p.delete_field('Salary Slip', 'flag')
332 sql("delete from tabDocField where label = 'Process Payroll' and parent = 'Salary Slip'")
333
334 # field property
335 p.set_field_property('Salary Slip', 'bank_name', 'permlevel', '1')
336 p.set_field_property('Salary Slip', 'leave_without_pay', 'permlevel', '0')
337 p.set_field_property('Salary Slip', 'leave_without_pay', 'trigger', 'Client')
338 p.set_field_property('SS Earning Detail', 'e_type', 'permlevel', '0')
339 p.set_field_property('SS Earning Detail', 'e_type', 'fieldtype', 'Link')
340 p.set_field_property('SS Earning Detail', 'e_type', 'options', 'Earning Type')
341 p.set_field_property('SS Deduction Detail', 'd_type', 'permlevel', '0')
342 p.set_field_property('SS Deduction Detail', 'd_type', 'fieldtype', 'Link')
343 p.set_field_property('SS Deduction Detail', 'd_type', 'options', 'Deduction Type')
344 sql("update `tabSS Earning Detail` set e_modified_amount = e_amount")
345 sql("update `tabSS Deduction Detail` set d_modified_amount = d_amount")
346
347 # permission
348 p.delete_permission('Salary Slip', 'Administrator', 0)
349 p.delete_permission('Salary Slip', 'Administrator', 1)
350 p.add_permission('Salary Slip', 'Employee', 0, read = 1, match = 'owner')
351 p.add_permission('Salary Slip', 'Employee', 1, read = 1, match = 'owner')
352 elif patch_no == 79:
353 # Import Modules
Rushabh Mehta542da5e2011-08-02 13:31:59 +0530354 import_from_files(record_list=[['hr','doctype','leave_application'],['hr','doctype','leave_allocation'],['hr','doctype','leave_control_panel'],['hr','doctype','holiday_list'],['hr','doctype','holiday_list_detail'],['hr','Module Def','HR']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530355 elif patch_no == 80:
356 # Holiday List
357 sql("update `tabHoliday List Detail` set description = holiday_name")
358 sql("delete from tabDocField where parent = 'Holiday List Detail' and fieldname = 'holiday_name'")
359 sql("update tabDocField set fieldtype = 'Select', options = 'link:Fiscal Year' where parent = 'Holiday List' and fieldname = 'fiscal_year'")
360 sql("delete from tabDocPerm where role in ('Administrator','HR User') and parent = 'Holiday List'")
361
362 # Leave Control Panel
363 # --------------------
364 sql("delete from `tabDocField` where parent = 'Leave Control Panel' and label in ('Leave Control Panel','Allocation Details') and fieldtype = 'Section Break'")
365 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')")
366 sql("update tabDocField set fieldtype = 'Select', options = 'link:Fiscal Year' where parent = 'Leave Control Panel' and fieldname = 'fiscal_year'")
367 sql("update tabDocField set fieldtype = 'Select', options = 'link:Leave Type' where parent = 'Leave Control Panel' and fieldname = 'leave_type'")
368 sql("update tabDocField set reqd = 1 where parent = 'Leave Control Panel' and fieldname = 'no_of_days'")
369
370 # Leave Application
371 # ------------------
372 for d in sql("select * from `tabLeave Transaction` where leave_transaction_type = 'Deduction' and ifnull(deduction_type, '') = 'Leave'", as_dict = 1):
373 lp = Document('Leave Application')
374 lp.employee = d['employee']
375 lp.leave_type = d['leave_type']
376 lp.posting_date = d['date']
377 lp.fiscal_year = d['fiscal_year']
378 lp.leave_balance = d['pre_balance']
379 lp.half_day = d['half_day']
380 lp.from_date = d['from_date']
381 lp.to_date = d['to_date']
382 lp.total_leave_days = d['total_leave']
383 lp.description = d['reason']
384 lp.docstatus = cint(d['docstatus'])
385 lp.save(1)
386
387 # Leave Allocation
388 # -----------------
389 for d in sql("select * from `tabLeave Transaction` where leave_transaction_type = 'Allocation'", as_dict = 1):
390 la = Document('Leave Allocation')
391 la.employee = d['employee']
392 la.leave_type = d['leave_type']
393 la.posting_date = d['date']
394 la.fiscal_year = d['fiscal_year']
395 la.new_leaves_allocated = d['total_leave']
396 la.total_leaves_allocated = d['total_leave']
397 la.description = d['reason']
398 la.docstatus = cint(d['docstatus'])
399 la.save(1)
400
401 # Payroll Module Def
402 # -------------------
403 sql("delete from `tabModule Def Item` where doc_name = 'Leave Transaction' and display_name = 'Leave Transaction' and parent = 'Payroll' and doc_type = 'Forms'")
404
405 elif patch_no == 81:
406 # Import Modules
Rushabh Mehta542da5e2011-08-02 13:31:59 +0530407 import_from_files(record_list=[['hr','Module Def','HR']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530408 elif patch_no == 82:
409 sql("update tabDocType set search_fields = 'employee,leave_type,total_leaves_allocated,fiscal_year' where name = 'Leave Allocation'")
410 sql("update tabDocType set search_fields = 'employee,leave_type,from_date,to_date,total_leave_days,fiscal_year' where name = 'Leave Application'")
411 elif patch_no == 83:
412 # delete leave transaction
413 webnotes.conn.sql("set foreign_key_checks=0")
414 sql("delete from `tabLeave Transaction`")
415 import webnotes.model
416 webnotes.model.delete_doc('DocType','Badge Settings Detail')
417 webnotes.model.delete_doc('DocType','Leave Transaction')
418 webnotes.conn.sql("set foreign_key_checks=1")
419 elif patch_no == 84:
420 p = get_obj('Patch Util')
421 p.set_field_property('SS Earning Detail', 'e_amount', 'permlevel', '1')
422 p.set_field_property('SS Deduction Detail', 'd_amount', 'permlevel', '1')
423 elif patch_no == 85:
424 # permission
425 p = get_obj('Patch Util')
426 p.add_permission('Leave Application', 'Employee', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1, match = 'owner')
427 p.add_permission('Leave Application', 'Employee', 1, read = 1, match = 'owner')
428 p.add_permission('Leave Allocation', 'HR User', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1, match = 'owner')
429 p.add_permission('Leave Allocation', 'HR User', 1, read = 1)
430 sql("update tabDocPerm set `match` = '' where parent = 'Leave Application' and role = 'HR User'")
431 elif patch_no == 86:
432 # Import Modules
Nabin Hait31a407d2011-07-28 11:47:45 +0530433 import_from_files(record_list=[['hr','doctype','leave_type']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530434 elif patch_no == 87:
435 sql("update `tabLeave Type` set is_lwp = 1 where name = 'Leave Without Pay'")
436 elif patch_no == 88:
437 # Import Modules
Nabin Hait31a407d2011-07-28 11:47:45 +0530438 import_from_files(record_list=[['hr','doctype','leave_allocation']])
Brahma K09307622011-07-27 12:03:34 +0530439
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530440 elif patch_no == 89:
441 sql("delete from `tabModule Def Item` where doc_type = 'Setup Forms' and doc_name in ('Payroll Rule', 'IT Checklist', 'Employee Profile') and parent = 'Payroll'")
442 sql("update `tabDocField` set `hidden` = 1, `print_hide` = 1, `report_hide` = 1 where parent = 'Leave Type' and fieldname = 'is_encash'")
443 elif patch_no == 90:
444 sql("update `tabLeave Allocation` set docstatus = 1")
445 elif patch_no == 91:
446 import webnotes
447 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!""")
448 webnotes.conn.set_global("system_message_id", "5")
449 elif patch_no == 92:
450 sql("update tabDocField set label = 'Get Charges' where parent IN ('Sales Order','Delivery Note','Receivable Voucher') and label = 'Get Other Charges' and fieldtype = 'Button'")
451 # Automated Other Charges Calculation basis
452 sql("update tabDocField set options = '', `trigger` = 'Client' where parent IN ('Quotation','Sales Order','Delivery Note','Receivable Voucher') and label = 'Get Charges' and fieldtype = 'Button'")
453 elif patch_no == 93:
454 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'")
455 sql("update `tabField Mapper Detail` set from_field = 'customer' where to_field = 'customer' and parent = 'Sales Order-Receivable Voucher'")
456 elif patch_no == 94:
Nabin Hait31a407d2011-07-28 11:47:45 +0530457 import_from_files(record_list=[['selling','doctype','sms_center']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530458 elif patch_no == 95:
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530459 import_from_files(record_list=[['mapper','DocType Mapper','Sales Order-Receivable Voucher'], ['mapper','DocType Mapper','Delivery Note-Receivable Voucher']])
460 elif patch_no == 96:
461 sql("delete from `tabModule Def Item` where doc_type = 'Reports' and display_name = 'Cenvat Credit - Input or Capital Goods' and parent = 'Accounts'")
462 elif patch_no == 97:
463 sql("update tabFeed set doc_label = 'Feed', doc_name = name where ifnull(doc_name,'') = '' and ifnull(doc_label,'') = ''")
464 elif patch_no == 98:
465 import_from_files(record_list=[['accounts','doctype','payable_voucher']])
466 elif patch_no == 99:
467 import_from_files(record_list=[['accounts','doctype','account']])
468 elif patch_no == 100:
469 p = get_obj('Patch Util')
470 p.set_field_property('Account', 'level', 'hidden', '1')
471 p.set_field_property('Account', 'level', 'print_hide', '1')
472 p.set_field_property('Account', 'account_type', 'search_index', '0')
473 p.set_field_property('TDS Detail', 'tds_category', 'width', '150px')
474 p.set_field_property('TDS Detail', 'special_tds_rate_applicable', 'width', '150px')
475 p.set_field_property('TDS Detail', 'special_tds_rate', 'width', '150px')
476 p.set_field_property('TDS Detail', 'special_tds_limit', 'width', '150px')
477 elif patch_no == 101:
478 # Leave Application Details and Leave Allocation Details
479 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')")
480 get_obj('DocType','Leave Application').doc.save()
481 get_obj('DocType','Leave Allocation').doc.save()
482 elif patch_no == 102:
483 # make item description field editable in production order
484 sql("update tabDocField set permlevel = 0 where fieldname = 'description' and parent = 'Production Order'")
485 elif patch_no == 103:
486 sql("update tabDocField set fieldname = '' where fieldtype = 'HTML'")
487 elif patch_no == 104:
Rushabh Mehta542da5e2011-08-02 13:31:59 +0530488 import_from_files(record_list=[['hr','search_criteria','stdsrch_00001'],['hr','search_criteria','stdsrch_00002'],['hr','search_criteria','stdsrch_00003'],['hr','Module Def','HR'],['hr','doctype','leave_application'],['hr','doctype','leave_allocation']])
Brahma K09307622011-07-27 12:03:34 +0530489
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530490 elif patch_no == 105:
491 # Employee Leave Balance
492 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')")
493 # Update Search Fields
494 sql("update tabDocType set search_fields = 'employee,employee_name,leave_type,from_date,to_date,total_leave_days,fiscal_year' where name = 'Leave Application'")
495 sql("update tabDocType set search_fields = 'employee,employee_name,leave_type,total_leaves_allocated,fiscal_year' where name = 'Leave Allocation'")
496 elif patch_no == 106:
497 for d in sql("select name,employee,employee_name from `tabLeave Allocation`"):
498 if not cstr(d[2]):
499 sql("update `tabLeave Allocation` set employee_name = '%s' where name = '%s'" % (webnotes.conn.get_value('Employee',cstr(d[1]),'employee_name'), cstr(d[0])))
500 for d in sql("select name,employee,employee_name from `tabLeave Application`"):
501 if not cstr(d[2]):
502 sql("update `tabLeave Application` set employee_name = '%s' where name = '%s'" % (webnotes.conn.get_value('Employee',cstr(d[1]),'employee_name'), cstr(d[0])))
503 elif patch_no == 107:
504 sql("delete from `tabDocField` where fieldname = 'fiscal_year' and parent = 'Employee'")
505 elif patch_no == 108:
Nabin Hait31a407d2011-07-28 11:47:45 +0530506 import_from_files(record_list=[['hr','search_criteria','srch_std_00013']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530507 elif patch_no == 109:
Nabin Hait31a407d2011-07-28 11:47:45 +0530508 import_from_files(record_list=[['hr','search_criteria','srch_std_00015']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530509 elif patch_no == 110:
Nabin Hait31a407d2011-07-28 11:47:45 +0530510 import_from_files(record_list=[['hr','doctype','salary_structure'], ['hr', 'doctype', 'salary_slip']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530511 elif patch_no == 111:
512 sql("update tabDocType set search_fields = 'transfer_date, from_warehouse, to_warehouse, purpose, remarks' where name = 'Stock Entry'")
513 elif patch_no == 112:
514 sql("delete from tabDocField where label = 'Get Other Charges' and fieldtype = 'Button' and parent = 'Receivable Voucher'")
515 elif patch_no == 113:
516 sql("update tabDocField set reqd = 1 where parent = 'Customer' and fieldname = 'phone_1'")
517 elif patch_no == 114:
518 for d in sql("select name, master_name, credit_days, credit_limit from tabAccount where master_type = 'Customer'"):
519 if cstr(d[1]):
520 days, limit = cint(d[2]), flt(d[3])
521 cust_det = sql("select credit_days, credit_limit from tabCustomer where name = '%s'" % (cstr(d[1])))
522 if not days: days = cust_det and cint(cust_det[0][0]) or 0
523 if not limit: limit = cust_det and flt(cust_det[0][1]) or 0
524 sql("COMMIT")
525 sql("START TRANSACTION")
526 sql("update tabAccount set credit_days = '%s', credit_limit = '%s' where name = '%s'" % (days, limit, cstr(d[0])))
527 sql("COMMIT")
528
529 elif patch_no == 115:
530 # patch for timesheet cleanup
531 from webnotes.model import delete_doc
532 delete_doc('DocType', 'Timesheet Detail')
Brahma K09307622011-07-27 12:03:34 +0530533
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530534 from webnotes.modules.import_module import import_from_files
535 import_from_files(record_list = [['Projects', 'DocType', 'Timesheet'], ['Projects', 'DocType', 'Timesheet Detail'], ['Projects', 'DocType', 'Activity Type']])
536
537 elif patch_no == 116:
538 # again!
539 from webnotes.model import delete_doc
540 delete_doc('DocType', 'Timesheet Detail')
Brahma K09307622011-07-27 12:03:34 +0530541
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530542 from webnotes.modules.import_module import import_from_files
543 import_from_files(record_list = [['Projects', 'DocType', 'Timesheet Detail']])
544 elif patch_no == 117:
545 op = '\n' + 'Walk In'
546 sql("update `tabDocField` set `options` = concat(options, %s) where parent = 'Enquiry' and fieldname = 'source' and options not like '%%Walk%%'", op)
547 elif patch_no == 118:
548 from webnotes.utils import get_defaults
549 ss = sql("select name, net_pay from `tabSalary Slip`")
550 for d in ss:
551 if d[1]:
552 w = get_obj('Sales Common').get_total_in_words(get_defaults()['currency'], d[1])
553 sql("update `tabSalary Slip` set net_pay_in_words = '%s' where name = '%s'" % (w, d[0]))
554 elif patch_no == 119:
555 sql("update tabDocType set in_create = 1 where name = 'Profile'")
556 elif patch_no == 120:
557 sql("update tabDocField set permlevel = 0 where parent = 'Sales and Purchase Return Wizard' and fieldname = 'return_date'")
558 elif patch_no == 121:
559 import_from_files(record_list = [['CRM', 'DocType', 'Return Detail'], ['Material Management', 'DocType', 'Sales and Purchase Return Wizard']])
560 elif patch_no == 122:
561 sql("delete from tabDocField where (fieldname = 'serial_no' or label = 'Warrany Status') and parent = 'Sales Order'")
562 elif patch_no == 123:
563 import_from_files(record_list = [['CRM', 'Module Def', 'CRM'], ['CRM', 'Search Criteria', 'STDSRCH/00004']])
564 elif patch_no == 124:
565 import webnotes
566 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!""")
567 webnotes.conn.set_global("system_message_id", "5")
568 elif patch_no == 125:
569 import_from_files(record_list = [['Material Management', 'DocType', 'Delivery Note']])
570 elif patch_no == 126:
571 sql("delete from tabDocField where parent = 'Delivery Note' and label in ('Make Sales Invoice', 'Make Installation Note', 'Intro Note')")
572 elif patch_no == 127:
573 sql("delete from tabDocPerm where role = 'All' and parent = 'Expense Voucher' and (permlevel = 0 or permlevel = 2)")
574 p = get_obj('Patch Util')
575 p.add_permission('Expense Voucher', 'Employee', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1, match = 'owner')
576 p.add_permission('Expense Voucher', 'HR Manager', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1)
577 p.add_permission('Expense Voucher', 'HR User', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1)
578 elif patch_no == 128:
579 from webnotes.modules import import_module
Nabin Hait31a407d2011-07-28 11:47:45 +0530580 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 +0530581 elif patch_no == 129:
582 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'")
583 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'")
584 elif patch_no == 130:
585 # update from rv
586 from webnotes.model.code import get_obj
587 from webnotes.utils import cstr
588 for d in sql("select name, docstatus from `tabReceivable Voucher` where ifnull(docstatus,0) != 0"):
589 sql("COMMIT")
590 sql("START TRANSACTION")
591 try:
592 obj = get_obj('Receivable Voucher', cstr(d[0]), with_children = 1)
593 is_submit = 1
594 if cint(d[1]) == 2: is_submit = 0
595 get_obj('Sales Common').update_prevdoc_detail(is_submit, obj)
596 except:
597 pass
598 sql("COMMIT")
599
600 # update from dn
601 from webnotes.model.code import get_obj
602 for d in sql("select name, docstatus from `tabDelivery Note` where ifnull(docstatus,0) != 0"):
603 sql("COMMIT")
604 sql("START TRANSACTION")
605 try:
606 obj = get_obj('Delivery Note', cstr(d[0]), with_children = 1)
607 is_submit = 1
608 if cint(d[1]) == 2: is_submit = 0
609 get_obj('Sales Common').update_prevdoc_detail(is_submit, obj)
610 except:
611 pass
612 sql("COMMIT")
613 elif patch_no == 131:
614 sql("update `tabDocType` set allow_trash = 1 where name = 'Purchase Other Charges'")
615 sql("update tabDocPerm set `cancel` = 1 where parent = 'Purchase Other Charges' and permlevel = 0 and `read` = 1 and `write` = 1")
616 elif patch_no == 132:
617 sql("update tabDocField set no_copy = 0 where parent = 'Receivable Voucher' and fieldname = 'customer'")
618 elif patch_no == 133:
619 from webnotes.modules import import_module
620 import_module.import_from_files(record_list=[['accounts','doctype','receivable_voucher']])
621 elif patch_no == 134:
622 sql("update tabDocField set no_copy = 1 where parent = 'Receivable Voucher' and fieldname = 'posting_time'")
623 elif patch_no == 135:
624 sql("update tabDocField set `default` = 'Today' where parent = 'Receivable Voucher' and fieldname = 'due_date'")
625 elif patch_no == 136:
626 from webnotes.modules import import_module
627 import_module.import_from_files(record_list=[['accounts','doctype','rv_detail']])
628 elif patch_no == 137:
629 from webnotes.modules import import_module
630 import_module.import_from_files(record_list=[['setup','doctype','price_list']])
631 elif patch_no == 138:
632 sql("update `tabDocType` set allow_attach = 1 where name = 'Price List'")
633 elif patch_no == 139:
634 from webnotes.modules import import_module
635 import_module.import_from_files(record_list=[['mapper','DocType Mapper','Sales Order-Receivable Voucher'], ['mapper','DocType Mapper','Delivery Note-Receivable Voucher']])
636 elif patch_no == 140:
637 from webnotes.modules import import_module
638 import_module.import_from_files(record_list=[['accounts','doctype','rv_detail']])
639 elif patch_no == 141:
640 sql("delete from tabDocField where (fieldname = 'letter_head' or label = 'Letter Head') and parent = 'Company'")
641 elif patch_no == 142:
642 # fixes to letter head and personalize
643 from webnotes.model import delete_doc
Brahma K09307622011-07-27 12:03:34 +0530644
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530645 delete_doc('DocType', 'Batch Settings')
646 delete_doc('DocType', 'Batch Settings Detail')
647 delete_doc('DocType', 'Social Badge')
648 delete_doc('Page', 'Personalize Page')
649 delete_doc('DocType', 'Personalize Page Control')
Brahma K09307622011-07-27 12:03:34 +0530650
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530651 import_from_files(record_list=[['core','doctype','letter_head'], ['setup','doctype','personalize']])
652 elif patch_no == 144:
653 webnotes.conn.sql("update tabDocField set fieldtype='Code' where parent='Letter Head' and fieldname='content'")
654 elif patch_no == 145:
655 sql("update `tabDocField` set permlevel=1 where fieldname = 'group_or_ledger' and parent = 'Account'")
656 elif patch_no == 146:
657 import_from_files(record_list=[['accounts','doctype','account']])
658 elif patch_no == 147:
659 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']])
660 elif patch_no == 148:
661 sql("delete from `tabDocField` where (fieldname = 'account_balances' or label = 'Balances') and parent = 'Account'")
662 sql("update tabDocType set istable = 0, section_style = 'Simple', search_fields = 'account, period, fiscal_year, balance' where name = 'Account Balance'")
663 sql("update tabDocField set permlevel = 0 where parent = 'Account Balance'")
664 p = get_obj('Patch Util')
665 p.add_permission('Account Balance', 'Accounts User', 0, read = 1)
666 p.add_permission('Account Balance', 'Accounts Manager', 0, read = 1)
667 import_from_files(record_list=[['accounts','doctype','account_balance']])
668 elif patch_no == 149:
669 sql("update `tabAccount Balance` set account = parent")
670 elif patch_no == 150:
671 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')")
672 ac_bal = Document("DocType", "Account Balance")
673 ac_bal.save()
674 elif patch_no == 151:
675 sql("delete from tabDocField where label = 'Add / Manage Contacts' and fieldtype = 'Button' and parent = 'Customer'")
676 sql("delete from `tabField Mapper Detail` where parent = 'Sales Order-Delivery Note' and from_field = 'note' and to_field = 'note'")
677 elif patch_no == 152:
Nabin Hait31a407d2011-07-28 11:47:45 +0530678 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 +0530679 elif patch_no == 153:
680 sql("delete from `tabDocField` where fieldname = 'sales_person' and parent = 'Customer'")
681 elif patch_no == 154:
Nabin Hait31a407d2011-07-28 11:47:45 +0530682 import_from_files(record_list=[['stock','doctype','serial_no'], ['support','doctype','customer_issue']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530683 elif patch_no == 155:
684 for d in sql("select name, item_code from `tabSerial No`"):
685 sql("COMMIT")
686 sql("START TRANSACTION")
687 sql("update `tabSerial No` set item_name = '%s' where name = '%s'" % (webnotes.conn.get_value('Item',cstr(d[1]),'item_name'), cstr(d[0])))
688 sql("COMMIT")
689 elif patch_no == 156:
690 sql("update tabDocField set fieldtype = 'Code' where fieldname = 'html' and parent = 'Print Format'")
691 elif patch_no == 157:
692 import_from_files(record_list=[['accounts', 'doctype', 'journal_voucher'], ['accounts', 'Print Format', 'Payment Receipt Voucher'], ['accounts', 'Print Format', 'Cheque Printing Format']])
693 elif patch_no == 158:
694 from webnotes.model.doc import addchild
695 sql("delete from tabDocField where parent = 'Customer Issue' and fieldname = 'customer_group'")
696 elif patch_no == 159:
697 sql("update tabAccount set account_type = 'Chargeable' where account_name in ('Advertising and Publicity', 'Freight & Forwarding Charges', 'Miscellaneous Expenses', 'Sales Promotion Expenses')")
698 elif patch_no == 160:
699 sql("update `tabDocType` set search_fields = 'posting_date, due_date, debit_to, fiscal_year, grand_total, outstanding_amount' where name = 'Receivable Voucher'")
700 sql("update `tabDocType` set search_fields = 'posting_date, credit_to, fiscal_year, bill_no, grand_total, outstanding_amount' where name = 'Payable Voucher'")
701 elif patch_no == 161:
702 sql("update tabDocType set autoname = 'field:batch_id' where name = 'Batch'")
703 sql("update tabDocField set no_copy = 1 where parent = 'Batch' and fieldname = 'batch_id'")
704 elif patch_no == 162:
Nabin Hait31a407d2011-07-28 11:47:45 +0530705 import_from_files(record_list=[['selling', 'search_criteria', 'sales_order_pending_items1']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530706 elif patch_no == 163:
707 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 +0530708 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 +0530709 elif patch_no == 164:
Nabin Hait31a407d2011-07-28 11:47:45 +0530710 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 +0530711 elif patch_no == 165:
712 pass
713 elif patch_no == 166:
Nabin Hait31a407d2011-07-28 11:47:45 +0530714 import_from_files(record_list=[['buying', 'doctype', 'purchase_order']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530715 elif patch_no == 167:
716 if webnotes.conn.get_value('Control Panel', None, 'account_id') not in ['ax0000956', 'ax0001338']:
717 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')")
718 elif patch_no == 168:
719 sql("update tabDocField set fieldtype = 'Data', options = 'Suggest' where fieldname = 'bank_name' and parent = 'Employee'")
720 elif patch_no == 169:
721 import_from_files(record_list=[['accounts', 'doctype', 'pv_detail'], ['accounts', 'doctype', 'rv_detail']])
722 elif patch_no == 170:
723 import_from_files(record_list=[['mapper', 'DocType Mapper', 'Delivery Note-Receivable Voucher']])
724 elif patch_no == 171:
Nabin Hait31a407d2011-07-28 11:47:45 +0530725 import_from_files(record_list=[['buying', 'doctype', 'supplier']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530726 elif patch_no == 172:
727 import webnotes
728 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>""")
729 webnotes.conn.set_global("system_message_id", "6")
730 elif patch_no == 173:
731 sql("delete from tabDocField where label = 'Get Other Charges' and parent = 'Delivery Note'")
732 sql("update tabDocField set reqd = 0 where fieldname = 'posting_time' and parent = 'Serial No'")
733 elif patch_no == 174:
734 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")
735 if c and cint(c[0][0]) > 1:
736 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")
737 elif patch_no == 175:
738 import webnotes
739 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>""")
740 webnotes.conn.set_global("system_message_id", "6")
741 elif patch_no == 176:
742 sql("update tabDocPerm set role='Guest', `write`=0, `create`=0 where role='Administrator' and parent='Notification Control' limit 1")
743 elif patch_no == 177:
744 sql("delete from `tabDocField` where label = 'Next Steps' and parent = 'Purchase Order'")
745 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'")
746 elif patch_no == 178:
Nabin Hait31a407d2011-07-28 11:47:45 +0530747 import_from_files(record_list = [['hr', 'doctype', 'salary_slip']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530748 elif patch_no == 179:
749 from webnotes.utils import get_defaults
750 sl = sql("select name, net_pay from `tabSalary Slip`")
751 for d in sl:
752 in_words = get_obj('Sales Common').get_total_in_words(get_defaults()['currency'], round(flt(d[1])))
753 sql("update `tabSalary Slip` set rounded_total = '%s', total_in_words = '%s' where name = '%s'" % (round(flt(d[1])), in_words, d[0]))
754 elif patch_no == 180:
755 sql("delete from tabDocField where parent = 'Salary Slip' and fieldname = 'net_pay_in_words'")
756 elif patch_no == 181:
757 import_from_files(record_list = [['accounts', 'doctype', 'journal_voucher']])
758 elif patch_no == 182:
759 sql("update tabDocField set options = CONCAT(options, '\nWrite Off Voucher') where fieldname = 'voucher_type' and parent = 'Journal Voucher'")
760 elif patch_no == 183:
761 sql("delete from tabDocField where label = 'SMS' and fieldtype = 'Section Break' and parent in ('Enquiry', 'Lead', 'Sales Order', 'Delivery Note')")
762 elif patch_no == 184:
763 from webnotes.model import delete_doc
764 delete_doc('DocType', 'Feed')
765 delete_doc('DocType', 'Feed List')
766 delete_doc('DocType', 'Feed Control')
767
768 # add trigger
769 from webnotes.model.triggers import add_trigger
770 add_trigger('*','*','*','event_updates.update_feed')
771
772 webnotes.conn.commit()
773
774 try:
775 sql("drop table tabFeed")
776 sql("drop table `tabFeed List`")
777 except: pass
778
779 # import
780 from webnotes.modules.module_manager import reload_doc
781 reload_doc('event_updates','doctype','feed')
782 elif patch_no==185:
783 sql("delete from tabDocTrigger where method = 'webnotes.widgets.follow.on_docsave'")
784 elif patch_no==186:
785 from webnotes.modules.module_manager import reload_doc
786 reload_doc('event_updates','doctype','feed')
787 elif patch_no == 187:
788 sql("update tabDocType set autoname = '' where name = 'QA Inspection Report'")
789 elif patch_no == 188:
Nabin Hait31a407d2011-07-28 11:47:45 +0530790 import_from_files(record_list = [['buying', 'doctype', 'qa_inspection_report']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530791 elif patch_no == 189:
792 sql("update `tabDocField` set allow_on_submit = 1 where fieldname in ('entries', 'other_charges') and parent = 'Receivable Voucher'")
793 elif patch_no == 190:
794 sql("update tabDocField set permlevel=0 where fieldname = 'fiscal_year' and parent = 'Stock Entry'")
795 elif patch_no == 191:
Nabin Hait31a407d2011-07-28 11:47:45 +0530796 import_from_files(record_list = [['support', 'doctype', 'customer_issue']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530797 elif patch_no == 192:
798 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 +0530799 import_from_files(record_list = [['buying', 'Module Def', 'SRM']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530800 elif patch_no == 193:
801 sql("update tabDocField set fieldtype='Button', `trigger`='Client' where parent='Letter Head' and fieldname='set_from_image'")
802 elif patch_no == 194:
803 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 +0530804 import_from_files(record_list = [['stock', 'Module Def', 'Material Management']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530805 elif patch_no == 195:
806 from webnotes.modules.module_manager import reload_doc
807 reload_doc('setup','doctype','manage_account')
808 elif patch_no == 196:
809 sql("update `tabModule Def` set module_page = null where name = 'Material Management'")
810 elif patch_no == 197:
811 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 +0530812 import_from_files(record_list = [['support', 'doctype', 'customer_issue']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530813 elif patch_no == 198:
814 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')")
815 sql("delete from `tabDocField` where label in ('SMS', 'Send SMS') and parent = 'Purchase Order'")
816 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')")
817 from webnotes.model import delete_doc
818 delete_doc('DocType', 'Lead SMS Detail')
819 delete_doc('DocType', 'Enquiry SMS Detail')
820 elif patch_no == 199:
821 sql("update tabDocField set reqd = 0 where parent = 'Attendance' and fieldname = 'shifts'")
822 elif patch_no == 200:
823 reload_doc('event_updates','page','profile_settings')
824 elif patch_no == 201:
825 reload_doc('setup','doctype','price_list')
826 elif patch_no == 202:
827 name1 = sql("select name from tabDocField where parent='Price List' and label='Clear Prices' limit 1,1")
828 name2 = sql("select name from tabDocField where parent='Price List' and label='Update Prices' limit 1,1")
829 if name1:
830 sql("delete from tabDocField where name=%s limit 1", name1[0][0])
831 if name2:
832 sql("delete from tabDocField where name=%s limit 1", name2[0][0])
833 elif patch_no == 203:
834 sql("delete from tabDocField where parent = 'Company' and fieldname = 'default_salary_account' limit 1")
835 elif patch_no == 204:
836 sql("delete from tabDocField where parent = 'Company' and fieldname = 'default_salary_acount' limit 1")
837 elif patch_no == 205:
838 sql("update `tabDocField` set `default` = '' where fieldname = 'naming_series' and parent = 'Installation Note'")
839 elif patch_no == 206:
Nabin Hait31a407d2011-07-28 11:47:45 +0530840 reload_doc('selling','doctype','installation_note')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530841 elif patch_no == 207:
842 import_from_files(record_list = [['setup', 'doctype', 'company']])
843 elif patch_no == 208:
844 sql("delete from `tabDocField` where (label in ('SMS', 'Send SMS') or fieldname in ('message', 'customer_mobile_no')) and parent ='Quotation'")
845 default_currency = get_obj('Manage Account').doc.default_currency
846 sql("update tabCompany set default_currency = '%s'" % default_currency)
847 elif patch_no == 209:
848 import_from_files(record_list = [['setup', 'doctype', 'company']])
849 elif patch_no == 210:
850 sql("delete FROM `tabDocField` WHERE parent = 'Lead' AND label in ('CC:','Attachment Html','Create New File','Attachment')")
851 elif patch_no == 212:
852 # reload company because of disturbed UI
853 import_from_files(record_list = [['setup', 'doctype', 'company']])
854 elif patch_no == 213:
Nabin Hait31a407d2011-07-28 11:47:45 +0530855 reload_doc('selling','doctype','lead')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530856 reload_doc('setup','doctype','company')
857 elif patch_no == 214:
Nabin Hait31a407d2011-07-28 11:47:45 +0530858 reload_doc('selling','doctype','sales_order')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530859 elif patch_no == 215:
860 # patch for item and image in description
861 sql("update tabDocField set width = '300px' where fieldname='description'")
Nabin Hait31a407d2011-07-28 11:47:45 +0530862 reload_doc('stock', 'doctype', 'item')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530863 sql("delete from __DocTypeCache")
864 elif patch_no == 216:
Nabin Hait31a407d2011-07-28 11:47:45 +0530865 import_from_files(record_list = [['stock', 'doctype', 'serial_no'], ['stock', 'doctype', 'stock_ledger_entry']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530866 elif patch_no == 217:
867 sql("update tabDocField set options = '\nIn Store\nDelivered\nNot in Use' where fieldname = 'status' and parent = 'Serial No'")
868 sql("update tabDocField set no_copy = 1 where fieldname = 'serial_no' and parent = 'Delivery Note Detail'")
869 sql("update tabDocField set no_copy = 1 where fieldname = 'serial_no' and parent = 'Stock Entry Detail'")
870 elif patch_no == 218:
871 for d in sql("select name from `tabSerial No`"):
872 sql("Commit")
873 sql("Start Transaction")
874 s = Document('Serial No', d[0])
875 if s.pr_no:
876 s.purchase_document_type = 'Purchase Receipt'
877 s.purchase_document_no = s.pr_no
878 if s.delivery_note_no:
879 s.delivery_document_type = 'Delivery Note'
880 s.delivery_document_no = s.delivery_note_no
881 if s.notes:
882 s.delivery_note_no = s.notes
883 s.company = webnotes.utils.get_defaults()['company']
884 s.fiscal_year = webnotes.utils.get_defaults()['fiscal_year']
885 s.save()
886 elif patch_no == 219:
887 sql("delete from tabDocField where fieldname in ('pr_no', 'make', 'label', 'delivery_note_no', 'notes') and parent = 'Serial No'")
888 elif patch_no == 220:
889 sql("update tabDocField set label = 'Incoming Rate' where fieldname = 'purchase_rate' and parent = 'Serial No'")
890 sql("update tabDocField set label = 'Incoming Time' where fieldname = 'purchase_time' and parent = 'Serial No'")
891 elif patch_no == 221:
892 sql("update tabDocField set reqd = 1 where fieldname in ('purchase_rate', 'warehouse') and parent = 'Serial No'")
893 elif patch_no == 222:
894 sql("update tabDocField set options = '\nDelivery Note\nReceivable Voucher\nStock Entry' where fieldname = 'delivery_document_type' and parent = 'Serial No'")
895 elif patch_no == 223:
896 sql("update tabDocField set hidden = 0 where fieldname in ('pay_to_recd_from', 'total_amount', 'total_amount_in_words') and parent = 'Journal Voucher'")
897 sql("update tabDocField set permlevel = 0 where fieldname = 'pay_to_recd_from' and parent = 'Journal Voucher'")
898 elif patch_no == 224:
Nabin Hait31a407d2011-07-28 11:47:45 +0530899 import_from_files(record_list = [['stock', 'doctype', 'delivery_note_packing_detail'], ['accounts', 'Print Format', 'Payment Receipt Voucher']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530900 elif patch_no == 225:
Nabin Hait31a407d2011-07-28 11:47:45 +0530901 import_from_files(record_list = [['stock', 'doctype', 'delivery_note_packing_detail']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530902 elif patch_no == 226:
Nabin Hait31a407d2011-07-28 11:47:45 +0530903 import_from_files(record_list = [['stock', 'doctype', 'delivery_note_packing_detail']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530904 elif patch_no == 227:
Nabin Hait31a407d2011-07-28 11:47:45 +0530905 reload_doc('stock', 'doctype', 'item')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530906 if webnotes.conn.get_value('Control Panel', None, 'account_id') != 'axjanak2011':
907 sql("delete from tabDocField where parent = 'Item' and fieldname='alternate_description' limit 1")
908 elif patch_no == 228:
909 # knowledge base patch
910 reload_doc('knowledge_base', 'doctype', 'question')
911 reload_doc('knowledge_base', 'doctype', 'answer')
912 reload_doc('knowledge_base', 'page', 'questions')
913 reload_doc('knowledge_base', 'Module Def', 'Knowledge Base')
914 sql("update `tabModule Def` set disabled='No' where name='Knowledge Base'")
Brahma K09307622011-07-27 12:03:34 +0530915 elif patch_no == 229:
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530916 reload_doc('knowledge_base', 'page', 'question_view')
917 elif patch_no == 230:
Nabin Hait31a407d2011-07-28 11:47:45 +0530918 reload_doc('buying', 'doctype', 'indent')
919 reload_doc('buying', 'doctype', 'indent_detail')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530920 reload_doc('Mapper', 'DocType Mapper', 'Sales Order-Indent')
921 elif patch_no == 231:
922 reload_doc('Mapper', 'DocType Mapper', 'Sales Order-Indent')
923 elif patch_no == 232:
924 sql("update `tabDocField` set options = 'Sales Order' where fieldname = 'sales_order_no' and parent = 'Indent'")
925 elif patch_no == 233:
926 reload_doc('Mapper', 'DocType Mapper', 'Sales Order-Receivable Voucher')
927 reload_doc('Mapper', 'DocType Mapper', 'Delivery Note-Receivable Voucher')
928 elif patch_no == 234:
929 sql("update `tabTable Mapper Detail` set validation_logic = 'docstatus=1' where parent = 'Sales Order-Indent' and from_table = 'Sales Order Detail'")
930 elif patch_no == 235:
Brahma K09307622011-07-27 12:03:34 +0530931 for sc in sql("""select name from `tabSearch Criteria` where ifnull(name,'')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530932 like 'srch%' or ifnull(name,'') like '%stdsrch'"""):
933 try:
934 get_obj('Search Criteria', sc[0]).rename()
935 except AttributeError, e:
936 pass
937 reload_doc('core', 'doctype', 'system_console')
938 elif patch_no == 236:
939 # warehouse not mandatory for delivered serial nos
940 sql("update tabDocField set reqd=0 where parent='Serial No' and fieldname='warehouse'")
941 elif patch_no == 237:
942 sql("update tabDocField set depends_on = 'eval:doc.is_pos==1' where fieldname = 'cash_bank_account' and parent = 'Receivable Voucher'")
943 elif patch_no == 238:
944 reload_doc('accounts', 'doctype', 'receivable_voucher')
945 reload_doc('accounts', 'GL Mapper', 'POS with write off')
946 elif patch_no == 239:
947 reload_doc('core', 'doctype', 'docfield')
948 reload_doc('core', 'doctype', 'doctype')
Nabin Hait31a407d2011-07-28 11:47:45 +0530949 from patches.old_patches.feed_patch import set_subjects_and_tagfields
Brahma K09307622011-07-27 12:03:34 +0530950
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530951 set_subjects_and_tagfields()
952 elif patch_no == 240:
953 # again for sales order (status)
Nabin Hait31a407d2011-07-28 11:47:45 +0530954 from patches.old_patches.feed_patch import set_subjects_and_tagfields
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530955 set_subjects_and_tagfields()
956 elif patch_no == 241:
957 sql("update `tabDocField` set fieldtype = 'Text', options = '', in_filter = '' where fieldname = 'serial_no' and parent = 'Stock Ledger Entry'")
958 elif patch_no == 242:
959 if webnotes.conn.get_value('Control Panel', None, 'account_id') not in ['axjanak2011']:
960 sql("commit")
961 try:
962 sql("alter table `tabStock Ledger Entry` drop index serial_no")
963 except:
964 pass
965
966 sql("alter table `tabStock Ledger Entry` change serial_no serial_no text")
967 elif patch_no == 243:
968 # moving custom script and custom fields to framework
969 webnotes.conn.set_value('DocType', 'Custom Script', 'module', 'Core')
970 webnotes.conn.set_value('DocType', 'Custom Field', 'module', 'Core')
971 reload_doc('setup', 'doctype', 'company')
972 elif patch_no == 244:
Nabin Hait31a407d2011-07-28 11:47:45 +0530973 reload_doc('stock', 'search_criteria', 'shortage_to_indent')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530974 elif patch_no == 245:
Nabin Hait31a407d2011-07-28 11:47:45 +0530975 from patches.old_patches.doctype_permission_patch import set_doctype_permissions
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530976 set_doctype_permissions()
977
Nabin Hait31a407d2011-07-28 11:47:45 +0530978 from patches.old_patches.feed_patch import set_subjects_and_tagfields
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530979 set_subjects_and_tagfields()
980 elif patch_no == 246:
981 webnotes.conn.set_value('DocType','Stock Entry','tag_fields','purpose')
982 webnotes.conn.set_value('DocType','Stock Entry','subject','%(remarks)s')
983 elif patch_no == 247:
984 webnotes.conn.set_value('DocType','Stock Entry','subject','%(remarks)s')
985 elif patch_no == 248:
986 reload_doc('setup', 'doctype', 'manage_account')
987 elif patch_no == 249:
988 sql("update `tabDocPerm` t1, `tabDocType` t2 set t1.role = 'System Manager' where t1.role = 'Administrator' and t1.parent = t2.name and t2.module != 'Core'")
989 elif patch_no == 250:
Nabin Hait31a407d2011-07-28 11:47:45 +0530990 from patches.old_patches.feed_patch import support_patch
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530991 support_patch()
992 elif patch_no == 251:
993 from webnotes.model import db_schema
994 db_schema.remove_all_foreign_keys()
Nabin Hait31a407d2011-07-28 11:47:45 +0530995 from patches.old_patches.customer_address import run_patch
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530996 run_patch()
997 elif patch_no == 252:
Nabin Hait31a407d2011-07-28 11:47:45 +0530998 reload_doc('support','doctype','support_ticket')
999 reload_doc('support','doctype','support_ticket_response')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301000 elif patch_no == 253:
1001 reload_doc('accounts','doctype','ledger_balance_export')
1002 reload_doc('accounts','doctype','ledger_detail')
1003 reload_doc('accounts', 'Module Def', 'Accounts')
1004
1005 from webnotes.model.db_schema import updatedb
1006 updatedb('Ledger Balance Export')
1007 updatedb('Ledger Detail')
1008 elif patch_no == 254:
Nabin Hait31a407d2011-07-28 11:47:45 +05301009 reload_doc('setup', 'doctype', 'sms_settings')
1010 reload_doc('setup', 'doctype', 'static_parameter_detail')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301011
1012 from webnotes.model.db_schema import updatedb
1013 updatedb('SMS Settings')
1014 updatedb('Static Parameter Detail')
1015 elif patch_no == 255:
Nabin Hait31a407d2011-07-28 11:47:45 +05301016 from patches.old_patches.customer_address import run_old_data_sync_patch
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301017 run_old_data_sync_patch()
1018 elif patch_no == 256:
1019 sql("update `tabLetter Head` set content = replace(content, 'http://46.4.50.84/v170-test/', '')")
1020 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'")
1021 sql("update `tabItem` set description_html = replace(description_html, 'http://46.4.50.84/v170-test/', '')")
1022 elif patch_no == 257:
Nabin Hait31a407d2011-07-28 11:47:45 +05301023 from patches.old_patches.customer_address import run_old_data_sync_patch
Brahma K09307622011-07-27 12:03:34 +05301024 run_old_data_sync_patch()
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301025 elif patch_no == 258:
1026 sql("update tabDocField set `default`=NULL where fieldname = 'naming_series'")
1027 elif patch_no == 259:
1028 sql("update `tabQuotation Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1029 sql("update `tabSales Order Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1030 sql("update `tabRV Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1031 sql("update `tabDelivery Note Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1032 elif patch_no == 260:
1033 sql("update `tabLetter Head` set content = replace(content, 'http://46.4.50.84/v170/', '')")
1034 sql("update `tabSingles` set value = replace(value, 'http://46.4.50.84/v170/', '') where field in ('letter_head', 'client_name') and doctype = 'Control Panel'")
1035 sql("update `tabItem` set description_html = replace(description_html, 'http://46.4.50.84/v170/', '')")
1036 sql("update `tabQuotation Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1037 sql("update `tabSales Order Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1038 sql("update `tabRV Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1039 sql("update `tabDelivery Note Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1040 elif patch_no == 261:
1041 sql("update `tabPrint Format` set html = replace(html, 'customer_address', 'address_display')")
1042 elif patch_no == 262:
Nabin Hait31a407d2011-07-28 11:47:45 +05301043 from patches.old_patches.customer_address import sync_lead_phone
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301044 sync_lead_phone()
1045 elif patch_no == 263:
1046 ol = ['','Open','To Reply','Waiting for Customer','Hold','Closed']
1047 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 +05301048 elif patch_no == 264:
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301049 sql("delete from tabDocField where parent = 'Customer Issue' and (fieldname = 'issue_in' or fieldname = 'issue_category')")
1050 sql("update tabDocField set options=NULL where parent='Support Ticket' and label = 'Send'")
1051 elif patch_no == 266:
1052 reload_doc('setup','doctype','support_email_settings')
1053 elif patch_no == 267:
1054 sql("update `tabPrint Format` set html = replace(html, 'supplier_address', 'address_display')")
1055 elif patch_no == 268:
1056 sql("update `tabDocPerm` set permlevel = 0 where permlevel is null")
1057 elif patch_no == 269:
1058 p = get_obj('Patch Util')
1059 p.add_permission('GL Entry', 'Accounts User', 0, read = 1)
1060 elif patch_no == 270:
1061 pages = ['Accounts Setup', 'Accounts', 'Accounting Reports','GeneralLedger','How do I - Accounts','Making Opening Entries',\
1062 'Analysis','How do I - CRM','How do I - Inventory','Inventory Setup', 'Stock','HR','HR & Payroll Setup',\
1063 'Payroll Setup','Production Setup','Production','Buying','SRM Setup','Contact Page','Forum','Messages','Test Toolbar',\
1064 'Trend Analyzer']
1065 from webnotes.model import delete_doc
1066 sql("delete from `tabPage Visit`")
1067 for p in pages:
1068 try: delete_doc('Page', p)
1069 except: pass
1070 elif patch_no == 271:
1071 # tags patch
Nabin Hait31a407d2011-07-28 11:47:45 +05301072 reload_doc('selling','doctype','sales_order')
1073 reload_doc('stock','doctype','delivery_note')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301074 sql("delete from tabDocField where fieldname='per_amt_billed' and parent in ('Sales Order', 'Delivery Note')")
Brahma K09307622011-07-27 12:03:34 +05301075
1076 sql("""update `tabSales Order` set delivery_status = if(ifnull(per_delivered,0) < 0.001, 'Not Delivered',
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301077 if(per_delivered >= 99.99, 'Fully Delivered', 'Partly Delivered'))""")
Brahma K09307622011-07-27 12:03:34 +05301078 sql("""update `tabSales Order` set billing_status = if(ifnull(per_billed,0) < 0.001, 'Not Billed',
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301079 if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""")
Brahma K09307622011-07-27 12:03:34 +05301080 sql("""update `tabDelivery Note` set billing_status = if(ifnull(per_billed,0) < 0.001, 'Not Billed',
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301081 if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""")
1082 elif patch_no == 272:
1083 from webnotes.model import delete_doc
1084 try:
1085 delete_doc('Search Criteria', '_SRCH00003')
1086 except:
1087 pass
1088 reload_doc('accounts', 'search_criteria', 'purchase_register')
1089 elif patch_no == 276:
1090 from webnotes.model import delete_doc
1091 sn = sql("select name from `tabSearch Criteria` where criteria_name = 'Sales Personwise Transaction Summary'")
1092 for d in sn:
1093 delete_doc('Search Criteria', d[0])
Nabin Hait31a407d2011-07-28 11:47:45 +05301094 reload_doc('selling', 'search_criteria', 'sales_personwise_transaction_summary')
nabinhaite0250fb2011-06-14 13:35:31 +05301095 elif patch_no == 277:
1096 webnotes.model.delete_doc('DocType','HomePage Settings')
1097 webnotes.model.delete_doc('DocType','Badge Settings')
1098 sql("update tabDocType set module='Home' where module in ('Event Updates', 'My Company')")
1099 sql("update tabPage set module='Home' where module in ('Event Updates', 'My Company')")
1100 sql("update `tabSearch Criteria` set module='Home' where module in ('Event Updates', 'My Company')")
1101
1102
1103 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')
1104 for p in delete_pages:
1105 webnotes.model.delete_doc('Page',p)
nabinhaitb7789a52011-06-14 17:33:12 +05301106 elif patch_no == 278:
1107 sql("update tabDocTrigger set method = 'home.update_feed' where method = 'event_updates.update_feed'")
nabinhaitc43ece72011-06-15 11:55:32 +05301108 elif patch_no == 279:
1109 dt = ['GL Entry', 'Stock Ledger Entry']
1110 for t in dt:
1111 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)
1112 for d in rec:
1113 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 +05301114
nabinhaitc43ece72011-06-15 11:55:32 +05301115 other_dt = ['Enquiry', 'Quotation', 'Sales Order', 'Indent', 'Purchase Order', 'Production Order', 'Customer Issue', 'Installation Note']
1116 for dt in other_dt:
1117 rec = sql("select name, status from `tab%s` where modified >= '2011-06-15 01:00:00'" % dt)
1118 for r in rec:
1119 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 +05301120 elif patch_no == 280:
1121 reload_doc('accounts', 'doctype', 'form_16a')
nabinhaite7221212011-06-15 14:39:31 +05301122 elif patch_no == 281:
1123 dt_list = ['Delivery Note', 'Purchase Receipt']
1124 for dt in dt_list:
nabinhaite7221212011-06-15 14:39:31 +05301125 sql("update `tab%s` set status = 'Submitted' where docstatus = 1 and modified >='2011-06-15 01:00:00'" % dt)
1126 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 +05301127 elif patch_no == 282:
1128 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']
1129 for d in dt_list:
1130 tbl = sql("select options from `tabDocField` where fieldtype = 'Table' and parent = '%s'" % d)
1131 for t in tbl:
1132 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 +05301133 elif patch_no == 283:
1134 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")
1135 for d in rec:
1136 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 +05301137 elif patch_no == 284:
Nabin Hait31a407d2011-07-28 11:47:45 +05301138 reload_doc('support', 'doctype', 'support_ticket')
nabinhaitf7d80002011-06-20 13:51:26 +05301139 sql("update `tabDocField` set in_filter = 1 where fieldname in ('raised_by', 'subject') and parent = 'Support Ticket'")
nabinhait6150e652011-06-20 16:34:48 +05301140 elif patch_no == 286:
nabinhait4b59bea2011-06-20 14:07:04 +05301141 reload_doc('accounts', 'search_criteria', 'itemwise_sales_register')
1142 reload_doc('accounts', 'search_criteria', 'itemwise_purchase_register')
nabinhait58f01022011-06-21 15:05:43 +05301143 elif patch_no == 287:
nabinhait8b849fe2011-06-21 15:09:55 +05301144 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 +05301145 elif patch_no == 288:
1146 reload_doc('accounts', 'doctype', 'payable_voucher')
nabinhait33dee782011-06-21 17:17:39 +05301147 elif patch_no == 289:
1148 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 +05301149 sql("update `tabDocType` set search_fields = 'status,transaction_date,customer,lead,order_type' where name = 'Quotation'")
Anand Doshib9f7e392011-06-22 12:11:47 +05301150 elif patch_no == 290:
Brahma K09307622011-07-27 12:03:34 +05301151 count = sql("""SELECT * FROM `tabModule Def`
Anand Doshib9f7e392011-06-22 12:11:47 +05301152 WHERE `module_name` LIKE 'Home'""")
1153 if not count:
1154 md = Document('Module Def')
1155 md.module_name = 'Home'
1156 md.module_label = 'Home'
Rushabh Mehta64b6c2c2011-06-22 16:38:11 +05301157 md.save(1)
1158 elif patch_no == 291:
Nabin Hait31a407d2011-07-28 11:47:45 +05301159 reload_doc('utilities','doctype','rename_tool')
nabinhaitaeee6ba2011-06-22 18:25:29 +05301160 elif patch_no == 292:
1161 reload_doc('accounts', 'search_criteria', 'trial_balance')
Ravi Dey560ee3d2011-06-23 13:03:24 +05301162 elif patch_no == 293:
1163 sql("delete from tabDocField where parent='Account' and fieldname='address'")
1164 reload_doc('accounts', 'doctype', 'account')
Rushabh Mehta3e037432011-06-23 22:47:04 +05301165 elif patch_no == 294:
1166 # new account profile fix
1167 ul = sql("select name from tabProfile where ifnull(name,'') not in ('Administrator', 'Guest', '')")
1168 # if one user and one user has no roles
1169 if len(ul)==1 and not sql("select parent from tabUserRole where role='System Manager' and parent=%s", ul[0][0]):
1170 get_obj('Setup Control').add_roles(Document('Profile', ul[0][0]))
Ravi Dey0b6c5652011-06-24 14:44:21 +05301171 elif patch_no == 295:
1172 sql("update `tabDocField` set options = 'Delivered\nNot Delivered\nPartly Delivered\nClosed\nNot Applicable' where parent = 'Sales Order' and fieldname = 'delivery_status'")
1173 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 +05301174 elif patch_no == 296:
Ravi Dey26c160f2011-06-24 15:53:51 +05301175 sql("delete from tabDocField where parent='Support Ticket' and fieldname='contact_no'")
Nabin Hait31a407d2011-07-28 11:47:45 +05301176 reload_doc('support', 'doctype', 'support_ticket')
Ravi Dey74c9c4d2011-06-27 11:26:39 +05301177 elif patch_no == 297:
Nabin Hait31a407d2011-07-28 11:47:45 +05301178 reload_doc('hr', 'doctype', 'employee')
1179 reload_doc('hr', 'doctype', 'attendance')
1180 reload_doc('hr', 'doctype', 'expense_voucher')
1181 reload_doc('hr', 'doctype', 'appraisal')
1182 reload_doc('hr', 'doctype', 'salary_structure')
1183 reload_doc('hr', 'doctype', 'salary_slip')
Ravi Dey48671df2011-06-27 12:03:36 +05301184 elif patch_no == 298:
Ravi Dey94a332a2011-07-01 13:50:34 +05301185 sql("update `tabDocField` set options = 'link:Company' where parent = 'Attendance' and fieldname = 'company'")
1186 sql("update `tabDocField` set options = 'link:Company' where parent = 'Expense Voucher' and fieldname = 'company'")
1187 sql("update `tabDocField` set options = 'link:Company' where parent = 'Appraisal' and fieldname = 'company'")
Ravi Dey8d3f4b62011-06-27 12:48:56 +05301188 elif patch_no == 299:
1189 sql("update `tabDocPerm` set `match` = NULL where parent = 'Employee' and role = 'Employee'")
nabinhait690c6972011-06-28 14:42:07 +05301190 elif patch_no == 300:
Anand Doshib74eec82011-06-28 13:42:08 +05301191 sql("""DELETE FROM `tabSearch Criteria` WHERE name IN
1192 ('sales_register1', 'sales_register2', 'purchase_register1')""")
nabinhait78f5bf62011-06-28 16:21:58 +05301193 elif patch_no == 301:
nabinhait690c6972011-06-28 14:42:07 +05301194 from patches.delivery_billing_status_patch import run_patch
1195 run_patch()
nabinhaitb3930002011-06-28 16:50:38 +05301196 elif patch_no == 302:
1197 sql("update `tabDocField` set no_copy = 1 where fieldname = 'naming_series'")
Ravi Dey4c651192011-06-28 19:36:18 +05301198 elif patch_no == 303:
Ravi Dey27c5b402011-06-29 18:05:18 +05301199 pass
1200 elif patch_no == 304:
Rushabh Mehtac71eeb62011-06-30 08:28:36 +05301201 sql("delete from `tabDocField` where parent = 'company' and label = 'Trash Company' and fieldtype = 'button'")
Ravi Deyc674e432011-06-29 18:15:12 +05301202 reload_doc('setup', 'doctype', 'company')
Ravi Dey79c28652011-06-29 18:55:19 +05301203 elif patch_no == 305:
1204 sql("update `tabDocField` set options = 'link:Company' where options='link:Company' and fieldname='company' and fieldtype='Select'")
nabinhaitec097972011-07-01 13:34:41 +05301205 elif patch_no == 306:
Ravi Dey94a332a2011-07-01 13:50:34 +05301206 sql("update `tabDocField` set options = '\nAccount\nCompany\nCustomer\nSupplier\nEmployee\nWarehouse\nItem' where parent = 'Rename Tool' and fieldname = 'select_doctype'")
1207 sql("update `tabDocField` set options = 'link:Item' where parent = 'Raw Materials Supplied' and fieldname = 'po_item'")
1208 sql("update `tabDocField` set options = 'Sales Order' where parent = 'Indent Detail' and fieldname = 'sales_order_no'")
1209 sql("update `tabDocField` set options = 'link:Company', fieldtype = 'Select' where parent = 'Stock Ledger Entry' and fieldname = 'company'")
Nabin Hait31a407d2011-07-28 11:47:45 +05301210 reload_doc('utilities', 'doctype', 'rename_tool')
Ravi Dey627d01b2011-07-01 14:05:43 +05301211 elif patch_no == 307:
1212 sql("delete from `tabDocField` where parent = 'company' and label = 'Trash Company' and fieldtype = 'Button'")
1213 reload_doc('setup', 'doctype', 'company')
nabinhaita56fc002011-07-01 16:32:03 +05301214 elif patch_no == 308:
Ravi Deyc1886b52011-07-04 16:53:42 +05301215 sql("update `tabDocField` set reqd = 0 where fieldname = 'select_item' and parent = 'Property Setter'")
nabinhait1bd56b12011-07-05 14:41:36 +05301216 elif patch_no == 309:
1217 sql("delete from `tabDocField` where fieldname = 'item_attachments_details' and parent = 'Item'")
nabinhait7f339e02011-07-05 15:43:17 +05301218 sql("delete from `tabModule Def Item` where parent = 'Stock' and doc_name = 'Landed Cost Wizard'")
nabinhait5deab242011-07-06 09:23:02 +05301219 elif patch_no == 310:
1220 from erpnext_structure_cleanup import run_patches
1221 run_patches()
nabinhait4bb8bf42011-07-06 10:11:11 +05301222 elif patch_no == 311:
1223 sql("update `tabDocField` set reqd = 0 where fieldname = 'select_item' and parent = 'Property Setter'")
nabinhait4c38fbb2011-07-06 10:36:53 +05301224 #reload_doc('core', 'doctype', 'property_setter')
nabinhait4bb8bf42011-07-06 10:11:11 +05301225 elif patch_no == 312:
1226 sql("delete from `tabSessions`")
1227 sql("delete from `__SessionCache`")
nabinhaitd54ec522011-07-06 12:20:21 +05301228 elif patch_no == 313:
1229 dt = ['GL Entry', 'Stock Ledger Entry']
1230 for t in dt:
1231 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)
1232 for d in rec:
nabinhaitfccbb092011-07-06 12:23:27 +05301233 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 +05301234
nabinhaitd54ec522011-07-06 12:20:21 +05301235 other_dt = ['Enquiry', 'Quotation', 'Sales Order', 'Indent', 'Purchase Order', 'Production Order', 'Customer Issue', 'Installation Note']
1236 for dt in other_dt:
1237 rec = sql("select name, status from `tab%s` where modified >= '2011-07-06 10:00:00'" % dt)
1238 for r in rec:
1239 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 +05301240
1241
nabinhaitd54ec522011-07-06 12:20:21 +05301242 dt_list = ['Delivery Note', 'Purchase Receipt']
1243 for dt in dt_list:
1244 sql("update `tab%s` set status = 'Submitted' where docstatus = 1 and modified >='2011-07-06 10:00:00'" % dt)
1245 sql("update `tab%s` set status = 'Cancelled' where docstatus = 2 and modified >='2011-07-06 10:00:00'" % dt)
1246
1247 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']
1248 for d in dt_list:
1249 tbl = sql("select options from `tabDocField` where fieldtype = 'Table' and parent = '%s'" % d)
1250 for t in tbl:
1251 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 +05301252
nabinhait22f7edd2011-07-06 12:45:02 +05301253 elif patch_no == 314:
1254 # delete double feed
1255 sql("delete from tabFeed where subject like 'New %'")
nabinhaiteb315402011-07-06 13:03:31 +05301256 elif patch_no == 315:
1257 # delete double feed
1258 sql("delete from tabFeed where doc_name like 'New %'")
1259 reload_doc('core', 'doctype', 'property_setter')
1260
1261 from webnotes.model.doc import Document
1262 m = Document('Module Def Role')
1263 m.role = 'All'
1264 m.parent = 'Home'
1265 m.parenttype = 'Module Def'
1266 m.parentfield = 'roles'
1267 m.save(1)
Ravi Dey7a6211d2011-07-07 15:49:24 +05301268 elif patch_no == 316:
Ravi Dey89822722011-07-07 15:52:35 +05301269 pass
1270 elif patch_no == 317:
Brahma K09307622011-07-27 12:03:34 +05301271 sql("update `tabPage` set name = 'profile-settings' where page_name = 'Profile Settings'")
Anand Doshi56ab7e42011-07-07 18:37:58 +05301272 elif patch_no == 318:
Ravi Deycfc5dff2011-07-07 16:48:54 +05301273 reload_doc('utilities', 'doctype', 'bulk_rename_tool')
Anand Doshi52b1d5a2011-07-07 18:41:12 +05301274 elif patch_no == 319:
Anand Doshi56ab7e42011-07-07 18:37:58 +05301275 sql("delete from tabFeed where doc_name like 'New %'")
nabinhait63cf2b92011-07-08 13:30:46 +05301276 elif patch_no == 320:
1277 reload_doc('setup', 'doctype', 'series_detail')
Ravi Deyfac96e12011-07-08 13:38:16 +05301278 elif patch_no == 321:
Ravi Dey84913842011-07-08 13:46:09 +05301279 reload_doc('hr','doctype','leave_application')
1280 elif patch_no == 322:
1281 sql("delete from `tabDocField` where parent = 'Leave Application' and fieldname = 'latter_head'")
Nabin Hait2acac4b2011-07-10 13:52:05 +05301282 elif patch_no == 323:
1283 reload_doc('stock', 'doctype', 'stock_entry')
Nabin Haite079a6e2011-07-10 14:15:52 +05301284 sql("update `tabDocField` set options = 'get_stock_and_rate' where parent = 'Stock Entry' and label = 'Get Stock and Rate'")
1285 sql("delete from `tabDocField` where label = 'Get Current Stock' and parent = 'Stock Entry'")
nabinhait54b0e7d2011-07-13 16:40:03 +05301286 elif patch_no == 324:
1287 sql("delete from `tabDocField` where fieldname = 'test_field' and parent = 'Customer'")
Ravi Dey9dd0c0b2011-07-13 18:08:38 +05301288 elif patch_no == 325:
1289 sql("update `tabDocField` set fieldtype = 'Data' where parent = 'Salary Slip' and fieldname = 'total_days_in_month'")
1290 reload_doc('hr', 'doctype', 'salary_slip')
Rushabh Mehta61790802011-07-17 10:52:47 +05301291 elif patch_no == 326:
1292 # load the new billing page
1293 if cint(webnotes.conn.get_value('Control Panel',None,'sync_with_gateway')):
1294 reload_doc('server_tools','page','billing')
nabinhaite6526362011-07-19 18:09:26 +05301295 elif patch_no == 327:
Rushabh Mehta391aa022011-07-25 14:07:50 +05301296 # patch for support email settings now moved to email settings
1297 reload_doc('setup','doctype','email_settings')
Brahma K09307622011-07-27 12:03:34 +05301298
Rushabh Mehta391aa022011-07-25 14:07:50 +05301299 # map fields from support to email settings
1300 field_map = {
1301 'support_email': 'email',
1302 'support_host':'host',
1303 'support_username': 'username',
1304 'support_password': 'password',
Rushabh Mehtab7186d42011-07-25 14:37:48 +05301305 'support_use_ssl': 'use_ssl',
Rushabh Mehta391aa022011-07-25 14:07:50 +05301306 'sync_support_mails': 'integrate_incoming',
1307 'signature': 'support_signature'
1308 }
Brahma K09307622011-07-27 12:03:34 +05301309
Rushabh Mehta391aa022011-07-25 14:07:50 +05301310 for key in field_map:
1311 webnotes.conn.set_value('Email Settings',None,key, \
1312 webnotes.conn.get_value('Support Email Settings',None,field_map[key]))
Brahma K09307622011-07-27 12:03:34 +05301313
Rushabh Mehta391aa022011-07-25 14:07:50 +05301314 # delete support email settings
1315 from webnotes.model import delete_doc
1316 delete_doc('DocType', 'Support Email Settings')
1317
Rushabh Mehta9b8fad22011-07-25 14:45:42 +05301318 reload_doc('support','doctype','support_ticket')
Nabin Hait587ac5c2011-07-26 15:46:10 +05301319 sql("delete from tabDocField where fieldname='problem_description' and parent='Support Ticket'")
1320 elif patch_no == 328:
nabinhaite6526362011-07-19 18:09:26 +05301321 if webnotes.conn.get_value('Control Panel', None, 'account_id') != 'axjanak2011':
1322 sql("delete from `tabDocField` where fieldname = 'supplier_status' and parent = 'Supplier'")
Nabin Hait587ac5c2011-07-26 15:46:10 +05301323 elif patch_no == 329:
nabinhaitde9826c2011-07-20 18:02:59 +05301324 reload_doc('utilities', 'doctype', 'rename_tool')
1325 reload_doc('utilities', 'doctype', 'bulk_rename_tool')
Brahma K09307622011-07-27 12:03:34 +05301326 elif patch_no == 330:
1327 reload_doc('accounts', 'doctype', 'lease_agreement')
1328 reload_doc('accounts', 'doctype', 'lease_installment')
1329
1330 reload_doc('accounts', 'search_criteria', 'lease_agreement_list')
1331 reload_doc('accounts', 'search_criteria', 'lease_monthly_future_installment_inflows')
1332 reload_doc('accounts', 'search_criteria', 'lease_overdue_age_wise')
Nabin Haitf541b742011-07-28 15:33:42 +05301333 reload_doc('accounts', 'search_criteria', 'lease_over_due_list')
Brahma K09307622011-07-27 12:03:34 +05301334 reload_doc('accounts', 'search_criteria', 'lease_receipts_client_wise')
1335 reload_doc('accounts', 'search_criteria', 'lease_receipt_summary_year_to_date')
1336 reload_doc('accounts', 'search_criteria', 'lease_yearly_future_installment_inflows')
Brahma Kbcdade52011-07-27 12:11:09 +05301337
1338 reload_doc('accounts', 'Module Def', 'Accounts')
Brahma K3b1ebe02011-07-27 13:04:11 +05301339 elif patch_no == 331:
1340 p = get_obj('Patch Util')
1341 # permission
1342 p.add_permission('Lease Agreement', 'Accounts Manager', 0, read = 1, write=1,submit=1, cancel=1,amend=1)
1343 p.add_permission('Lease Agreement', 'Accounts Manager', 1, read = 1)
Nabin Haitd29916b2011-07-27 14:26:23 +05301344 elif patch_no == 332:
1345 sql("update `tabDocField` set permlevel=1, hidden = 1 where parent = 'Bulk Rename Tool' and fieldname = 'file_list'")
Nabin Hait812e7182011-08-05 11:10:30 +05301346 elif patch_no == 333:
Nabin Haitd31de592011-08-10 14:01:27 +05301347 sql("update `tabDocPerm` set `create` =1 where role = 'Accounts Manager' and parent = 'Lease Agreement'")
Nabin Hait812e7182011-08-05 11:10:30 +05301348
1349 p = get_obj('Patch Util')
1350 p.add_permission('DocType Mapper', 'System Manager', 0, read = 1, write=1, create=1)
1351 p.add_permission('Role', 'System Manager', 0, read = 1, write=1, create=1)
1352 p.add_permission('Print Format', 'System Manager', 0, read = 1, write=1, create=1)
Nabin Haitc4e579c2011-08-05 11:21:35 +05301353 elif patch_no == 334:
1354 reload_doc('knowledge_base', 'doctype', 'answer')
Nabin Haitf82b1cc2011-08-05 13:23:14 +05301355 elif patch_no == 335:
Nabin Hait2c0ab732011-08-05 13:40:04 +05301356 for dt in ['Account', 'Cost Center', 'Territory', 'Item Group', 'Customer Group']:
Anand Doshib61abff2011-08-10 11:58:05 +05301357 sql("update `tabDocField` set fieldtype = 'Link', options = %s where fieldname = 'old_parent' and parent = %s", (dt, dt))
1358 elif patch_no == 336:
Anand Doshiaabf1742011-08-10 13:27:25 +05301359 reload_doc('server_tools','page','billing')
1360 elif patch_no == 337:
1361 item_list = webnotes.conn.sql("""SELECT name, description_html
1362 FROM tabItem""")
1363 if item_list:
1364 for item, html in item_list:
1365 if html and "getfile" in html and "acx" in html:
1366 ac_id = webnotes.conn.sql("""SELECT value FROM `tabSingles` WHERE doctype='Control Panel' AND field='account_id'""")
1367 sp_acx = html.split("acx=")
1368 l_acx = len(sp_acx)
1369 if l_acx > 1:
1370 for i in range(l_acx-1):
1371 sp_quot = sp_acx[i+1].split('"')
1372 if len(sp_quot) > 1: sp_quot[0] = str(ac_id[0][0])
1373 sp_acx[i+1] = '"'.join(sp_quot)
1374 html = "acx=".join(sp_acx)
Nabin Haitd31de592011-08-10 14:01:27 +05301375 webnotes.conn.sql("""UPDATE tabItem SET description_html=%s WHERE name=%s""", (html, item))