2013-08-05 09:29:54 +00:00
|
|
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
2012-12-10 13:58:38 +00:00
|
|
|
import webnotes
|
|
|
|
|
2012-12-10 12:43:34 +00:00
|
|
|
def execute():
|
2012-12-10 13:32:38 +00:00
|
|
|
delete_doctypes()
|
|
|
|
rename_module()
|
2012-12-14 08:55:51 +00:00
|
|
|
cleanup_bom()
|
2012-12-18 13:12:02 +00:00
|
|
|
rebuild_exploded_bom()
|
2012-12-10 13:32:38 +00:00
|
|
|
|
|
|
|
def delete_doctypes():
|
2012-12-10 12:43:34 +00:00
|
|
|
from webnotes.model import delete_doc
|
|
|
|
delete_doc("DocType", "Production Control")
|
2012-12-10 13:32:38 +00:00
|
|
|
delete_doc("DocType", "BOM Control")
|
|
|
|
|
2012-12-14 08:55:51 +00:00
|
|
|
|
2012-12-10 13:32:38 +00:00
|
|
|
def rename_module():
|
2012-12-10 14:07:49 +00:00
|
|
|
webnotes.reload_doc("core", "doctype", "role")
|
|
|
|
webnotes.reload_doc("core", "doctype", "page")
|
|
|
|
webnotes.reload_doc("core", "doctype", "module_def")
|
|
|
|
|
2012-12-11 09:48:51 +00:00
|
|
|
if webnotes.conn.exists("Role", "Production User"):
|
|
|
|
webnotes.rename_doc("Role", "Production User", "Manufacturing User")
|
|
|
|
if webnotes.conn.exists("Role", "Production Manager"):
|
|
|
|
webnotes.rename_doc("Role", "Production Manager", "Manufacturing Manager")
|
2012-12-10 14:07:49 +00:00
|
|
|
|
|
|
|
if webnotes.conn.exists("Page", "manufacturing-home"):
|
|
|
|
webnotes.delete_doc("Page", "production-home")
|
|
|
|
else:
|
|
|
|
webnotes.rename_doc("Page", "production-home", "manufacturing-home")
|
|
|
|
|
2012-12-11 09:48:51 +00:00
|
|
|
if webnotes.conn.exists("Module Def", "Production"):
|
|
|
|
webnotes.rename_doc("Module Def", "Production", "Manufacturing")
|
2012-12-10 13:58:38 +00:00
|
|
|
|
2012-12-20 11:23:33 +00:00
|
|
|
modules_list = webnotes.conn.get_global('modules_list')
|
|
|
|
if modules_list:
|
|
|
|
webnotes.conn.set_global("modules_list", modules_list.replace("Production",
|
|
|
|
"Manufacturing"))
|
2012-12-11 13:08:58 +00:00
|
|
|
|
|
|
|
# set end of life to null if "0000-00-00"
|
|
|
|
webnotes.conn.sql("""update `tabItem` set end_of_life=null where end_of_life='0000-00-00'""")
|
2012-12-10 13:32:38 +00:00
|
|
|
|
2012-12-18 13:12:02 +00:00
|
|
|
def rebuild_exploded_bom():
|
2012-12-11 09:44:30 +00:00
|
|
|
from webnotes.model.code import get_obj
|
|
|
|
for bom in webnotes.conn.sql("""select name from `tabBOM` where docstatus < 2"""):
|
2012-12-11 09:45:04 +00:00
|
|
|
get_obj("BOM", bom[0], with_children=1).on_update()
|
2012-12-14 08:55:51 +00:00
|
|
|
|
|
|
|
def cleanup_bom():
|
2012-12-18 13:12:02 +00:00
|
|
|
webnotes.conn.sql("""UPDATE `tabBOM` SET is_active = 1 where ifnull(is_active, 'No') = 'Yes'""")
|
|
|
|
webnotes.conn.sql("""UPDATE `tabBOM` SET is_active = 0 where ifnull(is_active, 'No') = 'No'""")
|
|
|
|
webnotes.reload_doc("manufacturing", "doctype", "bom")
|
|
|
|
webnotes.conn.sql("""update `tabBOM` set with_operations = 1""")
|
2012-12-14 08:55:51 +00:00
|
|
|
|