[fix] [patch] rename_quality_inspection_field

This commit is contained in:
Rushabh Mehta 2016-11-21 16:19:50 +05:30
parent d50d6a559c
commit 75d455422a

View File

@ -5,30 +5,30 @@ from frappe.model.utils.rename_field import *
def execute(): def execute():
for doctype in ("Purchase Receipt Item", "Delivery Note Item"): for doctype in ("Purchase Receipt Item", "Delivery Note Item"):
frappe.reload_doctype(doctype) frappe.reload_doctype(doctype)
table_columns = frappe.db.get_table_columns(doctype) table_columns = frappe.db.get_table_columns(doctype)
if "qa_no" in table_columns: if "qa_no" in table_columns:
rename_field(doctype, "qa_no", "quality_inspection") rename_field(doctype, "qa_no", "quality_inspection")
frappe.reload_doctype("Item") frappe.reload_doctype("Item")
rename_field("Item", "inspection_required", "inspection_required_before_purchase") rename_field("Item", "inspection_required", "inspection_required_before_purchase")
frappe.reload_doctype("Quality Inspection") frappe.reload_doc('stock', 'doctype', 'quality_inspection')
frappe.db.sql(""" frappe.db.sql("""
update update
`tabQuality Inspection` `tabQuality Inspection`
set set
reference_type = 'Purchase Receipt', reference_name = purchase_receipt_no reference_type = 'Purchase Receipt', reference_name = purchase_receipt_no
where where
ifnull(purchase_receipt_no, '') != '' and inspection_type = 'Incoming' ifnull(purchase_receipt_no, '') != '' and inspection_type = 'Incoming'
""") """)
frappe.db.sql(""" frappe.db.sql("""
update update
`tabQuality Inspection` `tabQuality Inspection`
set set
reference_type = 'Delivery Note', reference_name = delivery_note_no reference_type = 'Delivery Note', reference_name = delivery_note_no
where where
ifnull(delivery_note_no, '') != '' and inspection_type = 'Outgoing' ifnull(delivery_note_no, '') != '' and inspection_type = 'Outgoing'
""") """)
@ -36,4 +36,3 @@ def execute():
update_reports("Quality Inspection", old_fieldname, "reference_name") update_reports("Quality Inspection", old_fieldname, "reference_name")
update_users_report_view_settings("Quality Inspection", old_fieldname, "reference_name") update_users_report_view_settings("Quality Inspection", old_fieldname, "reference_name")
update_property_setters("Quality Inspection", old_fieldname, "reference_name") update_property_setters("Quality Inspection", old_fieldname, "reference_name")