blob: f422610aeec17ec6c32b0449241b536350e311e7 [file] [log] [blame]
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301# REMEMBER to update this
2# ========================
nabinhaita56fc002011-07-01 16:32:03 +05303
Brahma K09307622011-07-27 12:03:34 +05304last_patch = 330
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:
Rushabh Mehta393e70b2011-08-02 13:05:09 +053059<<<<<<< HEAD
Brahma K09307622011-07-27 12:03:34 +053060
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +053061 import_from_files(record_list=[['material_management','doctype','item']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +053062=======
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +053063
Nabin Hait31a407d2011-07-28 11:47:45 +053064 import_from_files(record_list=[['stock','doctype','item']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +053065>>>>>>> stable
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +053066 elif patch_no == 42:
67 acc = sql("select name, lft, rgt from tabAccount where account_name in ('Incomes', 'Expenses')")
68 for d in acc:
69 sql("update tabAccount set is_pl_account = 'Yes' where lft >= '%s' and rgt <= '%s'" % (d[1], d[2]))
70 elif patch_no == 43:
71 import webnotes.model
72 webnotes.model.delete_doc('Page', 'Module Manager')
Brahma K09307622011-07-27 12:03:34 +053073
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +053074 # cleanup of Service, Customer Support, Utilities Modules
75 # -------------------------------------------------------
76 elif patch_no == 44:
77 from webnotes.model import delete_doc
78
79 for dt in sql("select name from tabDocType where module in ('Customer Support')"):
80 delete_doc('DocType', dt[0])
81
82 for dt in sql("select name from `tabSearch Criteria` where module in ('Customer Support')"):
83 delete_doc('Search Criteria', dt[0])
84
85 for dt in sql("select name from tabPage where module in ('Customer Support')"):
86 delete_doc('Page', dt[0])
87
88 # move a couple
89 webnotes.conn.sql("update `tab%s` set module=%s where name=%s" % ('DocType', '%s', '%s'), ('Application Internal', 'Patch Util'))
90 webnotes.conn.sql("update `tab%s` set module=%s where name=%s" % ('DocType', '%s', '%s'), ('Application Internal', 'DocType Property Setter'))
91
92 # remove utilities
93 webnotes.conn.sql('delete from `tabModule Def` where name in ("Customer Support", "Utilities")')
Brahma K09307622011-07-27 12:03:34 +053094
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +053095 elif patch_no == 45:
96 webnotes.conn.sql('delete from tabDocField where options="Ticket Response Detail"')
97
98 elif patch_no == 46:
99 import webnotes
100 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.")
101 webnotes.conn.set_global("system_message_id", "2")
102
103 elif patch_no == 47:
104 import webnotes
105 webnotes.conn.set_global("system_message", "")
106 webnotes.conn.set_global("system_message_id", "3")
107
108 elif patch_no == 48:
109 webnotes.conn.sql("update tabDocField set options = 'Print Heading' where fieldname = 'select_print_heading'")
110
111 elif patch_no == 49:
112 webnotes.conn.sql("update tabDocType set autoname = '' where name = 'Search Criteria'")
113 elif patch_no == 50:
114 sql("update tabDocField set in_filter = 1 where fieldname in ('cost_center', 'income_account', 'Item Group') and parent = 'RV Detail'")
115 elif patch_no == 51:
116 sql("update tabDocField set options = 'link:Print Heading' where fieldtype = 'Select' and fieldname = 'select_print_heading' and parent = 'POS Setting'")
117 elif patch_no == 52:
118 sql("update tabDocField set print_hide = 1 where fieldname = 'letter_head'")
119 elif patch_no == 53:
120 sql("update tabDocType set search_fields = 'lead_name,lead_owner,status,contact_by,contact_date' where name = 'Lead'")
121 elif patch_no == 54:
122 sql("delete from tabDocField where parent = 'Supplier' and label = 'Supplier Contacts' and fieldtype = 'Section Break'")
123 elif patch_no == 55:
124 sql("commit")
125 try:
126 sql("alter table tabFeed add column `_user_tags` varchar(180)")
127 except Exception, e:
128 if e.args[0]!=1060:
129 raise e
130 elif patch_no == 56:
131 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'")
132 elif patch_no == 57:
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530133<<<<<<< HEAD
Brahma K09307622011-07-27 12:03:34 +0530134
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530135 import_from_files(record_list=[['crm','doctype','sales_order_detail']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530136=======
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530137
Nabin Hait31a407d2011-07-28 11:47:45 +0530138 import_from_files(record_list=[['selling','doctype','sales_order_detail']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530139>>>>>>> stable
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530140 elif patch_no == 58:
141 # module def patches
142 sql("update `tabModule Def` set module_page = NULL where name not in ('Event Updates', 'Setup', 'My Company')")
143 sql("delete from `tabModule Def Item` where doc_type in ('Separator', 'Setup Forms', 'More Reports')")
144 sql("delete from `tabModule Def Item` where doc_name = 'Project Activity'")
145 sql("update `tabModule Def` set module_label = 'People', disabled='No', is_hidden='No' where name = 'My Company'")
Brahma K09307622011-07-27 12:03:34 +0530146
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530147 # insert new module items
148 from webnotes.model.doc import make_autoname
149 if not sql("select name from `tabModule Def Item` where parent='Projects' and doc_name='Ticket'"):
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, 'Forms', 'Ticket', 'Task', 1)""", make_autoname('MDI.#####'))
153
154 if not sql("select name from `tabModule Def Item` where parent='Projects' and doc_name='Timesheet'"):
Brahma K09307622011-07-27 12:03:34 +0530155 sql("""insert into `tabModule Def Item`
156 (name, parent, parenttype, parentfield, docstatus, doc_type, doc_name, display_name, idx) values
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530157 (%s, 'Projects', 'Module Def', 'items', 0, 'Forms', 'Timesheet', 'Timesheet', 2)""", make_autoname('MDI.#####'))
Brahma K09307622011-07-27 12:03:34 +0530158
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530159 if not sql("select name from `tabModule Def Item` where parent='Projects' and doc_name='Projects'"):
Brahma K09307622011-07-27 12:03:34 +0530160 sql("""insert into `tabModule Def Item`
161 (name, parent, parenttype, parentfield, docstatus, doc_type, doc_name, display_name, idx) values
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530162 (%s, 'Projects', 'Module Def', 'items', 0, 'Pages', 'Projects', 'Gantt Chart', 1)""", make_autoname('MDI.#####'))
Brahma K09307622011-07-27 12:03:34 +0530163
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530164 elif patch_no == 59:
165 webnotes.conn.set_value('Control Panel',None,'mail_footer','')
166 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>')
167 elif patch_no == 60:
168 sql("delete from `tabModule Def Item` where display_name = 'Point of Sales'")
169 elif patch_no == 61:
170 sql("delete from `tabTDS Category Account` where company not in (select name from tabCompany)")
171 elif patch_no == 62:
172 # Import Supplier Quotation
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530173<<<<<<< HEAD
Brahma K09307622011-07-27 12:03:34 +0530174
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530175 import_from_files(record_list=[['srm','doctype','supplier_quotation']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530176=======
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530177
Nabin Hait31a407d2011-07-28 11:47:45 +0530178 import_from_files(record_list=[['buying','doctype','supplier_quotation']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530179>>>>>>> stable
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530180 # Adding Status Filter
181 sql("update tabDocType set search_fields = concat('status,',search_fields) where name IN ('Delivery Note','Leave Transaction')")
182 # Import Other Charges
Brahma K09307622011-07-27 12:03:34 +0530183
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530184 import_from_files(record_list=[['setup','doctype','other_charges']])
185 elif patch_no == 63:
186 sql("update `tabDocField` set permlevel = 1 where fieldname in ('return_date', 'return_details') and parent = 'Sales and Purchase Return Wizard'")
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530187<<<<<<< HEAD
Brahma K09307622011-07-27 12:03:34 +0530188
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530189 import_from_files(record_list = [['accounts', 'doctype', 'rv_detail'], ['material_management', 'doctype', 'sales_and_purchase_return_wizard'], ['material_management', 'doctype', 'stock_entry']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530190=======
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530191
Nabin Hait31a407d2011-07-28 11:47:45 +0530192 import_from_files(record_list = [['accounts', 'doctype', 'rv_detail'], ['stock', 'doctype', 'sales_and_purchase_return_wizard'], ['stock', 'doctype', 'stock_entry']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530193>>>>>>> stable
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530194 elif patch_no == 64:
195 sql("update tabDocField set `hidden` = 1, `print_hide` = 1, `report_hide` = 1 where options in ('RFQ','Supplier Quotation')")
196 sql("update tabDocType set `read_only` = 1, in_create = 1 where name in ('RFQ','Supplier Quotation')")
197 sql("update tabDocField set `report_hide` = 0 where fieldname in ('email_id','phone_1','fax_1') and parent = 'Customer'")
198 elif patch_no == 65:
199 # Monthly Trend Analyzer <-> Trend Analyzer
200 sql("update `tabSearch Criteria` set criteria_name = 'Trend Analyzer' where criteria_name = 'Monthly Trend Analyzer' and name = 'SRCH/00159'")
201 sql("update `tabModule Def Item` set display_name = 'Trend Analyzer' where parent = 'Analysis' and display_name = 'Monthly Trend Analyzer'")
202 elif patch_no == 66:
203 import webnotes
204 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!""")
205 webnotes.conn.set_global("system_message_id", "4")
Brahma K09307622011-07-27 12:03:34 +0530206
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530207 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')")
208 from webnotes.session_cache import clear_cache
209 clear_cache(webnotes.session['user'])
210 elif patch_no == 67:
211 sql("update `tabDocField` set in_filter = 1 where fieldname = 'brand' and parent = 'RV Detail'")
212 sql("delete from `tabModule Def Item` where (display_name = 'Sales Invoice' and parent = 'CRM') or (display_name = 'Purchase Invoice' and parent = 'SRM')")
213 elif patch_no == 68:
214 from webnotes.modules.import_module import import_from_files
Nabin Hait31a407d2011-07-28 11:47:45 +0530215 import_from_files(record_list=[['hr','doctype','employee'],['roles','Role','Employee']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530216 elif patch_no == 69:
217 # delete flds from employee master
218 p = get_obj('Patch Util')
219 emp_del_flds = ['month_of_birth']
220 for f in emp_del_flds:
221 p.delete_field('Employee', f)
222
223 sql("Update tabDocField set `default` = 'Active' where fieldname = 'status' and parent = 'Employee'")
224
225 # map parent flds
226 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']
227
228 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")
229 for e in emp_prof:
230 prof_obj = get_obj('Employee Profile', e[0])
231 emp_obj = get_obj('Employee', e[1])
232 for d in fld_map:
233 emp_obj.doc.fields[d] = prof_obj.doc.fields[d]
234 emp_obj.doc.current_accommodation_type = prof_obj.doc.present_accommodation_type
Brahma K09307622011-07-27 12:03:34 +0530235
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530236 # address
237 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])
238 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])
239 emp_obj.doc.permanent_address = per_addr
240 emp_obj.doc.current_address = cur_addr
241 #family
242 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])
243 emp_obj.doc.family_background = fam
244 # health
245 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])
246 emp_obj.doc.health_details = health
247 emp_obj.doc.save()
248
249
250 # map tables
251 tbl_list = ['Experience In Company Detail', 'Previous Experience Detail', 'Educational Qualifications Detail']
252 for t in tbl_list:
253 sql("update `tab%s` t1, `tabEmployee Profile` t2 set t1.parent = t2.employee, t1.parenttype = 'Employee' where t1.parent = t2.name" % t)
254
255
256 # overwrite idx?????????
257
258
259 # delete emp profile
260 webnotes.model.delete_doc('DocType', 'Employee Profile')
261 for e in emp_prof:
262 webnotes.model.delete_doc('Employee Profile', e[0])
263
264 elif patch_no == 70:
265 # update search criteria module -> System
266 sql("update tabDocType set module='System' where name='Search Criteria'")
Brahma K09307622011-07-27 12:03:34 +0530267
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530268 # Cleanups to Contact
269 sql("update tabDocField set fieldtype='Data' where options='Designation' and parent='Contact'")
270 sql("update tabDocField set fieldtype='Data' where options='Department' and parent='Contact'")
271 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'")
272
273 # import Contact, Employee
274 from webnotes.modules.import_module import import_from_files
Nabin Hait31a407d2011-07-28 11:47:45 +0530275 import_from_files(record_list=[['utilities','doctype','contact']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530276
Brahma K09307622011-07-27 12:03:34 +0530277
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530278 # remove last_contact_date from Lead
279 sql("delete from tabDocField where fieldname='last_contact_date' and parent='Lead'")
Brahma K09307622011-07-27 12:03:34 +0530280
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530281 elif patch_no == 71:
282 # Make Stock Qty and Conversion Factor field editable. Also no need to mention Conversion factor in table can do it directly
283 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')")
284 sql("update `tabDocField` set `width` = '100px' where parent IN ('PO Detail','Purchase Receipt Detail') and fieldname = 'stock_uom'")
285
286 elif patch_no == 72:
287 # Core Patch
288 # ----------
Brahma K09307622011-07-27 12:03:34 +0530289
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530290 from webnotes.modules.import_module import import_from_files
Brahma K09307622011-07-27 12:03:34 +0530291
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530292 # import module def
293 import_from_files(record_list = [['core', 'Module Def', 'Core']])
294 elif patch_no == 73:
295 # set module in DocTypes
296 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 +0530297
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530298 # set module in Page
299 sql("update tabPage set module='Core' where name='Login Page'")
Brahma K09307622011-07-27 12:03:34 +0530300
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530301 # move file browser to Tools
302 sql("update tabPage set module='Tools' where name='File Browser'")
303 sql("update tabDocType set module='Tools' where name='File Browser Control'")
304 sql("update tabDocType set module='Application Internal' where name='Profile Control'")
305 elif patch_no == 74:
306 p = get_obj('Patch Util')
307 # permission
308 p.delete_permission('Employee', 'Administrator', 0)
309 p.delete_permission('Employee', 'Administrator', 1)
310 p.add_permission('Employee', 'Employee', 0, read = 1, match = 'owner')
311 p.add_permission('Employee', 'Employee', 1, read = 1, match = 'owner')
312 sql("delete from `tabDocField` where parent = 'Employee' and label = 'Payroll Rule'")
313 elif patch_no == 75:
314 #sal structure patch
315 # import
316 from webnotes.modules.import_module import import_from_files
Nabin Hait31a407d2011-07-28 11:47:45 +0530317 import_from_files(record_list=[['hr','doctype','salary_structure'], ['hr','doctype','earning_detail'],['hr','doctype','deduction_detail']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530318 elif patch_no == 76:
319 # property
320 p = get_obj('Patch Util')
321 p.set_field_property('Salary Structure', 'is_active', 'default', 'Yes')
322 p.set_field_property('Salary Structure', 'ctc', 'reqd', '1')
323 p.set_field_property('Earning Detail', 'modified_value', 'width', '')
324 p.set_field_property('Earning Detail', 'modified_value', 'trigger', 'Client')
325 p.set_field_property('Deduction Detail', 'd_modified_amt', 'width', '')
326 p.set_field_property('Earning Detail', 'd_modified_amt', 'trigger', 'Client')
327 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'")
328
329 # delete
330 sql("update `tabSalary Structure` set net_pay = total")
331 sql("delete from tabDocField where label in ('LWP Help', 'Calculate Total', 'Total') and parent = 'Salary Structure'")
332 sql("delete from tabDocPerm where parent in ('Earning Detail', 'Deduction Detail')")
333
334
335 # permission
336 p.delete_permission('Salary Structure', 'Administrator', 0)
337 p.delete_permission('Salary Structure', 'Administrator', 1)
338 p.add_permission('Salary Structure', 'Employee', 0, read = 1, match = 'owner')
339 p.add_permission('Salary Structure', 'Employee', 1, read = 1, match = 'owner')
340 elif patch_no == 77:
341 # sal slip patch
342 # import
343 from webnotes.modules.import_module import import_from_files
Nabin Hait31a407d2011-07-28 11:47:45 +0530344 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 +0530345 elif patch_no == 78:
346 p = get_obj('Patch Util')
347 # delete
348 sql("update `tabSalary Slip` set leave_encashment_amount = encashment_amount")
349 p.delete_field('Salary Slip', 'encashment_amount')
350 p.delete_field('Salary Slip', 'year')
351 p.delete_field('Salary Slip', 'flag')
352 sql("delete from tabDocField where label = 'Process Payroll' and parent = 'Salary Slip'")
353
354 # field property
355 p.set_field_property('Salary Slip', 'bank_name', 'permlevel', '1')
356 p.set_field_property('Salary Slip', 'leave_without_pay', 'permlevel', '0')
357 p.set_field_property('Salary Slip', 'leave_without_pay', 'trigger', 'Client')
358 p.set_field_property('SS Earning Detail', 'e_type', 'permlevel', '0')
359 p.set_field_property('SS Earning Detail', 'e_type', 'fieldtype', 'Link')
360 p.set_field_property('SS Earning Detail', 'e_type', 'options', 'Earning Type')
361 p.set_field_property('SS Deduction Detail', 'd_type', 'permlevel', '0')
362 p.set_field_property('SS Deduction Detail', 'd_type', 'fieldtype', 'Link')
363 p.set_field_property('SS Deduction Detail', 'd_type', 'options', 'Deduction Type')
364 sql("update `tabSS Earning Detail` set e_modified_amount = e_amount")
365 sql("update `tabSS Deduction Detail` set d_modified_amount = d_amount")
366
367 # permission
368 p.delete_permission('Salary Slip', 'Administrator', 0)
369 p.delete_permission('Salary Slip', 'Administrator', 1)
370 p.add_permission('Salary Slip', 'Employee', 0, read = 1, match = 'owner')
371 p.add_permission('Salary Slip', 'Employee', 1, read = 1, match = 'owner')
372 elif patch_no == 79:
373 # Import Modules
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530374<<<<<<< HEAD
Brahma K09307622011-07-27 12:03:34 +0530375
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530376 import_from_files(record_list=[['payroll','doctype','leave_application'],['payroll','doctype','leave_allocation'],['payroll','doctype','leave_control_panel'],['payroll','doctype','holiday_list'],['payroll','doctype','holiday_list_detail'],['payroll','Module Def','Payroll']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530377=======
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530378
Nabin Hait31a407d2011-07-28 11:47:45 +0530379 import_from_files(record_list=[['hr','doctype','leave_application'],['hr','doctype','leave_allocation'],['hr','doctype','leave_control_panel'],['hr','doctype','holiday_list'],['hr','doctype','holiday_list_detail'],['hr','Module Def','Payroll']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530380>>>>>>> stable
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530381 elif patch_no == 80:
382 # Holiday List
383 sql("update `tabHoliday List Detail` set description = holiday_name")
384 sql("delete from tabDocField where parent = 'Holiday List Detail' and fieldname = 'holiday_name'")
385 sql("update tabDocField set fieldtype = 'Select', options = 'link:Fiscal Year' where parent = 'Holiday List' and fieldname = 'fiscal_year'")
386 sql("delete from tabDocPerm where role in ('Administrator','HR User') and parent = 'Holiday List'")
387
388 # Leave Control Panel
389 # --------------------
390 sql("delete from `tabDocField` where parent = 'Leave Control Panel' and label in ('Leave Control Panel','Allocation Details') and fieldtype = 'Section Break'")
391 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')")
392 sql("update tabDocField set fieldtype = 'Select', options = 'link:Fiscal Year' where parent = 'Leave Control Panel' and fieldname = 'fiscal_year'")
393 sql("update tabDocField set fieldtype = 'Select', options = 'link:Leave Type' where parent = 'Leave Control Panel' and fieldname = 'leave_type'")
394 sql("update tabDocField set reqd = 1 where parent = 'Leave Control Panel' and fieldname = 'no_of_days'")
395
396 # Leave Application
397 # ------------------
398 for d in sql("select * from `tabLeave Transaction` where leave_transaction_type = 'Deduction' and ifnull(deduction_type, '') = 'Leave'", as_dict = 1):
399 lp = Document('Leave Application')
400 lp.employee = d['employee']
401 lp.leave_type = d['leave_type']
402 lp.posting_date = d['date']
403 lp.fiscal_year = d['fiscal_year']
404 lp.leave_balance = d['pre_balance']
405 lp.half_day = d['half_day']
406 lp.from_date = d['from_date']
407 lp.to_date = d['to_date']
408 lp.total_leave_days = d['total_leave']
409 lp.description = d['reason']
410 lp.docstatus = cint(d['docstatus'])
411 lp.save(1)
412
413 # Leave Allocation
414 # -----------------
415 for d in sql("select * from `tabLeave Transaction` where leave_transaction_type = 'Allocation'", as_dict = 1):
416 la = Document('Leave Allocation')
417 la.employee = d['employee']
418 la.leave_type = d['leave_type']
419 la.posting_date = d['date']
420 la.fiscal_year = d['fiscal_year']
421 la.new_leaves_allocated = d['total_leave']
422 la.total_leaves_allocated = d['total_leave']
423 la.description = d['reason']
424 la.docstatus = cint(d['docstatus'])
425 la.save(1)
426
427 # Payroll Module Def
428 # -------------------
429 sql("delete from `tabModule Def Item` where doc_name = 'Leave Transaction' and display_name = 'Leave Transaction' and parent = 'Payroll' and doc_type = 'Forms'")
430
431 elif patch_no == 81:
432 # Import Modules
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530433<<<<<<< HEAD
Brahma K09307622011-07-27 12:03:34 +0530434
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530435 import_from_files(record_list=[['payroll','Module Def','Payroll']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530436=======
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530437
Nabin Hait31a407d2011-07-28 11:47:45 +0530438 import_from_files(record_list=[['hr','Module Def','Payroll']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530439>>>>>>> stable
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530440 elif patch_no == 82:
441 sql("update tabDocType set search_fields = 'employee,leave_type,total_leaves_allocated,fiscal_year' where name = 'Leave Allocation'")
442 sql("update tabDocType set search_fields = 'employee,leave_type,from_date,to_date,total_leave_days,fiscal_year' where name = 'Leave Application'")
443 elif patch_no == 83:
444 # delete leave transaction
445 webnotes.conn.sql("set foreign_key_checks=0")
446 sql("delete from `tabLeave Transaction`")
447 import webnotes.model
448 webnotes.model.delete_doc('DocType','Badge Settings Detail')
449 webnotes.model.delete_doc('DocType','Leave Transaction')
450 webnotes.conn.sql("set foreign_key_checks=1")
451 elif patch_no == 84:
452 p = get_obj('Patch Util')
453 p.set_field_property('SS Earning Detail', 'e_amount', 'permlevel', '1')
454 p.set_field_property('SS Deduction Detail', 'd_amount', 'permlevel', '1')
455 elif patch_no == 85:
456 # permission
457 p = get_obj('Patch Util')
458 p.add_permission('Leave Application', 'Employee', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1, match = 'owner')
459 p.add_permission('Leave Application', 'Employee', 1, read = 1, match = 'owner')
460 p.add_permission('Leave Allocation', 'HR User', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1, match = 'owner')
461 p.add_permission('Leave Allocation', 'HR User', 1, read = 1)
462 sql("update tabDocPerm set `match` = '' where parent = 'Leave Application' and role = 'HR User'")
463 elif patch_no == 86:
464 # Import Modules
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530465<<<<<<< HEAD
Brahma K09307622011-07-27 12:03:34 +0530466
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530467 import_from_files(record_list=[['payroll','doctype','leave_type']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530468=======
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530469
Nabin Hait31a407d2011-07-28 11:47:45 +0530470 import_from_files(record_list=[['hr','doctype','leave_type']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530471>>>>>>> stable
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530472 elif patch_no == 87:
473 sql("update `tabLeave Type` set is_lwp = 1 where name = 'Leave Without Pay'")
474 elif patch_no == 88:
475 # Import Modules
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530476<<<<<<< HEAD
Brahma K09307622011-07-27 12:03:34 +0530477
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530478 import_from_files(record_list=[['payroll','doctype','leave_allocation']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530479=======
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530480
Nabin Hait31a407d2011-07-28 11:47:45 +0530481 import_from_files(record_list=[['hr','doctype','leave_allocation']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530482>>>>>>> stable
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530483 elif patch_no == 89:
484 sql("delete from `tabModule Def Item` where doc_type = 'Setup Forms' and doc_name in ('Payroll Rule', 'IT Checklist', 'Employee Profile') and parent = 'Payroll'")
485 sql("update `tabDocField` set `hidden` = 1, `print_hide` = 1, `report_hide` = 1 where parent = 'Leave Type' and fieldname = 'is_encash'")
486 elif patch_no == 90:
487 sql("update `tabLeave Allocation` set docstatus = 1")
488 elif patch_no == 91:
489 import webnotes
490 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!""")
491 webnotes.conn.set_global("system_message_id", "5")
492 elif patch_no == 92:
493 sql("update tabDocField set label = 'Get Charges' where parent IN ('Sales Order','Delivery Note','Receivable Voucher') and label = 'Get Other Charges' and fieldtype = 'Button'")
494 # Automated Other Charges Calculation basis
495 sql("update tabDocField set options = '', `trigger` = 'Client' where parent IN ('Quotation','Sales Order','Delivery Note','Receivable Voucher') and label = 'Get Charges' and fieldtype = 'Button'")
496 elif patch_no == 93:
497 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'")
498 sql("update `tabField Mapper Detail` set from_field = 'customer' where to_field = 'customer' and parent = 'Sales Order-Receivable Voucher'")
499 elif patch_no == 94:
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530500<<<<<<< HEAD
Brahma K09307622011-07-27 12:03:34 +0530501
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530502 import_from_files(record_list=[['crm','doctype','sms_center']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530503=======
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530504
Nabin Hait31a407d2011-07-28 11:47:45 +0530505 import_from_files(record_list=[['selling','doctype','sms_center']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530506>>>>>>> stable
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530507 elif patch_no == 95:
Brahma K09307622011-07-27 12:03:34 +0530508
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530509 import_from_files(record_list=[['mapper','DocType Mapper','Sales Order-Receivable Voucher'], ['mapper','DocType Mapper','Delivery Note-Receivable Voucher']])
510 elif patch_no == 96:
511 sql("delete from `tabModule Def Item` where doc_type = 'Reports' and display_name = 'Cenvat Credit - Input or Capital Goods' and parent = 'Accounts'")
512 elif patch_no == 97:
513 sql("update tabFeed set doc_label = 'Feed', doc_name = name where ifnull(doc_name,'') = '' and ifnull(doc_label,'') = ''")
514 elif patch_no == 98:
515 import_from_files(record_list=[['accounts','doctype','payable_voucher']])
516 elif patch_no == 99:
517 import_from_files(record_list=[['accounts','doctype','account']])
518 elif patch_no == 100:
519 p = get_obj('Patch Util')
520 p.set_field_property('Account', 'level', 'hidden', '1')
521 p.set_field_property('Account', 'level', 'print_hide', '1')
522 p.set_field_property('Account', 'account_type', 'search_index', '0')
523 p.set_field_property('TDS Detail', 'tds_category', 'width', '150px')
524 p.set_field_property('TDS Detail', 'special_tds_rate_applicable', 'width', '150px')
525 p.set_field_property('TDS Detail', 'special_tds_rate', 'width', '150px')
526 p.set_field_property('TDS Detail', 'special_tds_limit', 'width', '150px')
527 elif patch_no == 101:
528 # Leave Application Details and Leave Allocation Details
529 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')")
530 get_obj('DocType','Leave Application').doc.save()
531 get_obj('DocType','Leave Allocation').doc.save()
532 elif patch_no == 102:
533 # make item description field editable in production order
534 sql("update tabDocField set permlevel = 0 where fieldname = 'description' and parent = 'Production Order'")
535 elif patch_no == 103:
536 sql("update tabDocField set fieldname = '' where fieldtype = 'HTML'")
537 elif patch_no == 104:
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530538<<<<<<< HEAD
Brahma K09307622011-07-27 12:03:34 +0530539
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530540 import_from_files(record_list=[['payroll','search_criteria','stdsrch_00001'],['payroll','search_criteria','stdsrch_00002'],['payroll','search_criteria','stdsrch_00003'],['payroll','Module Def','Payroll'],['payroll','doctype','leave_application'],['payroll','doctype','leave_allocation']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530541=======
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530542
Nabin Hait31a407d2011-07-28 11:47:45 +0530543 import_from_files(record_list=[['hr','search_criteria','stdsrch_00001'],['hr','search_criteria','stdsrch_00002'],['hr','search_criteria','stdsrch_00003'],['hr','Module Def','Payroll'],['hr','doctype','leave_application'],['hr','doctype','leave_allocation']])
Rushabh Mehta393e70b2011-08-02 13:05:09 +0530544>>>>>>> stable
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530545 elif patch_no == 105:
546 # Employee Leave Balance
547 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')")
548 # Update Search Fields
549 sql("update tabDocType set search_fields = 'employee,employee_name,leave_type,from_date,to_date,total_leave_days,fiscal_year' where name = 'Leave Application'")
550 sql("update tabDocType set search_fields = 'employee,employee_name,leave_type,total_leaves_allocated,fiscal_year' where name = 'Leave Allocation'")
551 elif patch_no == 106:
552 for d in sql("select name,employee,employee_name from `tabLeave Allocation`"):
553 if not cstr(d[2]):
554 sql("update `tabLeave Allocation` set employee_name = '%s' where name = '%s'" % (webnotes.conn.get_value('Employee',cstr(d[1]),'employee_name'), cstr(d[0])))
555 for d in sql("select name,employee,employee_name from `tabLeave Application`"):
556 if not cstr(d[2]):
557 sql("update `tabLeave Application` set employee_name = '%s' where name = '%s'" % (webnotes.conn.get_value('Employee',cstr(d[1]),'employee_name'), cstr(d[0])))
558 elif patch_no == 107:
559 sql("delete from `tabDocField` where fieldname = 'fiscal_year' and parent = 'Employee'")
560 elif patch_no == 108:
Nabin Hait31a407d2011-07-28 11:47:45 +0530561 import_from_files(record_list=[['hr','search_criteria','srch_std_00013']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530562 elif patch_no == 109:
Nabin Hait31a407d2011-07-28 11:47:45 +0530563 import_from_files(record_list=[['hr','search_criteria','srch_std_00015']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530564 elif patch_no == 110:
Nabin Hait31a407d2011-07-28 11:47:45 +0530565 import_from_files(record_list=[['hr','doctype','salary_structure'], ['hr', 'doctype', 'salary_slip']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530566 elif patch_no == 111:
567 sql("update tabDocType set search_fields = 'transfer_date, from_warehouse, to_warehouse, purpose, remarks' where name = 'Stock Entry'")
568 elif patch_no == 112:
569 sql("delete from tabDocField where label = 'Get Other Charges' and fieldtype = 'Button' and parent = 'Receivable Voucher'")
570 elif patch_no == 113:
571 sql("update tabDocField set reqd = 1 where parent = 'Customer' and fieldname = 'phone_1'")
572 elif patch_no == 114:
573 for d in sql("select name, master_name, credit_days, credit_limit from tabAccount where master_type = 'Customer'"):
574 if cstr(d[1]):
575 days, limit = cint(d[2]), flt(d[3])
576 cust_det = sql("select credit_days, credit_limit from tabCustomer where name = '%s'" % (cstr(d[1])))
577 if not days: days = cust_det and cint(cust_det[0][0]) or 0
578 if not limit: limit = cust_det and flt(cust_det[0][1]) or 0
579 sql("COMMIT")
580 sql("START TRANSACTION")
581 sql("update tabAccount set credit_days = '%s', credit_limit = '%s' where name = '%s'" % (days, limit, cstr(d[0])))
582 sql("COMMIT")
583
584 elif patch_no == 115:
585 # patch for timesheet cleanup
586 from webnotes.model import delete_doc
587 delete_doc('DocType', 'Timesheet Detail')
Brahma K09307622011-07-27 12:03:34 +0530588
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530589 from webnotes.modules.import_module import import_from_files
590 import_from_files(record_list = [['Projects', 'DocType', 'Timesheet'], ['Projects', 'DocType', 'Timesheet Detail'], ['Projects', 'DocType', 'Activity Type']])
591
592 elif patch_no == 116:
593 # again!
594 from webnotes.model import delete_doc
595 delete_doc('DocType', 'Timesheet Detail')
Brahma K09307622011-07-27 12:03:34 +0530596
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530597 from webnotes.modules.import_module import import_from_files
598 import_from_files(record_list = [['Projects', 'DocType', 'Timesheet Detail']])
599 elif patch_no == 117:
600 op = '\n' + 'Walk In'
601 sql("update `tabDocField` set `options` = concat(options, %s) where parent = 'Enquiry' and fieldname = 'source' and options not like '%%Walk%%'", op)
602 elif patch_no == 118:
603 from webnotes.utils import get_defaults
604 ss = sql("select name, net_pay from `tabSalary Slip`")
605 for d in ss:
606 if d[1]:
607 w = get_obj('Sales Common').get_total_in_words(get_defaults()['currency'], d[1])
608 sql("update `tabSalary Slip` set net_pay_in_words = '%s' where name = '%s'" % (w, d[0]))
609 elif patch_no == 119:
610 sql("update tabDocType set in_create = 1 where name = 'Profile'")
611 elif patch_no == 120:
612 sql("update tabDocField set permlevel = 0 where parent = 'Sales and Purchase Return Wizard' and fieldname = 'return_date'")
613 elif patch_no == 121:
614 import_from_files(record_list = [['CRM', 'DocType', 'Return Detail'], ['Material Management', 'DocType', 'Sales and Purchase Return Wizard']])
615 elif patch_no == 122:
616 sql("delete from tabDocField where (fieldname = 'serial_no' or label = 'Warrany Status') and parent = 'Sales Order'")
617 elif patch_no == 123:
618 import_from_files(record_list = [['CRM', 'Module Def', 'CRM'], ['CRM', 'Search Criteria', 'STDSRCH/00004']])
619 elif patch_no == 124:
620 import webnotes
621 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!""")
622 webnotes.conn.set_global("system_message_id", "5")
623 elif patch_no == 125:
624 import_from_files(record_list = [['Material Management', 'DocType', 'Delivery Note']])
625 elif patch_no == 126:
626 sql("delete from tabDocField where parent = 'Delivery Note' and label in ('Make Sales Invoice', 'Make Installation Note', 'Intro Note')")
627 elif patch_no == 127:
628 sql("delete from tabDocPerm where role = 'All' and parent = 'Expense Voucher' and (permlevel = 0 or permlevel = 2)")
629 p = get_obj('Patch Util')
630 p.add_permission('Expense Voucher', 'Employee', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1, match = 'owner')
631 p.add_permission('Expense Voucher', 'HR Manager', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1)
632 p.add_permission('Expense Voucher', 'HR User', 0, read = 1, write = 1, create = 1, submit = 1, cancel = 1, amend = 1)
633 elif patch_no == 128:
634 from webnotes.modules import import_module
Nabin Hait31a407d2011-07-28 11:47:45 +0530635 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 +0530636 elif patch_no == 129:
637 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'")
638 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'")
639 elif patch_no == 130:
640 # update from rv
641 from webnotes.model.code import get_obj
642 from webnotes.utils import cstr
643 for d in sql("select name, docstatus from `tabReceivable Voucher` where ifnull(docstatus,0) != 0"):
644 sql("COMMIT")
645 sql("START TRANSACTION")
646 try:
647 obj = get_obj('Receivable Voucher', cstr(d[0]), with_children = 1)
648 is_submit = 1
649 if cint(d[1]) == 2: is_submit = 0
650 get_obj('Sales Common').update_prevdoc_detail(is_submit, obj)
651 except:
652 pass
653 sql("COMMIT")
654
655 # update from dn
656 from webnotes.model.code import get_obj
657 for d in sql("select name, docstatus from `tabDelivery Note` where ifnull(docstatus,0) != 0"):
658 sql("COMMIT")
659 sql("START TRANSACTION")
660 try:
661 obj = get_obj('Delivery Note', cstr(d[0]), with_children = 1)
662 is_submit = 1
663 if cint(d[1]) == 2: is_submit = 0
664 get_obj('Sales Common').update_prevdoc_detail(is_submit, obj)
665 except:
666 pass
667 sql("COMMIT")
668 elif patch_no == 131:
669 sql("update `tabDocType` set allow_trash = 1 where name = 'Purchase Other Charges'")
670 sql("update tabDocPerm set `cancel` = 1 where parent = 'Purchase Other Charges' and permlevel = 0 and `read` = 1 and `write` = 1")
671 elif patch_no == 132:
672 sql("update tabDocField set no_copy = 0 where parent = 'Receivable Voucher' and fieldname = 'customer'")
673 elif patch_no == 133:
674 from webnotes.modules import import_module
675 import_module.import_from_files(record_list=[['accounts','doctype','receivable_voucher']])
676 elif patch_no == 134:
677 sql("update tabDocField set no_copy = 1 where parent = 'Receivable Voucher' and fieldname = 'posting_time'")
678 elif patch_no == 135:
679 sql("update tabDocField set `default` = 'Today' where parent = 'Receivable Voucher' and fieldname = 'due_date'")
680 elif patch_no == 136:
681 from webnotes.modules import import_module
682 import_module.import_from_files(record_list=[['accounts','doctype','rv_detail']])
683 elif patch_no == 137:
684 from webnotes.modules import import_module
685 import_module.import_from_files(record_list=[['setup','doctype','price_list']])
686 elif patch_no == 138:
687 sql("update `tabDocType` set allow_attach = 1 where name = 'Price List'")
688 elif patch_no == 139:
689 from webnotes.modules import import_module
690 import_module.import_from_files(record_list=[['mapper','DocType Mapper','Sales Order-Receivable Voucher'], ['mapper','DocType Mapper','Delivery Note-Receivable Voucher']])
691 elif patch_no == 140:
692 from webnotes.modules import import_module
693 import_module.import_from_files(record_list=[['accounts','doctype','rv_detail']])
694 elif patch_no == 141:
695 sql("delete from tabDocField where (fieldname = 'letter_head' or label = 'Letter Head') and parent = 'Company'")
696 elif patch_no == 142:
697 # fixes to letter head and personalize
698 from webnotes.model import delete_doc
Brahma K09307622011-07-27 12:03:34 +0530699
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530700 delete_doc('DocType', 'Batch Settings')
701 delete_doc('DocType', 'Batch Settings Detail')
702 delete_doc('DocType', 'Social Badge')
703 delete_doc('Page', 'Personalize Page')
704 delete_doc('DocType', 'Personalize Page Control')
Brahma K09307622011-07-27 12:03:34 +0530705
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530706 import_from_files(record_list=[['core','doctype','letter_head'], ['setup','doctype','personalize']])
707 elif patch_no == 144:
708 webnotes.conn.sql("update tabDocField set fieldtype='Code' where parent='Letter Head' and fieldname='content'")
709 elif patch_no == 145:
710 sql("update `tabDocField` set permlevel=1 where fieldname = 'group_or_ledger' and parent = 'Account'")
711 elif patch_no == 146:
712 import_from_files(record_list=[['accounts','doctype','account']])
713 elif patch_no == 147:
714 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']])
715 elif patch_no == 148:
716 sql("delete from `tabDocField` where (fieldname = 'account_balances' or label = 'Balances') and parent = 'Account'")
717 sql("update tabDocType set istable = 0, section_style = 'Simple', search_fields = 'account, period, fiscal_year, balance' where name = 'Account Balance'")
718 sql("update tabDocField set permlevel = 0 where parent = 'Account Balance'")
719 p = get_obj('Patch Util')
720 p.add_permission('Account Balance', 'Accounts User', 0, read = 1)
721 p.add_permission('Account Balance', 'Accounts Manager', 0, read = 1)
722 import_from_files(record_list=[['accounts','doctype','account_balance']])
723 elif patch_no == 149:
724 sql("update `tabAccount Balance` set account = parent")
725 elif patch_no == 150:
726 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')")
727 ac_bal = Document("DocType", "Account Balance")
728 ac_bal.save()
729 elif patch_no == 151:
730 sql("delete from tabDocField where label = 'Add / Manage Contacts' and fieldtype = 'Button' and parent = 'Customer'")
731 sql("delete from `tabField Mapper Detail` where parent = 'Sales Order-Delivery Note' and from_field = 'note' and to_field = 'note'")
732 elif patch_no == 152:
Nabin Hait31a407d2011-07-28 11:47:45 +0530733 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 +0530734 elif patch_no == 153:
735 sql("delete from `tabDocField` where fieldname = 'sales_person' and parent = 'Customer'")
736 elif patch_no == 154:
Nabin Hait31a407d2011-07-28 11:47:45 +0530737 import_from_files(record_list=[['stock','doctype','serial_no'], ['support','doctype','customer_issue']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530738 elif patch_no == 155:
739 for d in sql("select name, item_code from `tabSerial No`"):
740 sql("COMMIT")
741 sql("START TRANSACTION")
742 sql("update `tabSerial No` set item_name = '%s' where name = '%s'" % (webnotes.conn.get_value('Item',cstr(d[1]),'item_name'), cstr(d[0])))
743 sql("COMMIT")
744 elif patch_no == 156:
745 sql("update tabDocField set fieldtype = 'Code' where fieldname = 'html' and parent = 'Print Format'")
746 elif patch_no == 157:
747 import_from_files(record_list=[['accounts', 'doctype', 'journal_voucher'], ['accounts', 'Print Format', 'Payment Receipt Voucher'], ['accounts', 'Print Format', 'Cheque Printing Format']])
748 elif patch_no == 158:
749 from webnotes.model.doc import addchild
750 sql("delete from tabDocField where parent = 'Customer Issue' and fieldname = 'customer_group'")
751 elif patch_no == 159:
752 sql("update tabAccount set account_type = 'Chargeable' where account_name in ('Advertising and Publicity', 'Freight & Forwarding Charges', 'Miscellaneous Expenses', 'Sales Promotion Expenses')")
753 elif patch_no == 160:
754 sql("update `tabDocType` set search_fields = 'posting_date, due_date, debit_to, fiscal_year, grand_total, outstanding_amount' where name = 'Receivable Voucher'")
755 sql("update `tabDocType` set search_fields = 'posting_date, credit_to, fiscal_year, bill_no, grand_total, outstanding_amount' where name = 'Payable Voucher'")
756 elif patch_no == 161:
757 sql("update tabDocType set autoname = 'field:batch_id' where name = 'Batch'")
758 sql("update tabDocField set no_copy = 1 where parent = 'Batch' and fieldname = 'batch_id'")
759 elif patch_no == 162:
Nabin Hait31a407d2011-07-28 11:47:45 +0530760 import_from_files(record_list=[['selling', 'search_criteria', 'sales_order_pending_items1']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530761 elif patch_no == 163:
762 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 +0530763 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 +0530764 elif patch_no == 164:
Nabin Hait31a407d2011-07-28 11:47:45 +0530765 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 +0530766 elif patch_no == 165:
767 pass
768 elif patch_no == 166:
Nabin Hait31a407d2011-07-28 11:47:45 +0530769 import_from_files(record_list=[['buying', 'doctype', 'purchase_order']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530770 elif patch_no == 167:
771 if webnotes.conn.get_value('Control Panel', None, 'account_id') not in ['ax0000956', 'ax0001338']:
772 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')")
773 elif patch_no == 168:
774 sql("update tabDocField set fieldtype = 'Data', options = 'Suggest' where fieldname = 'bank_name' and parent = 'Employee'")
775 elif patch_no == 169:
776 import_from_files(record_list=[['accounts', 'doctype', 'pv_detail'], ['accounts', 'doctype', 'rv_detail']])
777 elif patch_no == 170:
778 import_from_files(record_list=[['mapper', 'DocType Mapper', 'Delivery Note-Receivable Voucher']])
779 elif patch_no == 171:
Nabin Hait31a407d2011-07-28 11:47:45 +0530780 import_from_files(record_list=[['buying', 'doctype', 'supplier']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530781 elif patch_no == 172:
782 import webnotes
783 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>""")
784 webnotes.conn.set_global("system_message_id", "6")
785 elif patch_no == 173:
786 sql("delete from tabDocField where label = 'Get Other Charges' and parent = 'Delivery Note'")
787 sql("update tabDocField set reqd = 0 where fieldname = 'posting_time' and parent = 'Serial No'")
788 elif patch_no == 174:
789 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")
790 if c and cint(c[0][0]) > 1:
791 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")
792 elif patch_no == 175:
793 import webnotes
794 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>""")
795 webnotes.conn.set_global("system_message_id", "6")
796 elif patch_no == 176:
797 sql("update tabDocPerm set role='Guest', `write`=0, `create`=0 where role='Administrator' and parent='Notification Control' limit 1")
798 elif patch_no == 177:
799 sql("delete from `tabDocField` where label = 'Next Steps' and parent = 'Purchase Order'")
800 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'")
801 elif patch_no == 178:
Nabin Hait31a407d2011-07-28 11:47:45 +0530802 import_from_files(record_list = [['hr', 'doctype', 'salary_slip']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530803 elif patch_no == 179:
804 from webnotes.utils import get_defaults
805 sl = sql("select name, net_pay from `tabSalary Slip`")
806 for d in sl:
807 in_words = get_obj('Sales Common').get_total_in_words(get_defaults()['currency'], round(flt(d[1])))
808 sql("update `tabSalary Slip` set rounded_total = '%s', total_in_words = '%s' where name = '%s'" % (round(flt(d[1])), in_words, d[0]))
809 elif patch_no == 180:
810 sql("delete from tabDocField where parent = 'Salary Slip' and fieldname = 'net_pay_in_words'")
811 elif patch_no == 181:
812 import_from_files(record_list = [['accounts', 'doctype', 'journal_voucher']])
813 elif patch_no == 182:
814 sql("update tabDocField set options = CONCAT(options, '\nWrite Off Voucher') where fieldname = 'voucher_type' and parent = 'Journal Voucher'")
815 elif patch_no == 183:
816 sql("delete from tabDocField where label = 'SMS' and fieldtype = 'Section Break' and parent in ('Enquiry', 'Lead', 'Sales Order', 'Delivery Note')")
817 elif patch_no == 184:
818 from webnotes.model import delete_doc
819 delete_doc('DocType', 'Feed')
820 delete_doc('DocType', 'Feed List')
821 delete_doc('DocType', 'Feed Control')
822
823 # add trigger
824 from webnotes.model.triggers import add_trigger
825 add_trigger('*','*','*','event_updates.update_feed')
826
827 webnotes.conn.commit()
828
829 try:
830 sql("drop table tabFeed")
831 sql("drop table `tabFeed List`")
832 except: pass
833
834 # import
835 from webnotes.modules.module_manager import reload_doc
836 reload_doc('event_updates','doctype','feed')
837 elif patch_no==185:
838 sql("delete from tabDocTrigger where method = 'webnotes.widgets.follow.on_docsave'")
839 elif patch_no==186:
840 from webnotes.modules.module_manager import reload_doc
841 reload_doc('event_updates','doctype','feed')
842 elif patch_no == 187:
843 sql("update tabDocType set autoname = '' where name = 'QA Inspection Report'")
844 elif patch_no == 188:
Nabin Hait31a407d2011-07-28 11:47:45 +0530845 import_from_files(record_list = [['buying', 'doctype', 'qa_inspection_report']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530846 elif patch_no == 189:
847 sql("update `tabDocField` set allow_on_submit = 1 where fieldname in ('entries', 'other_charges') and parent = 'Receivable Voucher'")
848 elif patch_no == 190:
849 sql("update tabDocField set permlevel=0 where fieldname = 'fiscal_year' and parent = 'Stock Entry'")
850 elif patch_no == 191:
Nabin Hait31a407d2011-07-28 11:47:45 +0530851 import_from_files(record_list = [['support', 'doctype', 'customer_issue']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530852 elif patch_no == 192:
853 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 +0530854 import_from_files(record_list = [['buying', 'Module Def', 'SRM']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530855 elif patch_no == 193:
856 sql("update tabDocField set fieldtype='Button', `trigger`='Client' where parent='Letter Head' and fieldname='set_from_image'")
857 elif patch_no == 194:
858 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 +0530859 import_from_files(record_list = [['stock', 'Module Def', 'Material Management']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530860 elif patch_no == 195:
861 from webnotes.modules.module_manager import reload_doc
862 reload_doc('setup','doctype','manage_account')
863 elif patch_no == 196:
864 sql("update `tabModule Def` set module_page = null where name = 'Material Management'")
865 elif patch_no == 197:
866 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 +0530867 import_from_files(record_list = [['support', 'doctype', 'customer_issue']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530868 elif patch_no == 198:
869 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')")
870 sql("delete from `tabDocField` where label in ('SMS', 'Send SMS') and parent = 'Purchase Order'")
871 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')")
872 from webnotes.model import delete_doc
873 delete_doc('DocType', 'Lead SMS Detail')
874 delete_doc('DocType', 'Enquiry SMS Detail')
875 elif patch_no == 199:
876 sql("update tabDocField set reqd = 0 where parent = 'Attendance' and fieldname = 'shifts'")
877 elif patch_no == 200:
878 reload_doc('event_updates','page','profile_settings')
879 elif patch_no == 201:
880 reload_doc('setup','doctype','price_list')
881 elif patch_no == 202:
882 name1 = sql("select name from tabDocField where parent='Price List' and label='Clear Prices' limit 1,1")
883 name2 = sql("select name from tabDocField where parent='Price List' and label='Update Prices' limit 1,1")
884 if name1:
885 sql("delete from tabDocField where name=%s limit 1", name1[0][0])
886 if name2:
887 sql("delete from tabDocField where name=%s limit 1", name2[0][0])
888 elif patch_no == 203:
889 sql("delete from tabDocField where parent = 'Company' and fieldname = 'default_salary_account' limit 1")
890 elif patch_no == 204:
891 sql("delete from tabDocField where parent = 'Company' and fieldname = 'default_salary_acount' limit 1")
892 elif patch_no == 205:
893 sql("update `tabDocField` set `default` = '' where fieldname = 'naming_series' and parent = 'Installation Note'")
894 elif patch_no == 206:
Nabin Hait31a407d2011-07-28 11:47:45 +0530895 reload_doc('selling','doctype','installation_note')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530896 elif patch_no == 207:
897 import_from_files(record_list = [['setup', 'doctype', 'company']])
898 elif patch_no == 208:
899 sql("delete from `tabDocField` where (label in ('SMS', 'Send SMS') or fieldname in ('message', 'customer_mobile_no')) and parent ='Quotation'")
900 default_currency = get_obj('Manage Account').doc.default_currency
901 sql("update tabCompany set default_currency = '%s'" % default_currency)
902 elif patch_no == 209:
903 import_from_files(record_list = [['setup', 'doctype', 'company']])
904 elif patch_no == 210:
905 sql("delete FROM `tabDocField` WHERE parent = 'Lead' AND label in ('CC:','Attachment Html','Create New File','Attachment')")
906 elif patch_no == 212:
907 # reload company because of disturbed UI
908 import_from_files(record_list = [['setup', 'doctype', 'company']])
909 elif patch_no == 213:
Nabin Hait31a407d2011-07-28 11:47:45 +0530910 reload_doc('selling','doctype','lead')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530911 reload_doc('setup','doctype','company')
912 elif patch_no == 214:
Nabin Hait31a407d2011-07-28 11:47:45 +0530913 reload_doc('selling','doctype','sales_order')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530914 elif patch_no == 215:
915 # patch for item and image in description
916 sql("update tabDocField set width = '300px' where fieldname='description'")
Nabin Hait31a407d2011-07-28 11:47:45 +0530917 reload_doc('stock', 'doctype', 'item')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530918 sql("delete from __DocTypeCache")
919 elif patch_no == 216:
Nabin Hait31a407d2011-07-28 11:47:45 +0530920 import_from_files(record_list = [['stock', 'doctype', 'serial_no'], ['stock', 'doctype', 'stock_ledger_entry']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530921 elif patch_no == 217:
922 sql("update tabDocField set options = '\nIn Store\nDelivered\nNot in Use' where fieldname = 'status' and parent = 'Serial No'")
923 sql("update tabDocField set no_copy = 1 where fieldname = 'serial_no' and parent = 'Delivery Note Detail'")
924 sql("update tabDocField set no_copy = 1 where fieldname = 'serial_no' and parent = 'Stock Entry Detail'")
925 elif patch_no == 218:
926 for d in sql("select name from `tabSerial No`"):
927 sql("Commit")
928 sql("Start Transaction")
929 s = Document('Serial No', d[0])
930 if s.pr_no:
931 s.purchase_document_type = 'Purchase Receipt'
932 s.purchase_document_no = s.pr_no
933 if s.delivery_note_no:
934 s.delivery_document_type = 'Delivery Note'
935 s.delivery_document_no = s.delivery_note_no
936 if s.notes:
937 s.delivery_note_no = s.notes
938 s.company = webnotes.utils.get_defaults()['company']
939 s.fiscal_year = webnotes.utils.get_defaults()['fiscal_year']
940 s.save()
941 elif patch_no == 219:
942 sql("delete from tabDocField where fieldname in ('pr_no', 'make', 'label', 'delivery_note_no', 'notes') and parent = 'Serial No'")
943 elif patch_no == 220:
944 sql("update tabDocField set label = 'Incoming Rate' where fieldname = 'purchase_rate' and parent = 'Serial No'")
945 sql("update tabDocField set label = 'Incoming Time' where fieldname = 'purchase_time' and parent = 'Serial No'")
946 elif patch_no == 221:
947 sql("update tabDocField set reqd = 1 where fieldname in ('purchase_rate', 'warehouse') and parent = 'Serial No'")
948 elif patch_no == 222:
949 sql("update tabDocField set options = '\nDelivery Note\nReceivable Voucher\nStock Entry' where fieldname = 'delivery_document_type' and parent = 'Serial No'")
950 elif patch_no == 223:
951 sql("update tabDocField set hidden = 0 where fieldname in ('pay_to_recd_from', 'total_amount', 'total_amount_in_words') and parent = 'Journal Voucher'")
952 sql("update tabDocField set permlevel = 0 where fieldname = 'pay_to_recd_from' and parent = 'Journal Voucher'")
953 elif patch_no == 224:
Nabin Hait31a407d2011-07-28 11:47:45 +0530954 import_from_files(record_list = [['stock', 'doctype', 'delivery_note_packing_detail'], ['accounts', 'Print Format', 'Payment Receipt Voucher']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530955 elif patch_no == 225:
Nabin Hait31a407d2011-07-28 11:47:45 +0530956 import_from_files(record_list = [['stock', 'doctype', 'delivery_note_packing_detail']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530957 elif patch_no == 226:
Nabin Hait31a407d2011-07-28 11:47:45 +0530958 import_from_files(record_list = [['stock', 'doctype', 'delivery_note_packing_detail']])
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530959 elif patch_no == 227:
Nabin Hait31a407d2011-07-28 11:47:45 +0530960 reload_doc('stock', 'doctype', 'item')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530961 if webnotes.conn.get_value('Control Panel', None, 'account_id') != 'axjanak2011':
962 sql("delete from tabDocField where parent = 'Item' and fieldname='alternate_description' limit 1")
963 elif patch_no == 228:
964 # knowledge base patch
965 reload_doc('knowledge_base', 'doctype', 'question')
966 reload_doc('knowledge_base', 'doctype', 'answer')
967 reload_doc('knowledge_base', 'page', 'questions')
968 reload_doc('knowledge_base', 'Module Def', 'Knowledge Base')
969 sql("update `tabModule Def` set disabled='No' where name='Knowledge Base'")
Brahma K09307622011-07-27 12:03:34 +0530970 elif patch_no == 229:
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530971 reload_doc('knowledge_base', 'page', 'question_view')
972 elif patch_no == 230:
Nabin Hait31a407d2011-07-28 11:47:45 +0530973 reload_doc('buying', 'doctype', 'indent')
974 reload_doc('buying', 'doctype', 'indent_detail')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530975 reload_doc('Mapper', 'DocType Mapper', 'Sales Order-Indent')
976 elif patch_no == 231:
977 reload_doc('Mapper', 'DocType Mapper', 'Sales Order-Indent')
978 elif patch_no == 232:
979 sql("update `tabDocField` set options = 'Sales Order' where fieldname = 'sales_order_no' and parent = 'Indent'")
980 elif patch_no == 233:
981 reload_doc('Mapper', 'DocType Mapper', 'Sales Order-Receivable Voucher')
982 reload_doc('Mapper', 'DocType Mapper', 'Delivery Note-Receivable Voucher')
983 elif patch_no == 234:
984 sql("update `tabTable Mapper Detail` set validation_logic = 'docstatus=1' where parent = 'Sales Order-Indent' and from_table = 'Sales Order Detail'")
985 elif patch_no == 235:
Brahma K09307622011-07-27 12:03:34 +0530986 for sc in sql("""select name from `tabSearch Criteria` where ifnull(name,'')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +0530987 like 'srch%' or ifnull(name,'') like '%stdsrch'"""):
988 try:
989 get_obj('Search Criteria', sc[0]).rename()
990 except AttributeError, e:
991 pass
992 reload_doc('core', 'doctype', 'system_console')
993 elif patch_no == 236:
994 # warehouse not mandatory for delivered serial nos
995 sql("update tabDocField set reqd=0 where parent='Serial No' and fieldname='warehouse'")
996 elif patch_no == 237:
997 sql("update tabDocField set depends_on = 'eval:doc.is_pos==1' where fieldname = 'cash_bank_account' and parent = 'Receivable Voucher'")
998 elif patch_no == 238:
999 reload_doc('accounts', 'doctype', 'receivable_voucher')
1000 reload_doc('accounts', 'GL Mapper', 'POS with write off')
1001 elif patch_no == 239:
1002 reload_doc('core', 'doctype', 'docfield')
1003 reload_doc('core', 'doctype', 'doctype')
Rushabh Mehta393e70b2011-08-02 13:05:09 +05301004<<<<<<< HEAD
Brahma K09307622011-07-27 12:03:34 +05301005
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301006 from patches.feed_patch import set_subjects_and_tagfields
Rushabh Mehta393e70b2011-08-02 13:05:09 +05301007=======
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301008
Nabin Hait31a407d2011-07-28 11:47:45 +05301009 from patches.old_patches.feed_patch import set_subjects_and_tagfields
Rushabh Mehta393e70b2011-08-02 13:05:09 +05301010>>>>>>> stable
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301011 set_subjects_and_tagfields()
1012 elif patch_no == 240:
1013 # again for sales order (status)
Nabin Hait31a407d2011-07-28 11:47:45 +05301014 from patches.old_patches.feed_patch import set_subjects_and_tagfields
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301015 set_subjects_and_tagfields()
1016 elif patch_no == 241:
1017 sql("update `tabDocField` set fieldtype = 'Text', options = '', in_filter = '' where fieldname = 'serial_no' and parent = 'Stock Ledger Entry'")
1018 elif patch_no == 242:
1019 if webnotes.conn.get_value('Control Panel', None, 'account_id') not in ['axjanak2011']:
1020 sql("commit")
1021 try:
1022 sql("alter table `tabStock Ledger Entry` drop index serial_no")
1023 except:
1024 pass
1025
1026 sql("alter table `tabStock Ledger Entry` change serial_no serial_no text")
1027 elif patch_no == 243:
1028 # moving custom script and custom fields to framework
1029 webnotes.conn.set_value('DocType', 'Custom Script', 'module', 'Core')
1030 webnotes.conn.set_value('DocType', 'Custom Field', 'module', 'Core')
1031 reload_doc('setup', 'doctype', 'company')
1032 elif patch_no == 244:
Nabin Hait31a407d2011-07-28 11:47:45 +05301033 reload_doc('stock', 'search_criteria', 'shortage_to_indent')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301034 elif patch_no == 245:
Nabin Hait31a407d2011-07-28 11:47:45 +05301035 from patches.old_patches.doctype_permission_patch import set_doctype_permissions
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301036 set_doctype_permissions()
1037
Nabin Hait31a407d2011-07-28 11:47:45 +05301038 from patches.old_patches.feed_patch import set_subjects_and_tagfields
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301039 set_subjects_and_tagfields()
1040 elif patch_no == 246:
1041 webnotes.conn.set_value('DocType','Stock Entry','tag_fields','purpose')
1042 webnotes.conn.set_value('DocType','Stock Entry','subject','%(remarks)s')
1043 elif patch_no == 247:
1044 webnotes.conn.set_value('DocType','Stock Entry','subject','%(remarks)s')
1045 elif patch_no == 248:
1046 reload_doc('setup', 'doctype', 'manage_account')
1047 elif patch_no == 249:
1048 sql("update `tabDocPerm` t1, `tabDocType` t2 set t1.role = 'System Manager' where t1.role = 'Administrator' and t1.parent = t2.name and t2.module != 'Core'")
1049 elif patch_no == 250:
Nabin Hait31a407d2011-07-28 11:47:45 +05301050 from patches.old_patches.feed_patch import support_patch
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301051 support_patch()
1052 elif patch_no == 251:
1053 from webnotes.model import db_schema
1054 db_schema.remove_all_foreign_keys()
Nabin Hait31a407d2011-07-28 11:47:45 +05301055 from patches.old_patches.customer_address import run_patch
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301056 run_patch()
1057 elif patch_no == 252:
Nabin Hait31a407d2011-07-28 11:47:45 +05301058 reload_doc('support','doctype','support_ticket')
1059 reload_doc('support','doctype','support_ticket_response')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301060 elif patch_no == 253:
1061 reload_doc('accounts','doctype','ledger_balance_export')
1062 reload_doc('accounts','doctype','ledger_detail')
1063 reload_doc('accounts', 'Module Def', 'Accounts')
1064
1065 from webnotes.model.db_schema import updatedb
1066 updatedb('Ledger Balance Export')
1067 updatedb('Ledger Detail')
1068 elif patch_no == 254:
Nabin Hait31a407d2011-07-28 11:47:45 +05301069 reload_doc('setup', 'doctype', 'sms_settings')
1070 reload_doc('setup', 'doctype', 'static_parameter_detail')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301071
1072 from webnotes.model.db_schema import updatedb
1073 updatedb('SMS Settings')
1074 updatedb('Static Parameter Detail')
1075 elif patch_no == 255:
Nabin Hait31a407d2011-07-28 11:47:45 +05301076 from patches.old_patches.customer_address import run_old_data_sync_patch
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301077 run_old_data_sync_patch()
1078 elif patch_no == 256:
1079 sql("update `tabLetter Head` set content = replace(content, 'http://46.4.50.84/v170-test/', '')")
1080 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'")
1081 sql("update `tabItem` set description_html = replace(description_html, 'http://46.4.50.84/v170-test/', '')")
1082 elif patch_no == 257:
Rushabh Mehta393e70b2011-08-02 13:05:09 +05301083<<<<<<< HEAD
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301084 from patches.customer_address import run_old_data_sync_patch
Brahma K09307622011-07-27 12:03:34 +05301085 run_old_data_sync_patch()
Rushabh Mehta393e70b2011-08-02 13:05:09 +05301086=======
Nabin Hait31a407d2011-07-28 11:47:45 +05301087 from patches.old_patches.customer_address import run_old_data_sync_patch
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301088 run_old_data_sync_patch()
Rushabh Mehta393e70b2011-08-02 13:05:09 +05301089>>>>>>> stable
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301090 elif patch_no == 258:
1091 sql("update tabDocField set `default`=NULL where fieldname = 'naming_series'")
1092 elif patch_no == 259:
1093 sql("update `tabQuotation Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1094 sql("update `tabSales Order Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1095 sql("update `tabRV Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1096 sql("update `tabDelivery Note Detail` set description = replace(description, 'http://46.4.50.84/v170-test/', '')")
1097 elif patch_no == 260:
1098 sql("update `tabLetter Head` set content = replace(content, 'http://46.4.50.84/v170/', '')")
1099 sql("update `tabSingles` set value = replace(value, 'http://46.4.50.84/v170/', '') where field in ('letter_head', 'client_name') and doctype = 'Control Panel'")
1100 sql("update `tabItem` set description_html = replace(description_html, 'http://46.4.50.84/v170/', '')")
1101 sql("update `tabQuotation Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1102 sql("update `tabSales Order Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1103 sql("update `tabRV Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1104 sql("update `tabDelivery Note Detail` set description = replace(description, 'http://46.4.50.84/v170/', '')")
1105 elif patch_no == 261:
1106 sql("update `tabPrint Format` set html = replace(html, 'customer_address', 'address_display')")
1107 elif patch_no == 262:
Nabin Hait31a407d2011-07-28 11:47:45 +05301108 from patches.old_patches.customer_address import sync_lead_phone
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301109 sync_lead_phone()
1110 elif patch_no == 263:
1111 ol = ['','Open','To Reply','Waiting for Customer','Hold','Closed']
1112 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 +05301113 elif patch_no == 264:
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301114 sql("delete from tabDocField where parent = 'Customer Issue' and (fieldname = 'issue_in' or fieldname = 'issue_category')")
1115 sql("update tabDocField set options=NULL where parent='Support Ticket' and label = 'Send'")
1116 elif patch_no == 266:
1117 reload_doc('setup','doctype','support_email_settings')
1118 elif patch_no == 267:
1119 sql("update `tabPrint Format` set html = replace(html, 'supplier_address', 'address_display')")
1120 elif patch_no == 268:
1121 sql("update `tabDocPerm` set permlevel = 0 where permlevel is null")
1122 elif patch_no == 269:
1123 p = get_obj('Patch Util')
1124 p.add_permission('GL Entry', 'Accounts User', 0, read = 1)
1125 elif patch_no == 270:
1126 pages = ['Accounts Setup', 'Accounts', 'Accounting Reports','GeneralLedger','How do I - Accounts','Making Opening Entries',\
1127 'Analysis','How do I - CRM','How do I - Inventory','Inventory Setup', 'Stock','HR','HR & Payroll Setup',\
1128 'Payroll Setup','Production Setup','Production','Buying','SRM Setup','Contact Page','Forum','Messages','Test Toolbar',\
1129 'Trend Analyzer']
1130 from webnotes.model import delete_doc
1131 sql("delete from `tabPage Visit`")
1132 for p in pages:
1133 try: delete_doc('Page', p)
1134 except: pass
1135 elif patch_no == 271:
1136 # tags patch
Nabin Hait31a407d2011-07-28 11:47:45 +05301137 reload_doc('selling','doctype','sales_order')
1138 reload_doc('stock','doctype','delivery_note')
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301139 sql("delete from tabDocField where fieldname='per_amt_billed' and parent in ('Sales Order', 'Delivery Note')")
Brahma K09307622011-07-27 12:03:34 +05301140
1141 sql("""update `tabSales Order` set delivery_status = if(ifnull(per_delivered,0) < 0.001, 'Not Delivered',
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301142 if(per_delivered >= 99.99, 'Fully Delivered', 'Partly Delivered'))""")
Brahma K09307622011-07-27 12:03:34 +05301143 sql("""update `tabSales Order` set billing_status = if(ifnull(per_billed,0) < 0.001, 'Not Billed',
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301144 if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""")
Brahma K09307622011-07-27 12:03:34 +05301145 sql("""update `tabDelivery Note` set billing_status = if(ifnull(per_billed,0) < 0.001, 'Not Billed',
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +05301146 if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""")
1147 elif patch_no == 272:
1148 from webnotes.model import delete_doc
1149 try:
1150 delete_doc('Search Criteria', '_SRCH00003')
1151 except:
1152 pass
1153 reload_doc('accounts', 'search_criteria', 'purchase_register')
1154 elif patch_no == 276:
1155 from webnotes.model import delete_doc
1156 sn = sql("select name from `tabSearch Criteria` where criteria_name = 'Sales Personwise Transaction Summary'")
1157 for d in sn:
1158 delete_doc('Search Criteria', d[0])
Nabin Hait31a407d2011-07-28 11:47:45 +05301159 reload_doc('selling', 'search_criteria', 'sales_personwise_transaction_summary')
nabinhaite0250fb2011-06-14 13:35:31 +05301160 elif patch_no == 277:
1161 webnotes.model.delete_doc('DocType','HomePage Settings')
1162 webnotes.model.delete_doc('DocType','Badge Settings')
1163 sql("update tabDocType set module='Home' where module in ('Event Updates', 'My Company')")
1164 sql("update tabPage set module='Home' where module in ('Event Updates', 'My Company')")
1165 sql("update `tabSearch Criteria` set module='Home' where module in ('Event Updates', 'My Company')")
1166
1167
1168 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')
1169 for p in delete_pages:
1170 webnotes.model.delete_doc('Page',p)
nabinhaitb7789a52011-06-14 17:33:12 +05301171 elif patch_no == 278:
1172 sql("update tabDocTrigger set method = 'home.update_feed' where method = 'event_updates.update_feed'")
nabinhaitc43ece72011-06-15 11:55:32 +05301173 elif patch_no == 279:
1174 dt = ['GL Entry', 'Stock Ledger Entry']
1175 for t in dt:
1176 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)
1177 for d in rec:
1178 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 +05301179
nabinhaitc43ece72011-06-15 11:55:32 +05301180 other_dt = ['Enquiry', 'Quotation', 'Sales Order', 'Indent', 'Purchase Order', 'Production Order', 'Customer Issue', 'Installation Note']
1181 for dt in other_dt:
1182 rec = sql("select name, status from `tab%s` where modified >= '2011-06-15 01:00:00'" % dt)
1183 for r in rec:
1184 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 +05301185 elif patch_no == 280:
1186 reload_doc('accounts', 'doctype', 'form_16a')
nabinhaite7221212011-06-15 14:39:31 +05301187 elif patch_no == 281:
1188 dt_list = ['Delivery Note', 'Purchase Receipt']
1189 for dt in dt_list:
nabinhaite7221212011-06-15 14:39:31 +05301190 sql("update `tab%s` set status = 'Submitted' where docstatus = 1 and modified >='2011-06-15 01:00:00'" % dt)
1191 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 +05301192 elif patch_no == 282:
1193 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']
1194 for d in dt_list:
1195 tbl = sql("select options from `tabDocField` where fieldtype = 'Table' and parent = '%s'" % d)
1196 for t in tbl:
1197 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 +05301198 elif patch_no == 283:
1199 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")
1200 for d in rec:
1201 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 +05301202 elif patch_no == 284:
Nabin Hait31a407d2011-07-28 11:47:45 +05301203 reload_doc('support', 'doctype', 'support_ticket')
nabinhaitf7d80002011-06-20 13:51:26 +05301204 sql("update `tabDocField` set in_filter = 1 where fieldname in ('raised_by', 'subject') and parent = 'Support Ticket'")
nabinhait6150e652011-06-20 16:34:48 +05301205 elif patch_no == 286:
nabinhait4b59bea2011-06-20 14:07:04 +05301206 reload_doc('accounts', 'search_criteria', 'itemwise_sales_register')
1207 reload_doc('accounts', 'search_criteria', 'itemwise_purchase_register')
nabinhait58f01022011-06-21 15:05:43 +05301208 elif patch_no == 287:
nabinhait8b849fe2011-06-21 15:09:55 +05301209 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 +05301210 elif patch_no == 288:
1211 reload_doc('accounts', 'doctype', 'payable_voucher')
nabinhait33dee782011-06-21 17:17:39 +05301212 elif patch_no == 289:
1213 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 +05301214 sql("update `tabDocType` set search_fields = 'status,transaction_date,customer,lead,order_type' where name = 'Quotation'")
Anand Doshib9f7e392011-06-22 12:11:47 +05301215 elif patch_no == 290:
Brahma K09307622011-07-27 12:03:34 +05301216 count = sql("""SELECT * FROM `tabModule Def`
Anand Doshib9f7e392011-06-22 12:11:47 +05301217 WHERE `module_name` LIKE 'Home'""")
1218 if not count:
1219 md = Document('Module Def')
1220 md.module_name = 'Home'
1221 md.module_label = 'Home'
Rushabh Mehta64b6c2c2011-06-22 16:38:11 +05301222 md.save(1)
1223 elif patch_no == 291:
Nabin Hait31a407d2011-07-28 11:47:45 +05301224 reload_doc('utilities','doctype','rename_tool')
nabinhaitaeee6ba2011-06-22 18:25:29 +05301225 elif patch_no == 292:
1226 reload_doc('accounts', 'search_criteria', 'trial_balance')
Ravi Dey560ee3d2011-06-23 13:03:24 +05301227 elif patch_no == 293:
1228 sql("delete from tabDocField where parent='Account' and fieldname='address'")
1229 reload_doc('accounts', 'doctype', 'account')
Rushabh Mehta3e037432011-06-23 22:47:04 +05301230 elif patch_no == 294:
1231 # new account profile fix
1232 ul = sql("select name from tabProfile where ifnull(name,'') not in ('Administrator', 'Guest', '')")
1233 # if one user and one user has no roles
1234 if len(ul)==1 and not sql("select parent from tabUserRole where role='System Manager' and parent=%s", ul[0][0]):
1235 get_obj('Setup Control').add_roles(Document('Profile', ul[0][0]))
Ravi Dey0b6c5652011-06-24 14:44:21 +05301236 elif patch_no == 295:
1237 sql("update `tabDocField` set options = 'Delivered\nNot Delivered\nPartly Delivered\nClosed\nNot Applicable' where parent = 'Sales Order' and fieldname = 'delivery_status'")
1238 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 +05301239 elif patch_no == 296:
Ravi Dey26c160f2011-06-24 15:53:51 +05301240 sql("delete from tabDocField where parent='Support Ticket' and fieldname='contact_no'")
Nabin Hait31a407d2011-07-28 11:47:45 +05301241 reload_doc('support', 'doctype', 'support_ticket')
Ravi Dey74c9c4d2011-06-27 11:26:39 +05301242 elif patch_no == 297:
Nabin Hait31a407d2011-07-28 11:47:45 +05301243 reload_doc('hr', 'doctype', 'employee')
1244 reload_doc('hr', 'doctype', 'attendance')
1245 reload_doc('hr', 'doctype', 'expense_voucher')
1246 reload_doc('hr', 'doctype', 'appraisal')
1247 reload_doc('hr', 'doctype', 'salary_structure')
1248 reload_doc('hr', 'doctype', 'salary_slip')
Ravi Dey48671df2011-06-27 12:03:36 +05301249 elif patch_no == 298:
Ravi Dey94a332a2011-07-01 13:50:34 +05301250 sql("update `tabDocField` set options = 'link:Company' where parent = 'Attendance' and fieldname = 'company'")
1251 sql("update `tabDocField` set options = 'link:Company' where parent = 'Expense Voucher' and fieldname = 'company'")
1252 sql("update `tabDocField` set options = 'link:Company' where parent = 'Appraisal' and fieldname = 'company'")
Ravi Dey8d3f4b62011-06-27 12:48:56 +05301253 elif patch_no == 299:
1254 sql("update `tabDocPerm` set `match` = NULL where parent = 'Employee' and role = 'Employee'")
nabinhait690c6972011-06-28 14:42:07 +05301255 elif patch_no == 300:
Anand Doshib74eec82011-06-28 13:42:08 +05301256 sql("""DELETE FROM `tabSearch Criteria` WHERE name IN
1257 ('sales_register1', 'sales_register2', 'purchase_register1')""")
nabinhait78f5bf62011-06-28 16:21:58 +05301258 elif patch_no == 301:
nabinhait690c6972011-06-28 14:42:07 +05301259 from patches.delivery_billing_status_patch import run_patch
1260 run_patch()
nabinhaitb3930002011-06-28 16:50:38 +05301261 elif patch_no == 302:
1262 sql("update `tabDocField` set no_copy = 1 where fieldname = 'naming_series'")
Ravi Dey4c651192011-06-28 19:36:18 +05301263 elif patch_no == 303:
Ravi Dey27c5b402011-06-29 18:05:18 +05301264 pass
1265 elif patch_no == 304:
Rushabh Mehtac71eeb62011-06-30 08:28:36 +05301266 sql("delete from `tabDocField` where parent = 'company' and label = 'Trash Company' and fieldtype = 'button'")
Ravi Deyc674e432011-06-29 18:15:12 +05301267 reload_doc('setup', 'doctype', 'company')
Ravi Dey79c28652011-06-29 18:55:19 +05301268 elif patch_no == 305:
1269 sql("update `tabDocField` set options = 'link:Company' where options='link:Company' and fieldname='company' and fieldtype='Select'")
nabinhaitec097972011-07-01 13:34:41 +05301270 elif patch_no == 306:
Ravi Dey94a332a2011-07-01 13:50:34 +05301271 sql("update `tabDocField` set options = '\nAccount\nCompany\nCustomer\nSupplier\nEmployee\nWarehouse\nItem' where parent = 'Rename Tool' and fieldname = 'select_doctype'")
1272 sql("update `tabDocField` set options = 'link:Item' where parent = 'Raw Materials Supplied' and fieldname = 'po_item'")
1273 sql("update `tabDocField` set options = 'Sales Order' where parent = 'Indent Detail' and fieldname = 'sales_order_no'")
1274 sql("update `tabDocField` set options = 'link:Company', fieldtype = 'Select' where parent = 'Stock Ledger Entry' and fieldname = 'company'")
Nabin Hait31a407d2011-07-28 11:47:45 +05301275 reload_doc('utilities', 'doctype', 'rename_tool')
Ravi Dey627d01b2011-07-01 14:05:43 +05301276 elif patch_no == 307:
1277 sql("delete from `tabDocField` where parent = 'company' and label = 'Trash Company' and fieldtype = 'Button'")
1278 reload_doc('setup', 'doctype', 'company')
nabinhaita56fc002011-07-01 16:32:03 +05301279 elif patch_no == 308:
Ravi Deyc1886b52011-07-04 16:53:42 +05301280 sql("update `tabDocField` set reqd = 0 where fieldname = 'select_item' and parent = 'Property Setter'")
nabinhait1bd56b12011-07-05 14:41:36 +05301281 elif patch_no == 309:
1282 sql("delete from `tabDocField` where fieldname = 'item_attachments_details' and parent = 'Item'")
nabinhait7f339e02011-07-05 15:43:17 +05301283 sql("delete from `tabModule Def Item` where parent = 'Stock' and doc_name = 'Landed Cost Wizard'")
nabinhait5deab242011-07-06 09:23:02 +05301284 elif patch_no == 310:
1285 from erpnext_structure_cleanup import run_patches
1286 run_patches()
nabinhait4bb8bf42011-07-06 10:11:11 +05301287 elif patch_no == 311:
1288 sql("update `tabDocField` set reqd = 0 where fieldname = 'select_item' and parent = 'Property Setter'")
nabinhait4c38fbb2011-07-06 10:36:53 +05301289 #reload_doc('core', 'doctype', 'property_setter')
nabinhait4bb8bf42011-07-06 10:11:11 +05301290 elif patch_no == 312:
1291 sql("delete from `tabSessions`")
1292 sql("delete from `__SessionCache`")
nabinhaitd54ec522011-07-06 12:20:21 +05301293 elif patch_no == 313:
1294 dt = ['GL Entry', 'Stock Ledger Entry']
1295 for t in dt:
1296 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)
1297 for d in rec:
nabinhaitfccbb092011-07-06 12:23:27 +05301298 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 +05301299
nabinhaitd54ec522011-07-06 12:20:21 +05301300 other_dt = ['Enquiry', 'Quotation', 'Sales Order', 'Indent', 'Purchase Order', 'Production Order', 'Customer Issue', 'Installation Note']
1301 for dt in other_dt:
1302 rec = sql("select name, status from `tab%s` where modified >= '2011-07-06 10:00:00'" % dt)
1303 for r in rec:
1304 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 +05301305
1306
nabinhaitd54ec522011-07-06 12:20:21 +05301307 dt_list = ['Delivery Note', 'Purchase Receipt']
1308 for dt in dt_list:
1309 sql("update `tab%s` set status = 'Submitted' where docstatus = 1 and modified >='2011-07-06 10:00:00'" % dt)
1310 sql("update `tab%s` set status = 'Cancelled' where docstatus = 2 and modified >='2011-07-06 10:00:00'" % dt)
1311
1312 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']
1313 for d in dt_list:
1314 tbl = sql("select options from `tabDocField` where fieldtype = 'Table' and parent = '%s'" % d)
1315 for t in tbl:
1316 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 +05301317
nabinhait22f7edd2011-07-06 12:45:02 +05301318 elif patch_no == 314:
1319 # delete double feed
1320 sql("delete from tabFeed where subject like 'New %'")
nabinhaiteb315402011-07-06 13:03:31 +05301321 elif patch_no == 315:
1322 # delete double feed
1323 sql("delete from tabFeed where doc_name like 'New %'")
1324 reload_doc('core', 'doctype', 'property_setter')
1325
1326 from webnotes.model.doc import Document
1327 m = Document('Module Def Role')
1328 m.role = 'All'
1329 m.parent = 'Home'
1330 m.parenttype = 'Module Def'
1331 m.parentfield = 'roles'
1332 m.save(1)
Ravi Dey7a6211d2011-07-07 15:49:24 +05301333 elif patch_no == 316:
Ravi Dey89822722011-07-07 15:52:35 +05301334 pass
1335 elif patch_no == 317:
Brahma K09307622011-07-27 12:03:34 +05301336 sql("update `tabPage` set name = 'profile-settings' where page_name = 'Profile Settings'")
Anand Doshi56ab7e42011-07-07 18:37:58 +05301337 elif patch_no == 318:
Ravi Deycfc5dff2011-07-07 16:48:54 +05301338 reload_doc('utilities', 'doctype', 'bulk_rename_tool')
Anand Doshi52b1d5a2011-07-07 18:41:12 +05301339 elif patch_no == 319:
Anand Doshi56ab7e42011-07-07 18:37:58 +05301340 sql("delete from tabFeed where doc_name like 'New %'")
nabinhait63cf2b92011-07-08 13:30:46 +05301341 elif patch_no == 320:
1342 reload_doc('setup', 'doctype', 'series_detail')
Ravi Deyfac96e12011-07-08 13:38:16 +05301343 elif patch_no == 321:
Ravi Dey84913842011-07-08 13:46:09 +05301344 reload_doc('hr','doctype','leave_application')
1345 elif patch_no == 322:
1346 sql("delete from `tabDocField` where parent = 'Leave Application' and fieldname = 'latter_head'")
Nabin Hait2acac4b2011-07-10 13:52:05 +05301347 elif patch_no == 323:
1348 reload_doc('stock', 'doctype', 'stock_entry')
Nabin Haite079a6e2011-07-10 14:15:52 +05301349 sql("update `tabDocField` set options = 'get_stock_and_rate' where parent = 'Stock Entry' and label = 'Get Stock and Rate'")
1350 sql("delete from `tabDocField` where label = 'Get Current Stock' and parent = 'Stock Entry'")
nabinhait54b0e7d2011-07-13 16:40:03 +05301351 elif patch_no == 324:
1352 sql("delete from `tabDocField` where fieldname = 'test_field' and parent = 'Customer'")
Ravi Dey9dd0c0b2011-07-13 18:08:38 +05301353 elif patch_no == 325:
1354 sql("update `tabDocField` set fieldtype = 'Data' where parent = 'Salary Slip' and fieldname = 'total_days_in_month'")
1355 reload_doc('hr', 'doctype', 'salary_slip')
Rushabh Mehta61790802011-07-17 10:52:47 +05301356 elif patch_no == 326:
1357 # load the new billing page
1358 if cint(webnotes.conn.get_value('Control Panel',None,'sync_with_gateway')):
1359 reload_doc('server_tools','page','billing')
nabinhaite6526362011-07-19 18:09:26 +05301360 elif patch_no == 327:
Rushabh Mehta391aa022011-07-25 14:07:50 +05301361 # patch for support email settings now moved to email settings
1362 reload_doc('setup','doctype','email_settings')
Brahma K09307622011-07-27 12:03:34 +05301363
Rushabh Mehta391aa022011-07-25 14:07:50 +05301364 # map fields from support to email settings
1365 field_map = {
1366 'support_email': 'email',
1367 'support_host':'host',
1368 'support_username': 'username',
1369 'support_password': 'password',
Rushabh Mehtab7186d42011-07-25 14:37:48 +05301370 'support_use_ssl': 'use_ssl',
Rushabh Mehta391aa022011-07-25 14:07:50 +05301371 'sync_support_mails': 'integrate_incoming',
1372 'signature': 'support_signature'
1373 }
Brahma K09307622011-07-27 12:03:34 +05301374
Rushabh Mehta391aa022011-07-25 14:07:50 +05301375 for key in field_map:
1376 webnotes.conn.set_value('Email Settings',None,key, \
1377 webnotes.conn.get_value('Support Email Settings',None,field_map[key]))
Brahma K09307622011-07-27 12:03:34 +05301378
Rushabh Mehta391aa022011-07-25 14:07:50 +05301379 # delete support email settings
1380 from webnotes.model import delete_doc
1381 delete_doc('DocType', 'Support Email Settings')
1382
Rushabh Mehta9b8fad22011-07-25 14:45:42 +05301383 reload_doc('support','doctype','support_ticket')
Nabin Hait587ac5c2011-07-26 15:46:10 +05301384 sql("delete from tabDocField where fieldname='problem_description' and parent='Support Ticket'")
1385 elif patch_no == 328:
nabinhaite6526362011-07-19 18:09:26 +05301386 if webnotes.conn.get_value('Control Panel', None, 'account_id') != 'axjanak2011':
1387 sql("delete from `tabDocField` where fieldname = 'supplier_status' and parent = 'Supplier'")
Nabin Hait587ac5c2011-07-26 15:46:10 +05301388 elif patch_no == 329:
nabinhaitde9826c2011-07-20 18:02:59 +05301389 reload_doc('utilities', 'doctype', 'rename_tool')
1390 reload_doc('utilities', 'doctype', 'bulk_rename_tool')
Brahma K09307622011-07-27 12:03:34 +05301391 elif patch_no == 330:
1392 reload_doc('accounts', 'doctype', 'lease_agreement')
1393 reload_doc('accounts', 'doctype', 'lease_installment')
1394
1395 reload_doc('accounts', 'search_criteria', 'lease_agreement_list')
1396 reload_doc('accounts', 'search_criteria', 'lease_monthly_future_installment_inflows')
1397 reload_doc('accounts', 'search_criteria', 'lease_overdue_age_wise')
1398 reload_doc('accounts', 'search_criteria', 'lease_overdue_list')
1399 reload_doc('accounts', 'search_criteria', 'lease_receipts_client_wise')
1400 reload_doc('accounts', 'search_criteria', 'lease_receipt_summary_year_to_date')
1401 reload_doc('accounts', 'search_criteria', 'lease_yearly_future_installment_inflows')
Brahma Kbcdade52011-07-27 12:11:09 +05301402
1403 reload_doc('accounts', 'Module Def', 'Accounts')
Brahma K3b1ebe02011-07-27 13:04:11 +05301404 elif patch_no == 331:
1405 p = get_obj('Patch Util')
1406 # permission
1407 p.add_permission('Lease Agreement', 'Accounts Manager', 0, read = 1, write=1,submit=1, cancel=1,amend=1)
1408 p.add_permission('Lease Agreement', 'Accounts Manager', 1, read = 1)