mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 10:49:09 +00:00
added code to update timestamps in Task, Customer Issue and Support Ticket
This commit is contained in:
32
patches/january_2013/update_closed_on.py
Normal file
32
patches/january_2013/update_closed_on.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import webnotes
|
||||
|
||||
def execute():
|
||||
webnotes.reload_doc("core", "doctype", "docfield")
|
||||
webnotes.reload_doc("support", "doctype", "support_ticket")
|
||||
|
||||
# customer issue resolved_by should be Profile
|
||||
if webnotes.conn.sql("""select count(*) from `tabCustomer Issue`
|
||||
where ifnull(resolved_by,"")!="" """)[0][0]:
|
||||
webnotes.make_property_setter({
|
||||
"doctype":"Customer Issue",
|
||||
"fieldname": "resolved_by",
|
||||
"property": "options",
|
||||
"value": "Sales Person"
|
||||
})
|
||||
|
||||
def get_communication_time(support_ticket, sort_order = 'asc'):
|
||||
tmp = webnotes.conn.sql("""select creation from tabCommunication where
|
||||
support_ticket=%s order by creation %s limit 1""" % ("%s", sort_order),
|
||||
support_ticket)
|
||||
return tmp and tmp[0][0] or None
|
||||
|
||||
# update in support ticket
|
||||
webnotes.conn.auto_commit_on_many_writes = True
|
||||
for st in webnotes.conn.sql("""select name, modified, status from
|
||||
`tabSupport Ticket`""", as_dict=1):
|
||||
|
||||
webnotes.conn.sql("""update `tabSupport Ticket` set first_responded_on=%s where
|
||||
name=%s""", (get_communication_time(st.name) or st.modified, st.name))
|
||||
if st.status=="Closed":
|
||||
webnotes.conn.sql("""update `tabSupport Ticket` set resolution_date=%s where
|
||||
name=%s""", (get_communication_time(st.name, 'desc') or st.modified, st.name))
|
||||
Reference in New Issue
Block a user