brotherton-erpnext/patches/december_2012/stock_entry_cleanup.py

75 lines
1.9 KiB
Python
Raw Normal View History

2012-12-18 04:59:06 +00:00
import webnotes
def execute():
# removed following fields
webnotes.reload_doc("stock", "doctype", "stock_entry")
2012-12-18 04:59:06 +00:00
custom_fields()
deprecate_process()
webnotes.delete_doc("doctype", "sandbox")
def custom_fields():
fields = [
{
"label": "Is Excisable Goods",
"fieldname": "is_excisable_goods",
"fieldtype": "Select",
"options": "\nYes\nNo",
2012-12-18 13:12:02 +00:00
"insert_after": "Company"
2012-12-18 04:59:06 +00:00
},
{
"label": "Excisable Goods",
"fieldname": "excisable_goods",
"fieldtype": "Select",
"options": "\nReturnable\nNon-Returnable)",
2012-12-18 13:12:02 +00:00
"insert_after": "Amended From"
2012-12-18 04:59:06 +00:00
},
{
"label": "Under Rule",
"fieldname": "under_rule",
"fieldtype": "Select",
"options": "\nOrdinary\n57 AC (5) a\n57 F (2) Non-Exc.",
2012-12-18 13:12:02 +00:00
"insert_after": "Remarks"
2012-12-18 04:59:06 +00:00
},
{
"label": "Transporter",
"fieldname": "transporter",
"fieldtype": "Data",
"options": "",
2012-12-18 13:12:02 +00:00
"insert_after": "Project Name"
2012-12-18 04:59:06 +00:00
},
{
"label": "Transfer Date",
"fieldname": "transfer_date",
"fieldtype": "Date",
"options": "",
2012-12-18 13:12:02 +00:00
"insert_after": "Select Print Heading"
2012-12-18 04:59:06 +00:00
},
]
for fld in fields:
if webnotes.conn.sql("""select name from `tabStock Entry`
where ifnull(%s, '') != '' and docstatus<2""", (fld['fieldname'])):
create_custom_field(fld)
def create_custom_field(fld):
fld.update({
"doctype": "Custom Field",
"dt": "Stock Entry",
"print_hide": 1,
"permlevel": 0
})
from webnotes.model.doclist import DocList
webnotes.insert(DocList([fld]))
def deprecate_process():
webnotes.conn.sql("""update `tabStock Entry`
2012-12-18 13:12:02 +00:00
set `purpose`="Material Transfer"
2012-12-18 04:59:06 +00:00
where process="Material Transfer" and purpose="Production Order" """)
webnotes.conn.sql("""update `tabStock Entry`
2012-12-18 13:12:02 +00:00
set `purpose`="Manufacture/Repack"
where (process="Backflush" and purpose="Production Order") or purpose="Other" """)
webnotes.conn.sql("""update `tabStock Entry`
set `purpose`="Subcontract"
where process="Subcontracting" """)