[patch] reload document before running patch && remove whitespaces
This commit is contained in:
parent
6f9db9eb70
commit
a52f8c2453
2 changed files with 32 additions and 31 deletions
|
|
@ -158,6 +158,6 @@ frappe.patches.v7_0.update_report_builder_json
|
|||
frappe.patches.v7_2.set_in_standard_filter_property #1
|
||||
execute:frappe.db.sql("update tabCommunication set communication_date = creation where time(communication_date) = 0")
|
||||
frappe.patches.v7_2.fix_email_queue_recipient
|
||||
frappe.patches.v7_2.update_feedback_request
|
||||
frappe.patches.v7_2.update_feedback_request # 2017-02-27
|
||||
execute:frappe.rename_doc('Country', 'Macedonia, Republic of', 'Macedonia', ignore_if_exists=True)
|
||||
execute:frappe.rename_doc('Country', 'Tanzania, United Republic of', 'Tanzania', ignore_if_exists=True)
|
||||
|
|
|
|||
|
|
@ -1,33 +1,34 @@
|
|||
import frappe
|
||||
|
||||
def execute():
|
||||
"""
|
||||
rename feedback request documents,
|
||||
update the feedback request and save the rating and communication
|
||||
reference in Feedback Request document
|
||||
"""
|
||||
|
||||
feedback_requests = frappe.get_all("Feedback Request")
|
||||
for request in feedback_requests:
|
||||
communication, rating = frappe.db.get_value("Communication", { "feedback_request": request.get("name") },
|
||||
["name", "rating"]) or [None, 0]
|
||||
|
||||
if communication:
|
||||
frappe.db.sql("""update `tabFeedback Request` set reference_communication='{communication}',
|
||||
rating={rating} where name='{feedback_request}'""".format(
|
||||
communication=communication,
|
||||
rating=rating or 0,
|
||||
feedback_request=request.get("name")
|
||||
))
|
||||
|
||||
if "Feedback" not in request.get("name"):
|
||||
# rename the feedback request doc
|
||||
reference_name, creation = frappe.db.get_value("Feedback Request", request.get("name"), ["name", "creation"])
|
||||
oldname = request.get("name")
|
||||
newname = "Feedback for {doctype} {docname} on {datetime}".format(
|
||||
doctype="Feedback Request",
|
||||
docname=reference_name,
|
||||
datetime=creation
|
||||
)
|
||||
frappe.rename_doc("Feedback Request", oldname, newname, ignore_permissions=True)
|
||||
if communication: frappe.db.set_value("Communication", communication, "feedback_request", newname)
|
||||
"""
|
||||
rename feedback request documents,
|
||||
update the feedback request and save the rating and communication
|
||||
reference in Feedback Request document
|
||||
"""
|
||||
|
||||
frappe.reload_doc("core", "doctype", "feedback_request")
|
||||
feedback_requests = frappe.get_all("Feedback Request")
|
||||
for request in feedback_requests:
|
||||
communication, rating = frappe.db.get_value("Communication", { "feedback_request": request.get("name") },
|
||||
["name", "rating"]) or [None, 0]
|
||||
|
||||
if communication:
|
||||
frappe.db.sql("""update `tabFeedback Request` set reference_communication='{communication}',
|
||||
rating={rating} where name='{feedback_request}'""".format(
|
||||
communication=communication,
|
||||
rating=rating or 0,
|
||||
feedback_request=request.get("name")
|
||||
))
|
||||
|
||||
if "Feedback" not in request.get("name"):
|
||||
# rename the feedback request doc
|
||||
reference_name, creation = frappe.db.get_value("Feedback Request", request.get("name"), ["name", "creation"])
|
||||
oldname = request.get("name")
|
||||
newname = "Feedback for {doctype} {docname} on {datetime}".format(
|
||||
doctype="Feedback Request",
|
||||
docname=reference_name,
|
||||
datetime=creation
|
||||
)
|
||||
frappe.rename_doc("Feedback Request", oldname, newname, ignore_permissions=True)
|
||||
if communication: frappe.db.set_value("Communication", communication, "feedback_request", newname)
|
||||
Loading…
Add table
Reference in a new issue