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))
Exemple #2
0
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))
Exemple #3
0
	def create_property_setter(self):
		if not self.doc.insert_after: return
		idx_label_list, field_list = get_fields_label(self.doc.dt, 0)
		label_index = idx_label_list.index(self.doc.insert_after)
		if label_index==-1: return

		prev_field = field_list[label_index]
		webnotes.conn.sql("""\
			DELETE FROM `tabProperty Setter`
			WHERE doc_type = %s
			AND field_name = %s
			AND property = 'previous_field'""", (self.doc.dt, self.doc.fieldname))
		
		webnotes.make_property_setter({
			"doctype":self.doc.dt, 
			"fieldname": self.doc.fieldname, 
			"property": "previous_field",
			"value": prev_field
		})
	def create_property_setter(self):
		if not self.doc.insert_after: return
		idx_label_list, field_list = get_fields_label(self.doc.dt, 0)
		label_index = idx_label_list.index(self.doc.insert_after)
		if label_index==-1: return

		prev_field = field_list[label_index]
		webnotes.conn.sql("""\
			DELETE FROM `tabProperty Setter`
			WHERE doc_type = %s
			AND field_name = %s
			AND property = 'previous_field'""", (self.doc.dt, self.doc.fieldname))
		
		webnotes.make_property_setter({
			"doctype":self.doc.dt, 
			"fieldname": self.doc.fieldname, 
			"property": "previous_field",
			"value": prev_field
		})