blob: 5b9f7a0c4712ddf412c1743f91f95aa843004992 [file] [log] [blame]
Rushabh Mehta3966f1d2012-02-23 12:35:32 +05301# ERPNext - web based ERP (http://erpnext.com)
2# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +053017# REMEMBER to update this
18# ========================
nabinhaita56fc002011-07-01 16:32:03 +053019
Nabin Haitc0d74342011-10-14 00:14:31 +053020last_patch = 388
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +053021
22#-------------------------------------------
23
Nabin Haitc57c5b02011-12-16 10:17:26 +053024def execute(patch_no):
25 return
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +053026 import webnotes
Rushabh Mehtaae4d1f92012-03-12 14:34:55 +053027 from webnotes.modules import reload_doc
Pratik Vyasc1e6e4c2011-06-08 14:37:15 +053028
29 from webnotes.model.code import get_obj
30 sql = webnotes.conn.sql
31 from webnotes.utils import cint, cstr, flt
32 from webnotes.model.doc import Document
Rushabh Mehta33bce672011-08-25 15:15:25 +053033 from webnotes.model import delete_doc
Brahma K09307622011-07-27 12:03:34 +053034
Rushabh Mehta9e6e7fa2011-08-25 16:08:06 +053035 if patch_no == 301:
nabinhait690c6972011-06-28 14:42:07 +053036 from patches.delivery_billing_status_patch import run_patch
37 run_patch()
nabinhaitb3930002011-06-28 16:50:38 +053038 elif patch_no == 302:
39 sql("update `tabDocField` set no_copy = 1 where fieldname = 'naming_series'")
Ravi Dey4c651192011-06-28 19:36:18 +053040 elif patch_no == 303:
Ravi Dey27c5b402011-06-29 18:05:18 +053041 pass
42 elif patch_no == 304:
Rushabh Mehtac71eeb62011-06-30 08:28:36 +053043 sql("delete from `tabDocField` where parent = 'company' and label = 'Trash Company' and fieldtype = 'button'")
Ravi Deyc674e432011-06-29 18:15:12 +053044 reload_doc('setup', 'doctype', 'company')
Ravi Dey79c28652011-06-29 18:55:19 +053045 elif patch_no == 305:
46 sql("update `tabDocField` set options = 'link:Company' where options='link:Company' and fieldname='company' and fieldtype='Select'")
nabinhaitec097972011-07-01 13:34:41 +053047 elif patch_no == 306:
Ravi Dey94a332a2011-07-01 13:50:34 +053048 sql("update `tabDocField` set options = '\nAccount\nCompany\nCustomer\nSupplier\nEmployee\nWarehouse\nItem' where parent = 'Rename Tool' and fieldname = 'select_doctype'")
49 sql("update `tabDocField` set options = 'link:Item' where parent = 'Raw Materials Supplied' and fieldname = 'po_item'")
50 sql("update `tabDocField` set options = 'Sales Order' where parent = 'Indent Detail' and fieldname = 'sales_order_no'")
51 sql("update `tabDocField` set options = 'link:Company', fieldtype = 'Select' where parent = 'Stock Ledger Entry' and fieldname = 'company'")
Nabin Hait31a407d2011-07-28 11:47:45 +053052 reload_doc('utilities', 'doctype', 'rename_tool')
Ravi Dey627d01b2011-07-01 14:05:43 +053053 elif patch_no == 307:
54 sql("delete from `tabDocField` where parent = 'company' and label = 'Trash Company' and fieldtype = 'Button'")
55 reload_doc('setup', 'doctype', 'company')
nabinhaita56fc002011-07-01 16:32:03 +053056 elif patch_no == 308:
Ravi Deyc1886b52011-07-04 16:53:42 +053057 sql("update `tabDocField` set reqd = 0 where fieldname = 'select_item' and parent = 'Property Setter'")
nabinhait1bd56b12011-07-05 14:41:36 +053058 elif patch_no == 309:
59 sql("delete from `tabDocField` where fieldname = 'item_attachments_details' and parent = 'Item'")
nabinhait7f339e02011-07-05 15:43:17 +053060 sql("delete from `tabModule Def Item` where parent = 'Stock' and doc_name = 'Landed Cost Wizard'")
nabinhait5deab242011-07-06 09:23:02 +053061 elif patch_no == 310:
62 from erpnext_structure_cleanup import run_patches
63 run_patches()
nabinhait4bb8bf42011-07-06 10:11:11 +053064 elif patch_no == 311:
65 sql("update `tabDocField` set reqd = 0 where fieldname = 'select_item' and parent = 'Property Setter'")
nabinhait4c38fbb2011-07-06 10:36:53 +053066 #reload_doc('core', 'doctype', 'property_setter')
nabinhait4bb8bf42011-07-06 10:11:11 +053067 elif patch_no == 312:
68 sql("delete from `tabSessions`")
69 sql("delete from `__SessionCache`")
nabinhaitd54ec522011-07-06 12:20:21 +053070 elif patch_no == 313:
71 dt = ['GL Entry', 'Stock Ledger Entry']
72 for t in dt:
73 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)
74 for d in rec:
nabinhaitfccbb092011-07-06 12:23:27 +053075 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 +053076
nabinhaitd54ec522011-07-06 12:20:21 +053077 other_dt = ['Enquiry', 'Quotation', 'Sales Order', 'Indent', 'Purchase Order', 'Production Order', 'Customer Issue', 'Installation Note']
78 for dt in other_dt:
79 rec = sql("select name, status from `tab%s` where modified >= '2011-07-06 10:00:00'" % dt)
80 for r in rec:
81 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 +053082
83
nabinhaitd54ec522011-07-06 12:20:21 +053084 dt_list = ['Delivery Note', 'Purchase Receipt']
85 for dt in dt_list:
86 sql("update `tab%s` set status = 'Submitted' where docstatus = 1 and modified >='2011-07-06 10:00:00'" % dt)
87 sql("update `tab%s` set status = 'Cancelled' where docstatus = 2 and modified >='2011-07-06 10:00:00'" % dt)
88
89 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']
90 for d in dt_list:
91 tbl = sql("select options from `tabDocField` where fieldtype = 'Table' and parent = '%s'" % d)
92 for t in tbl:
93 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 +053094
nabinhait22f7edd2011-07-06 12:45:02 +053095 elif patch_no == 314:
96 # delete double feed
97 sql("delete from tabFeed where subject like 'New %'")
nabinhaiteb315402011-07-06 13:03:31 +053098 elif patch_no == 315:
99 # delete double feed
100 sql("delete from tabFeed where doc_name like 'New %'")
101 reload_doc('core', 'doctype', 'property_setter')
102
103 from webnotes.model.doc import Document
104 m = Document('Module Def Role')
105 m.role = 'All'
106 m.parent = 'Home'
107 m.parenttype = 'Module Def'
108 m.parentfield = 'roles'
109 m.save(1)
Ravi Dey7a6211d2011-07-07 15:49:24 +0530110 elif patch_no == 316:
Ravi Dey89822722011-07-07 15:52:35 +0530111 pass
112 elif patch_no == 317:
Brahma K09307622011-07-27 12:03:34 +0530113 sql("update `tabPage` set name = 'profile-settings' where page_name = 'Profile Settings'")
Anand Doshi56ab7e42011-07-07 18:37:58 +0530114 elif patch_no == 318:
Ravi Deycfc5dff2011-07-07 16:48:54 +0530115 reload_doc('utilities', 'doctype', 'bulk_rename_tool')
Anand Doshi52b1d5a2011-07-07 18:41:12 +0530116 elif patch_no == 319:
Anand Doshi56ab7e42011-07-07 18:37:58 +0530117 sql("delete from tabFeed where doc_name like 'New %'")
nabinhait63cf2b92011-07-08 13:30:46 +0530118 elif patch_no == 320:
119 reload_doc('setup', 'doctype', 'series_detail')
Ravi Deyfac96e12011-07-08 13:38:16 +0530120 elif patch_no == 321:
Ravi Dey84913842011-07-08 13:46:09 +0530121 reload_doc('hr','doctype','leave_application')
122 elif patch_no == 322:
123 sql("delete from `tabDocField` where parent = 'Leave Application' and fieldname = 'latter_head'")
Nabin Hait2acac4b2011-07-10 13:52:05 +0530124 elif patch_no == 323:
125 reload_doc('stock', 'doctype', 'stock_entry')
Nabin Haite079a6e2011-07-10 14:15:52 +0530126 sql("update `tabDocField` set options = 'get_stock_and_rate' where parent = 'Stock Entry' and label = 'Get Stock and Rate'")
127 sql("delete from `tabDocField` where label = 'Get Current Stock' and parent = 'Stock Entry'")
nabinhait54b0e7d2011-07-13 16:40:03 +0530128 elif patch_no == 324:
129 sql("delete from `tabDocField` where fieldname = 'test_field' and parent = 'Customer'")
Ravi Dey9dd0c0b2011-07-13 18:08:38 +0530130 elif patch_no == 325:
131 sql("update `tabDocField` set fieldtype = 'Data' where parent = 'Salary Slip' and fieldname = 'total_days_in_month'")
132 reload_doc('hr', 'doctype', 'salary_slip')
Rushabh Mehta61790802011-07-17 10:52:47 +0530133 elif patch_no == 326:
134 # load the new billing page
135 if cint(webnotes.conn.get_value('Control Panel',None,'sync_with_gateway')):
136 reload_doc('server_tools','page','billing')
nabinhaite6526362011-07-19 18:09:26 +0530137 elif patch_no == 327:
Rushabh Mehta391aa022011-07-25 14:07:50 +0530138 # patch for support email settings now moved to email settings
139 reload_doc('setup','doctype','email_settings')
Brahma K09307622011-07-27 12:03:34 +0530140
Rushabh Mehta391aa022011-07-25 14:07:50 +0530141 # map fields from support to email settings
142 field_map = {
143 'support_email': 'email',
144 'support_host':'host',
145 'support_username': 'username',
146 'support_password': 'password',
Rushabh Mehtab7186d42011-07-25 14:37:48 +0530147 'support_use_ssl': 'use_ssl',
Rushabh Mehta391aa022011-07-25 14:07:50 +0530148 'sync_support_mails': 'integrate_incoming',
149 'signature': 'support_signature'
150 }
Brahma K09307622011-07-27 12:03:34 +0530151
Rushabh Mehta391aa022011-07-25 14:07:50 +0530152 for key in field_map:
153 webnotes.conn.set_value('Email Settings',None,key, \
154 webnotes.conn.get_value('Support Email Settings',None,field_map[key]))
Brahma K09307622011-07-27 12:03:34 +0530155
Rushabh Mehta391aa022011-07-25 14:07:50 +0530156 # delete support email settings
Rushabh Mehta391aa022011-07-25 14:07:50 +0530157 delete_doc('DocType', 'Support Email Settings')
158
Rushabh Mehta9b8fad22011-07-25 14:45:42 +0530159 reload_doc('support','doctype','support_ticket')
Nabin Hait587ac5c2011-07-26 15:46:10 +0530160 sql("delete from tabDocField where fieldname='problem_description' and parent='Support Ticket'")
161 elif patch_no == 328:
nabinhaite6526362011-07-19 18:09:26 +0530162 if webnotes.conn.get_value('Control Panel', None, 'account_id') != 'axjanak2011':
163 sql("delete from `tabDocField` where fieldname = 'supplier_status' and parent = 'Supplier'")
Nabin Hait587ac5c2011-07-26 15:46:10 +0530164 elif patch_no == 329:
nabinhaitde9826c2011-07-20 18:02:59 +0530165 reload_doc('utilities', 'doctype', 'rename_tool')
166 reload_doc('utilities', 'doctype', 'bulk_rename_tool')
Brahma K09307622011-07-27 12:03:34 +0530167 elif patch_no == 330:
168 reload_doc('accounts', 'doctype', 'lease_agreement')
169 reload_doc('accounts', 'doctype', 'lease_installment')
170
171 reload_doc('accounts', 'search_criteria', 'lease_agreement_list')
172 reload_doc('accounts', 'search_criteria', 'lease_monthly_future_installment_inflows')
173 reload_doc('accounts', 'search_criteria', 'lease_overdue_age_wise')
Nabin Haitf541b742011-07-28 15:33:42 +0530174 reload_doc('accounts', 'search_criteria', 'lease_over_due_list')
Brahma K09307622011-07-27 12:03:34 +0530175 reload_doc('accounts', 'search_criteria', 'lease_receipts_client_wise')
176 reload_doc('accounts', 'search_criteria', 'lease_receipt_summary_year_to_date')
177 reload_doc('accounts', 'search_criteria', 'lease_yearly_future_installment_inflows')
Brahma Kbcdade52011-07-27 12:11:09 +0530178
179 reload_doc('accounts', 'Module Def', 'Accounts')
Brahma K3b1ebe02011-07-27 13:04:11 +0530180 elif patch_no == 331:
181 p = get_obj('Patch Util')
182 # permission
183 p.add_permission('Lease Agreement', 'Accounts Manager', 0, read = 1, write=1,submit=1, cancel=1,amend=1)
184 p.add_permission('Lease Agreement', 'Accounts Manager', 1, read = 1)
Nabin Haitd29916b2011-07-27 14:26:23 +0530185 elif patch_no == 332:
186 sql("update `tabDocField` set permlevel=1, hidden = 1 where parent = 'Bulk Rename Tool' and fieldname = 'file_list'")
Brahma Ke8ec9752011-08-16 12:21:07 +0530187 elif patch_no == 333:
Nabin Haitd31de592011-08-10 14:01:27 +0530188 sql("update `tabDocPerm` set `create` =1 where role = 'Accounts Manager' and parent = 'Lease Agreement'")
Brahma K2eb81012011-08-16 12:27:48 +0530189
Nabin Hait812e7182011-08-05 11:10:30 +0530190 p = get_obj('Patch Util')
191 p.add_permission('DocType Mapper', 'System Manager', 0, read = 1, write=1, create=1)
192 p.add_permission('Role', 'System Manager', 0, read = 1, write=1, create=1)
193 p.add_permission('Print Format', 'System Manager', 0, read = 1, write=1, create=1)
Nabin Haitc4e579c2011-08-05 11:21:35 +0530194 elif patch_no == 334:
195 reload_doc('knowledge_base', 'doctype', 'answer')
Nabin Haitf82b1cc2011-08-05 13:23:14 +0530196 elif patch_no == 335:
Nabin Hait2c0ab732011-08-05 13:40:04 +0530197 for dt in ['Account', 'Cost Center', 'Territory', 'Item Group', 'Customer Group']:
Anand Doshib61abff2011-08-10 11:58:05 +0530198 sql("update `tabDocField` set fieldtype = 'Link', options = %s where fieldname = 'old_parent' and parent = %s", (dt, dt))
199 elif patch_no == 336:
Anand Doshiaabf1742011-08-10 13:27:25 +0530200 reload_doc('server_tools','page','billing')
201 elif patch_no == 337:
Brahma K2eb81012011-08-16 12:27:48 +0530202 item_list = webnotes.conn.sql("""SELECT name, description_html
Anand Doshiaabf1742011-08-10 13:27:25 +0530203 FROM tabItem""")
204 if item_list:
205 for item, html in item_list:
206 if html and "getfile" in html and "acx" in html:
207 ac_id = webnotes.conn.sql("""SELECT value FROM `tabSingles` WHERE doctype='Control Panel' AND field='account_id'""")
208 sp_acx = html.split("acx=")
209 l_acx = len(sp_acx)
Brahma K2eb81012011-08-16 12:27:48 +0530210 if l_acx > 1:
Anand Doshiaabf1742011-08-10 13:27:25 +0530211 for i in range(l_acx-1):
212 sp_quot = sp_acx[i+1].split('"')
213 if len(sp_quot) > 1: sp_quot[0] = str(ac_id[0][0])
214 sp_acx[i+1] = '"'.join(sp_quot)
215 html = "acx=".join(sp_acx)
Nabin Haitd31de592011-08-10 14:01:27 +0530216 webnotes.conn.sql("""UPDATE tabItem SET description_html=%s WHERE name=%s""", (html, item))
Nabin Hait76980b02011-08-10 16:35:25 +0530217 elif patch_no == 338:
218 # Patch for billing status based on amount
219 # reload so and dn
220 reload_doc('selling','doctype','sales_order')
221 reload_doc('stock','doctype','delivery_note')
Brahma K2eb81012011-08-16 12:27:48 +0530222
Nabin Hait76980b02011-08-10 16:35:25 +0530223 # delete billed_qty field
224 sql("delete from `tabDocField` where fieldname = 'billed_qty' and parent in ('Sales Order Detail', 'Delivery Note Detail')")
Brahma K2eb81012011-08-16 12:27:48 +0530225
Nabin Hait76980b02011-08-10 16:35:25 +0530226 # update billed amt in item table in so and dn
227 sql(""" update `tabSales Order Detail` so
228 set billed_amt = (select sum(amount) from `tabRV Detail` where `so_detail`= so.name and docstatus=1 and parent not like 'old%%'), modified = now()""")
Brahma K2eb81012011-08-16 12:27:48 +0530229
Nabin Hait76980b02011-08-10 16:35:25 +0530230 sql(""" update `tabDelivery Note Detail` dn
231 set billed_amt = (select sum(amount) from `tabRV Detail` where `dn_detail`= dn.name and docstatus=1 and parent not like 'old%%'), modified = now()""")
Brahma K2eb81012011-08-16 12:27:48 +0530232
Nabin Hait76980b02011-08-10 16:35:25 +0530233 # calculate % billed based on item table
234 sql(""" update `tabSales Order` so
235 set per_billed = (select sum(if(amount > ifnull(billed_amt, 0), billed_amt, amount))/sum(amount)*100 from `tabSales Order Detail` where parent = so.name), modified = now()""")
Brahma K2eb81012011-08-16 12:27:48 +0530236
Nabin Hait76980b02011-08-10 16:35:25 +0530237 sql(""" update `tabDelivery Note` dn
238 set per_billed = (select sum(if(amount > ifnull(billed_amt, 0), billed_amt, amount))/sum(amount)*100 from `tabDelivery Note Detail` where parent = dn.name), modified = now()""")
239
240 # update billing status based on % billed
241 sql("""update `tabSales Order` set billing_status = if(ifnull(per_billed,0) < 0.001, 'Not Billed',
242 if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""")
243 sql("""update `tabDelivery Note` set billing_status = if(ifnull(per_billed,0) < 0.001, 'Not Billed',
244 if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""")
Rushabh Mehtaab5292a2011-08-16 10:04:29 +0530245
Rushabh Mehtaaf43b742011-08-11 12:37:11 +0530246 # update name of questions page
247 sql("update tabPage set name='questions' where name='Questions'")
Brahma K2eb81012011-08-16 12:27:48 +0530248 sql("update tabPage set name='question-view' where name='Question View'")
Brahma Kfce442e2011-08-16 14:48:46 +0530249 elif patch_no == 339:
Brahma Ke8ec9752011-08-16 12:21:07 +0530250 reload_doc('production','doctype','bill_of_materials')
Nabin Hait95374462011-08-22 14:40:11 +0530251 elif patch_no == 340:
252 sql("update `tabDocField` set permlevel = 0 where (fieldname in ('process', 'production_order', 'fg_completed_qty') or label = 'Get Items') and parent = 'Stock Entry'")
Brahma K82187ce2011-08-23 15:42:34 +0530253 elif patch_no == 341:
254 reload_doc('stock','doctype','delivery_note')
Brahma K67164802011-08-23 16:22:29 +0530255 reload_doc('stock','doctype','item')
256 reload_doc('selling','doctype','quotation')
Brahma K82187ce2011-08-23 15:42:34 +0530257 reload_doc('stock','Print Format','Delivery Note Packing List Wise')
258
259 if not sql("select format from `tabDocFormat` where name = 'Delivery Note Packing List Wise' and parent = 'Delivery Note'"):
260 from webnotes.model.doc import addchild
261 dt_obj = get_obj('DocType', 'Delivery Note', with_children = 1)
262 ch = addchild(dt_obj.doc, 'formats', 'DocFormat', 1)
263 ch.format = 'Delivery Note Packing List Wise'
264 ch.save(1)
Brahma Kc735d442011-08-23 18:38:48 +0530265 elif patch_no == 342:
Nabin Haita0760df2011-08-23 17:29:54 +0530266 sql("update `tabDocField` set permlevel = 0 where parent = 'Stock Entry Detail' and fieldname in ('s_warehouse', 't_warehouse', 'fg_item')")
Brahma Kb25ed702011-08-23 18:41:25 +0530267 elif patch_no == 343:
Brahma Kc735d442011-08-23 18:38:48 +0530268 reload_doc('stock','doctype','item_customer_detail')
Nabin Haitcfe8ee82011-08-25 14:02:01 +0530269 elif patch_no == 344:
Nabin Hait7b8f53c2011-08-24 11:23:34 +0530270 sql("delete from `tabDocFormat` where ifnull(format, '') = '' and parent = 'Delivery Note'")
Rushabh Mehta8cf45172011-09-08 14:17:41 +0530271 reload_doc('stock', 'doctype', 'delivery_note_detail')
272 reload_doc('stock', 'doctype', 'item_customer_detail')
Rushabh Mehta33bce672011-08-25 15:15:25 +0530273 elif patch_no == 345:
Rushabh Mehta910d9552011-08-30 16:09:01 +0530274 # rerun 343 (merge confict)
275 reload_doc('stock','doctype','item_customer_detail')
Nabin Haitcfe8ee82011-08-25 14:02:01 +0530276 sql("delete from `tabModule Def Item` where display_name = 'Salary Slip Control Panel' and parent = 'HR'")
277 reload_doc('hr','Module Def','HR')
Rushabh Mehta33bce672011-08-25 15:15:25 +0530278 elif patch_no == 346:
Rushabh Mehta96fde952011-08-29 17:54:27 +0530279 pass
Nabin Hait2c030152011-08-25 19:41:24 +0530280 elif patch_no == 347:
281 sql("delete from `tabField Mapper Detail` where from_field = to_field and map = 'Yes' and ifnull(checking_operator, '') = ''")
Nabin Hait1d5cab82011-08-29 13:16:52 +0530282 elif patch_no == 348:
283 sql("update `tabStock Ledger Entry` set is_cancelled = 'No' where voucher_type = 'Serial No'")
Nabin Haite0410da2011-08-29 14:24:19 +0530284 elif patch_no == 349:
285 delete_doc('Custom Script', 'Update Series-Server')
286 delete_doc('Custom Script', 'Profile-Client')
287 delete_doc('Custom Script', 'Event-Client')
288 delete_doc('Custom Script', 'File-Server')
Brahma K3c9a6a12011-08-31 12:55:41 +0530289
Rushabh Mehta96fde952011-08-29 17:54:27 +0530290 # reload profile with new fields for security
291 delete_doc('DocType', 'Profile')
292 reload_doc('core', 'doctype', 'profile')
Nabin Hait7282fce2011-08-30 17:34:14 +0530293 elif patch_no == 350:
294 reload_doc('stock', 'doctype', 'delivery_note_detail')
295 reload_doc('stock', 'doctype', 'item_customer_detail')
Nabin Hait93592132011-08-31 11:27:51 +0530296 elif patch_no == 351:
297 reload_doc('home', 'page', 'dashboard')
Nabin Haitef757612011-09-02 13:10:23 +0530298 elif patch_no == 352:
299 reload_doc('stock','doctype','delivery_note')
300 reload_doc('stock','doctype','item')
301 reload_doc('selling','doctype','quotation')
302 reload_doc('stock','Print Format','Delivery Note Packing List Wise')
303
304 if not sql("select format from `tabDocFormat` where name = 'Delivery Note Packing List Wise' and parent = 'Delivery Note'"):
305 from webnotes.model.doc import addchild
306 dt_obj = get_obj('DocType', 'Delivery Note', with_children = 1)
307 ch = addchild(dt_obj.doc, 'formats', 'DocFormat', 1)
308 ch.format = 'Delivery Note Packing List Wise'
309 ch.save(1)
Nabin Haitc63e62e2011-09-02 14:44:15 +0530310 elif patch_no == 353:
Rushabh Mehta5f506172011-09-13 15:48:51 +0530311 reload_doc('core', 'doctype', 'doctype')
312 sql("update `tabDocType` set default_print_format = 'Standard' where name = 'Delivery Note'")
Nabin Hait8c2618c2011-09-02 17:43:32 +0530313 elif patch_no == 354:
Rushabh Mehta5f506172011-09-13 15:48:51 +0530314 reload_doc('stock', 'doctype', 'delivery_note')
315 reload_doc('stock', 'doctype', 'delivery_note_detail')
316 elif patch_no == 355:
317 sql("update `tabDocField` set print_hide =1 where fieldname in ('pack_no', 'pack_gross_wt', 'weight_uom', 'pack_nett_wt') and parent = 'Delivery Note Detail'")
318 elif patch_no == 356:
319 sql("update `tabDocField` set print_hide =1 where fieldname = 'print_packing_slip' and parent = 'Delivery Note'")
320 elif patch_no == 357:
321 reload_doc('hr', 'doctype', 'salary_manager')
322 elif patch_no == 358:
Rushabh Mehtab5717bd2011-09-06 12:46:33 +0530323 reload_doc('setup', 'doctype','features_setup')
Brahma K3c9a6a12011-08-31 12:55:41 +0530324 reload_doc('stock','doctype','item')
325 sql("update tabDocField set label='Produced Qty',description='Updated after finished goods are transferred to FG Warehouse through Stock Entry' where parent='Production Order' and fieldname='produced_qty'")
Brahma K8e8c4822011-08-31 15:46:29 +0530326 rs = sql("select fieldname from tabDocField where parent='Features Setup' and fieldname is not null")
327 from webnotes.model.doc import Document
Nabin Hait0b5f9b02011-09-16 14:32:23 +0530328 m = Document('Features Setup')
Brahma K8e8c4822011-08-31 15:46:29 +0530329 for d in rs:
330 m.fields[d[0]] = 1
Brahma K779cfaf2011-09-02 16:55:03 +0530331 m.save()
Rushabh Mehta5f506172011-09-13 15:48:51 +0530332 elif patch_no == 359:
Nabin Hait8c2618c2011-09-02 17:43:32 +0530333 reload_doc('hr', 'doctype', 'salary_slip')
334 delete_doc('DocType', 'Salary Control Panel')
Rushabh Mehta5f506172011-09-13 15:48:51 +0530335 elif patch_no == 360:
Rushabh Mehta8cf45172011-09-08 14:17:41 +0530336 sql("delete from `tabDocField` where (fieldname in ('client_string', 'server_code_error', 'server_code_compiled', 'server_code', 'server_code_core', 'client_script', 'client_script_core', 'dt_template', 'change_log') or label = 'Template') and parent = 'DocType'")
Rushabh Mehta5f506172011-09-13 15:48:51 +0530337 elif patch_no == 361:
338 sql("update `tabModule Def Item` set doc_name = 'GL Entry' where display_name in ('Lease Agreement List', 'Lease Monthly Future Installment Inflows', 'Lease Overdue Age Wise', 'Lease Overdue List', 'Lease Receipts Client Wise', 'Lease Receipt Summary Month Wise', 'Lease Yearly Future Installment Inflows') and parent = 'Accounts'")
339 elif patch_no == 362:
340 sql("update `tabDocField` set no_copy = 1 where fieldname in ('amended_from', 'amendment_date', 'file_list', 'naming_series', 'status')")
341 elif patch_no == 363:
342 reload_doc('accounts', 'search_criteria', 'voucher_wise_tax_details')
343 reload_doc('accounts', 'Module Def', 'Accounts')
344 mappers = sql("select name, module from `tabDocType Mapper`")
345 for d in mappers:
346 if d[0] and d[1]:
347 reload_doc(d[1].lower(), 'DocType Mapper', d[0])
Rushabh Mehta27739402011-09-15 12:55:25 +0530348 elif patch_no == 364:
349 sql("""delete from `tabField Mapper Detail`
350 where to_field in ('qty', 'amount', 'export_amount')
351 and parent in ('Sales Order-Receivable Voucher', 'Delivery Note-Receivable Voucher')
352 """)
353 mappers = sql("select name, module from `tabDocType Mapper`")
354 for d in mappers:
355 if d[0] and d[1]:
356 reload_doc(d[1].lower(), 'DocType Mapper', d[0])
357 elif patch_no == 365:
358 from patches.delivery_billing_status_patch import run_patch
359 run_patch()
Nabin Haitfdb0e362011-09-19 12:22:47 +0530360 elif patch_no == 367:
Nabin Hait0b5f9b02011-09-16 14:32:23 +0530361 bin = sql("select name from tabBin")
362 for b in bin:
363 bobj = get_obj('Bin',b[0])
Nabin Hait93ba4fb2011-11-08 15:30:04 +0530364 bobj.update_entries_after(posting_date = '2011-09-01', posting_time = '01:00')
Nabin Haitfdb0e362011-09-19 12:22:47 +0530365 elif patch_no == 368:
Nabin Haitb3ce0ec2011-09-22 16:10:15 +0530366 from webnotes.utils import nestedset
367 t = [
368 ['Account', 'parent_account'], ['Cost Center', 'parent_cost_center'],
369 ['Item Group', 'parent_item_group'], ['Territory', 'parent_territory'],
370 ['Customer Group', 'parent_customer_group'], ['Sales Person', 'parent_sales_person']
371 ]
372 for d in t:
373 nestedset.rebuild_tree(d[0], d[1])
Nabin Hait7e97d1f2011-09-27 11:34:06 +0530374 elif patch_no == 369:
Nabin Haitb3ce0ec2011-09-22 16:10:15 +0530375 reload_doc('hr', 'doctype', 'appraisal')
376 reload_doc('hr', 'doctype', 'appraisal_detail')
Nabin Hait7e97d1f2011-09-27 11:34:06 +0530377 elif patch_no == 370:
378 sql("update `tabDocField` set `hidden` = 0 where fieldname = 'group_or_ledger' and parent = 'Cost Center'")
Nabin Haitb3ce0ec2011-09-22 16:10:15 +0530379 elif patch_no == 371:
Rushabh Mehtaae4d1f92012-03-12 14:34:55 +0530380 from webnotes.modules import reload_doc
Nabin Haitb30c4a62011-10-05 11:36:16 +0530381
382 reload_doc('setup', 'doctype','features_setup')
383 flds = ['page_break', 'projects', 'packing_details', 'discounts', 'brands', 'item_batch_nos', 'after_sales_installations', 'item_searial_nos', 'item_group_in_details', 'exports', 'imports', 'item_advanced', 'sales_extras', 'more_info', 'quality', 'manufacturing', 'pos', 'item_serial_nos']
384
385 for f in flds:
386 val = sql("select value from tabSingles where field = '%s' and doctype = 'Features Setup'" % f)
387 val = val and val[0][0] or 0
388 sql("update `tabSingles` set `value` = %s where `field` = '%s' and doctype = 'Features Setup'" % (val, '__'+f))
389
390 st = "'"+"', '".join(flds)+"'"
391 sql("delete from `tabDocField` where fieldname in (%s) and parent = 'Features Setup'" % st)
392 sql("delete from `tabDefaultValue` where defkey in (%s) and parent = 'Control Panel'" % st)
393
394 get_obj('Features Setup', 'Features Setup').doc.save()
Nabin Hait685564f2011-10-11 14:42:34 +0530395 elif patch_no == 372:
Rushabh Mehtaae4d1f92012-03-12 14:34:55 +0530396 from webnotes.modules import reload_doc
Nabin Haitb30c4a62011-10-05 11:36:16 +0530397
398 reload_doc('setup', 'doctype','features_setup')
399 flds = ['page_break', 'projects', 'packing_details', 'discounts', 'brands', 'item_batch_nos', 'after_sales_installations', 'item_searial_nos', 'item_group_in_details', 'exports', 'imports', 'item_advanced', 'sales_extras', 'more_info', 'quality', 'manufacturing', 'pos', 'item_serial_nos']
400
401 for f in flds:
402 val = sql("select value from tabSingles where field = '%s' and doctype = 'Features Setup'" % f)
403 val = val and val[0][0] or 0
404 sql("update `tabSingles` set `value` = %s where `field` = '%s' and doctype = 'Features Setup'" % (val, 'fs_'+f))
405
406 st = "'__"+"', '__".join(flds)+"'"
407
408 sql("delete from `tabDocField` where fieldname in (%s) and parent = 'Features Setup'" % st)
409 sql("delete from `tabDefaultValue` where defkey in (%s) and parent = 'Control Panel'" % st)
410
411 get_obj('Features Setup', 'Features Setup').doc.save()
Nabin Hait685564f2011-10-11 14:42:34 +0530412 elif patch_no == 373:
Nabin Haita55eec12011-10-05 11:47:08 +0530413 sql("delete from `tabDocField` where fieldname = 'item_searial_nos' and parent = 'Features Setup'")
414 sql("delete from `tabDefaultValue` where defkey = 'item_searial_nos' and parent = 'Control Panel'")
Nabin Hait685564f2011-10-11 14:42:34 +0530415 elif patch_no == 374:
Nabin Haitda50c082011-10-05 12:10:08 +0530416 rs = sql("select fieldname from tabDocField where parent='Features Setup' and fieldname is not null")
417 from webnotes.model.code import get_obj
418 m = get_obj('Features Setup')
419 for d in rs:
420 m.doc.fields[d[0]] = 1
421 m.doc.save()
422 m.validate()
Nabin Hait685564f2011-10-11 14:42:34 +0530423 elif patch_no == 375:
Nabin Hait7a941862011-10-07 12:30:48 +0530424 from webnotes.session_cache import clear_cache
425 clear_cache(webnotes.session['user'])
Nabin Hait685564f2011-10-11 14:42:34 +0530426 elif patch_no == 376:
Nabin Haitddaa5a32011-10-07 12:36:13 +0530427 reload_doc('stock', 'DocType Mapper', 'Purchase Order-Purchase Receipt')
Nabin Hait685564f2011-10-11 14:42:34 +0530428 elif patch_no == 377:
Nabin Hait8e54aa82011-10-07 19:03:19 +0530429 flds = ['page_break', 'projects', 'packing_details', 'discounts', 'brands', 'item_batch_nos', 'after_sales_installations', 'item_searial_nos', 'item_group_in_details', 'exports', 'imports', 'item_advanced', 'sales_extras', 'more_info', 'quality', 'manufacturing', 'pos', 'item_serial_nos']
430
431 st = "'"+"', '".join(flds)+"'"
432 sql("delete from `tabDocField` where fieldname in (%s) and parent = 'Features Setup'" % st)
433 sql("delete from `tabDefaultValue` where defkey in (%s) and parent = 'Control Panel'" % st)
434
435 from webnotes.session_cache import clear_cache
436 clear_cache(webnotes.session['user'])
Nabin Hait685564f2011-10-11 14:42:34 +0530437 elif patch_no == 378:
438 comp = sql("select name from tabCompany where docstatus!=2")
439 fy = sql("select name from `tabFiscal Year` order by year_start_date asc")
440 for c in comp:
441 prev_fy = ''
442 for f in fy:
443 fy_obj = get_obj('Fiscal Year', f[0])
444 fy_obj.doc.past_year = prev_fy
445 fy_obj.doc.company = c[0]
446 fy_obj.doc.save()
447 fy_obj.repost()
448 prev_fy = f[0]
449 sql("commit")
450 sql("start transaction")
451 elif patch_no == 379:
452 sql("update tabDocPerm set amend = 0 where parent = 'Salary Structure'")
453 sql("update tabDocPerm set cancel = 1 where parent = 'Company' and role = 'System Manager'")
454 elif patch_no == 380:
455 if sql("select count(name) from `tabDocField` where label = 'View Ledger Entry' and parent = 'Journal Voucher' and fieldtype = 'Button'")[0][0] > 1:
456 sql("delete from `tabDocField` where label = 'View Ledger Entry' and parent = 'Journal Voucher' and fieldtype = 'Button' limit 1")
457 if sql("select count(name) from `tabDocField` where label = 'Get Balance' and parent = 'Journal Voucher' and fieldtype = 'Button'")[0][0] > 1:
458 sql("delete from `tabDocField` where label = 'Get Balance' and parent = 'Journal Voucher' and fieldtype = 'Button' limit 1")
459 elif patch_no == 381:
460 reload_doc('accounts', 'doctype', 'internal_reconciliation')
461 reload_doc('accounts', 'doctype', 'ir_payment_detail')
462 reload_doc('accounts', 'Module Def', 'Accounts')
463 elif patch_no == 382:
464 if sql("select count(name) from `tabDocField` where label = 'Get Specification Details' and parent = 'QA Inspection Report' and fieldtype = 'Button'")[0][0] > 1:
465 sql("delete from `tabDocField` where label = 'Get Specification Details' and parent = 'QA Inspection Report' and fieldtype = 'Button' limit 1")
Nabin Hait6a056162011-10-10 12:23:10 +0530466 elif patch_no == 383:
467 reload_doc('accounts', 'doctype', 'cost_center')
Nabin Hait15cad192011-10-10 17:10:24 +0530468 elif patch_no == 384:
469 reload_doc('stock', 'Module Def', 'Stock')
470 sql("delete from `tabModule Def Item` where display_name = 'Serial No' and parent = 'Support'")
471 sql("update `tabDocType` set subject = 'Item Code: %(item_code)s, Warehouse: %(warehouse)s' where name = 'Serial No'")
Nabin Haitc1d42812011-10-11 12:50:55 +0530472 elif patch_no == 385:
473 # Patch for adding packing related columns (packed by, checked by, shipping mark etc)
474 reload_doc('stock','doctype','delivery_note')
Nabin Hait89a9a262011-10-12 12:41:00 +0530475 elif patch_no == 386:
476 sql("update `tabDocField` set allow_on_submit = 1 where fieldname = 'page_break'")
Nabin Haitc7cf94e2011-10-12 13:16:11 +0530477 elif patch_no == 387:
478 sql("update `tabDocField` set allow_on_submit = 1 where fieldname in ('indent_details', 'po_details', 'purchase_receipt_details', 'entries', 'sales_order_details', 'delivery_note_details', 'quotation_details') and fieldtype = 'Table'")
Nabin Haitfe4c4f92011-10-13 11:07:14 +0530479 elif patch_no == 388:
Nabin Haitd84ad942011-10-13 14:04:26 +0530480 pass