2020-08-13 03:50:36 +00:00
|
|
|
import frappe
|
|
|
|
|
2021-09-02 11:14:59 +00:00
|
|
|
|
2020-08-13 03:50:36 +00:00
|
|
|
def execute():
|
|
|
|
if frappe.db.exists("DocType", "Lost Reason Detail"):
|
2020-08-26 06:30:45 +00:00
|
|
|
frappe.reload_doc("crm", "doctype", "opportunity_lost_reason")
|
2020-08-13 03:50:36 +00:00
|
|
|
frappe.reload_doc("crm", "doctype", "opportunity_lost_reason_detail")
|
|
|
|
frappe.reload_doc("setup", "doctype", "quotation_lost_reason_detail")
|
|
|
|
|
|
|
|
frappe.db.sql(
|
|
|
|
"""INSERT INTO `tabOpportunity Lost Reason Detail` SELECT * FROM `tabLost Reason Detail` WHERE `parenttype` = 'Opportunity'"""
|
|
|
|
)
|
|
|
|
|
|
|
|
frappe.db.sql(
|
|
|
|
"""INSERT INTO `tabQuotation Lost Reason Detail` SELECT * FROM `tabLost Reason Detail` WHERE `parenttype` = 'Quotation'"""
|
|
|
|
)
|
|
|
|
|
2020-08-26 06:30:45 +00:00
|
|
|
frappe.db.sql(
|
|
|
|
"""INSERT INTO `tabQuotation Lost Reason` (`name`, `creation`, `modified`, `modified_by`, `owner`, `docstatus`, `parent`, `parentfield`, `parenttype`, `idx`, `_comments`, `_assign`, `_user_tags`, `_liked_by`, `order_lost_reason`)
|
|
|
|
SELECT o.`name`, o.`creation`, o.`modified`, o.`modified_by`, o.`owner`, o.`docstatus`, o.`parent`, o.`parentfield`, o.`parenttype`, o.`idx`, o.`_comments`, o.`_assign`, o.`_user_tags`, o.`_liked_by`, o.`lost_reason`
|
2020-08-13 03:50:36 +00:00
|
|
|
FROM `tabOpportunity Lost Reason` o LEFT JOIN `tabQuotation Lost Reason` q ON q.name = o.name WHERE q.name IS NULL"""
|
|
|
|
)
|
2020-08-26 06:30:45 +00:00
|
|
|
|
2020-08-13 03:50:36 +00:00
|
|
|
frappe.delete_doc("DocType", "Lost Reason Detail")
|