Example #1
0
	def process_message(self, mail):
		if mail.from_email == self.email_settings.fields.get('support_email'):
			return
		thread_id = mail.get_thread_id()
		ticket = None
		new_ticket = False

		if thread_id and webnotes.conn.exists("Support Ticket", thread_id):
			ticket = webnotes.bean("Support Ticket", thread_id)
			ticket.doc.status = 'Open'
			ticket.doc.save()
				
		else:
			ticket = webnotes.bean([decode_dict({
				"doctype":"Support Ticket",
				"description": mail.content,
				"subject": mail.subject,
				"raised_by": mail.from_email,
				"content_type": mail.content_type,
				"status": "Open",
			})])
						
			ticket.insert()
			new_ticket = True

		mail.save_attachments_in_doc(ticket.doc)
				
		make(content=mail.content, sender=mail.from_email, subject = ticket.doc.subject,
			doctype="Support Ticket", name=ticket.doc.name,
			date=mail.date)
			
		if new_ticket and cint(self.email_settings.send_autoreply) and \
			"mailer-daemon" not in mail.from_email.lower():
				self.send_auto_reply(ticket.doc)
Example #2
0
def add_support_communication(subject, content, sender, docname=None, mail=None):
	if docname:
		ticket = webnotes.bean("Support Ticket", docname)
		ticket.doc.status = 'Open'
		ticket.ignore_permissions = True
		ticket.doc.save()
	else:
		ticket = webnotes.bean([decode_dict({
			"doctype":"Support Ticket",
			"description": content,
			"subject": subject,
			"raised_by": sender,
			"content_type": mail.content_type if mail else None,
			"status": "Open",
		})])
		ticket.ignore_permissions = True
		ticket.insert()
	
	make(content=content, sender=sender, subject = subject,
		doctype="Support Ticket", name=ticket.doc.name,
		date=mail.date if mail else today(), sent_or_received="Received")

	if mail:
		mail.save_attachments_in_doc(ticket.doc)
		
	return ticket
def add_sent_email_communication(subject, content, sender, email_date,email_id,email_uid,docname=None, mail=None):

	print 'in sent  email communtn method'
	print subject
	print"------------------------------------------------------"
	print sender
	print"------------------------------------------------------"
	print content
	print"-----------sent email from profile------------------------------------------"
	print 'mail.content_type'
	print mail.content_type
	print email_id
	print email_date
	print email_uid

	# email_name = webnotes.conn.get("Profile", {"email": email})
	# print email_name
	if docname:
		print "in the if"
		email = webnotes.bean("Sent Mail", docname)
		# email.doc.status = 'Open'
		email.ignore_permissions = True
		email.doc.save()
	else:
		print "elase"
		try:
			email = webnotes.bean([decode_dict({
				"doctype":"Sent Mail",
				"description": content,
				"subject": subject,
				"raised_by": sender,
				"content_type": mail.content_type if mail else None,
				"owner":email_id,
				"email_date":email_date,
				"email_uid":email_uid,
				"Flag":"Unread"
				
		})])
		except Exception, e:
			print e
			raise
		# print "after"
		# print email
		# print email.name

		email.ignore_permissions = True
		email.insert()
		print 'email object'
		print email.doc.name	
def add_support_communication(subject, content, sender, docname=None, mail=None):

	qr="select customer,employee_id from `tabInstallation Note` where name="+subject+" "
        res=webnotes.conn.sql(qr)
        
        w="select status,user_id from `tabEmployee` where name='%s'"%(res[0][1]);
        t=webnotes.conn.sql(w)

	q=" select territory from `tabCustomer` where name='%s'"%(res[0][0]);

        r=webnotes.conn.sql(q)
       	w=" select parent from `tabDefaultValue` where  defkey = '%s' and defvalue = '%s'"%('territory',r[0][0])
        a=webnotes.conn.sql(w)
	if t[0][0] == 'Active':
		assigned_to=t[0][1]
		assigned_to_higher_level=a[0][0]
	else:
		assigned_to=a[0][0]
		assigned_to_higher_level=a[0][0]
		

	if docname:
		ticket = webnotes.bean("Support Ticket", docname)
		ticket.doc.status = 'Open'
		ticket.ignore_permissions = True
		ticket.doc.save()
	else:
		ticket = webnotes.bean([decode_dict({
			"doctype":"Support Ticket",
			"description": content,
			"subject": subject,
			"raised_by": sender,
			"content_type": mail.content_type if mail else None,
			"status": "Open"
			#"assigned_to":assigned_to,
			#"assigned_to_higher_level":assigned_to_higher_level
		})])
		ticket.ignore_permissions = True
		ticket.insert()
	
	make(content=content, sender=sender, subject = subject,
		doctype="Support Ticket", name=ticket.doc.name,
		date=mail.date if mail else today(), sent_or_received="Received")

	if mail:
		mail.save_attachments_in_doc(ticket.doc)
		
	return ticket
def add_email_communication(subject, content, sender, email_date,email_id,email_uid,docname=None, mail=None):

	print 'in email communtn method'
	print subject
	print"------------------------------------------------------"
	print sender
	print"------------------------------------------------------"
	print content
	print"------------email from profile------------------------------------------"
	# print 'mail.content_type'
	# print mail.content_type
	# email_name = webnotes.conn.get("Profile", {"email": email})
	# print email_name
	if docname:
		email = webnotes.bean("Email Inbox", docname)
		#email.doc.status = 'Open'
		email.ignore_permissions = True
		email.doc.save()
	else:

		email = webnotes.bean([decode_dict({
			"doctype":"Email Inbox",
			"description": content,
			"subject": subject,
			"raised_by": sender,
			"content_type": mail.content_type if mail else None,
			"status": "Open",
			"owner":email_id,
			"email_date":email_date,
			"email_uid":email_uid,
			"Flag":"Unread"
			
		})])
		email.ignore_permissions = True
		email.insert()
		print 'email object'
		print email.doc.name	
	
	make(content=content, sender=sender, subject = subject,
		doctype="Email Inbox", name=email.doc.name,
		date=mail.date if mail else today(), sent_or_received="Received")

	if mail:
		print "in the mail"
		mail.save_attachments_in_doc(email.doc)
		
	return email
Example #6
0
    def process_message(self, mail):
        if mail.from_email == self.email_settings.fields.get('support_email'):
            return
        thread_id = mail.get_thread_id()
        ticket = None
        new_ticket = False

        if thread_id and webnotes.conn.exists("Support Ticket", thread_id):
            ticket = webnotes.bean("Support Ticket", thread_id)
            ticket.doc.status = 'Open'
            ticket.doc.save()

        else:
            ticket = webnotes.bean([
                decode_dict({
                    "doctype": "Support Ticket",
                    "description": mail.content,
                    "subject": mail.subject,
                    "raised_by": mail.from_email,
                    "content_type": mail.content_type,
                    "status": "Open",
                })
            ])

            ticket.insert()
            new_ticket = True

        mail.save_attachments_in_doc(ticket.doc)

        make(content=mail.content,
             sender=mail.from_email,
             subject=ticket.doc.subject,
             doctype="Support Ticket",
             name=ticket.doc.name,
             date=mail.date)

        if new_ticket and cint(self.email_settings.send_autoreply) and \
         "mailer-daemon" not in mail.from_email.lower():
            self.send_auto_reply(ticket.doc)
Example #7
0
def add_support_communication(subject,
                              content,
                              sender,
                              docname=None,
                              mail=None):
    if docname:
        ticket = webnotes.bean("Support Ticket", docname)
        ticket.doc.status = 'Open'
        ticket.ignore_permissions = True
        ticket.doc.save()
    else:
        ticket = webnotes.bean([
            decode_dict({
                "doctype": "Support Ticket",
                "description": content,
                "subject": subject,
                "raised_by": sender,
                "content_type": mail.content_type if mail else None,
                "status": "Open",
            })
        ])
        ticket.ignore_permissions = True
        ticket.insert()

    make(content=content,
         sender=sender,
         subject=subject,
         doctype="Support Ticket",
         name=ticket.doc.name,
         date=mail.date if mail else today(),
         sent_or_received="Received")

    if mail:
        mail.save_attachments_in_doc(ticket.doc)

    return ticket