Exemple #1
0
def on_method(bean, method):
	if method in ("on_update", "on_submit"):
		update_feed(bean.controller, method)
	
	if method in ("on_update", "on_cancel", "on_trash"):
		clear_doctype_notifications(bean.controller, method)

	if bean.doc.doctype=="Stock Entry" and method in ("on_submit", "on_cancel"):
		update_completed_qty(bean.controller, method)
Exemple #2
0
def on_method(bean, method):
    if method in ("on_update", "on_submit"):
        update_feed(bean.controller, method)

    if method in ("on_update", "on_cancel", "on_trash"):
        clear_doctype_notifications(bean.controller, method)

    if bean.doc.doctype == "Stock Entry" and method in ("on_submit",
                                                        "on_cancel"):
        update_completed_qty(bean.controller, method)
Exemple #3
0
	def process_message(self, mail):
		"""
			Updates message from support email as either new or reply
		"""
		from home import update_feed

		content, content_type = '[Blank Email]', 'text/plain'
		if mail.text_content:
			content, content_type = mail.text_content, 'text/plain'
		else:
			content, content_type = mail.html_content, 'text/html'
			
		thread_id = mail.get_thread_id()

		if webnotes.conn.exists('Support Ticket', thread_id):
			from webnotes.model.code import get_obj
			
			st = get_obj('Support Ticket', thread_id)
			st.make_response_record(content, mail.mail['From'], content_type)
			webnotes.conn.set(st.doc, 'status', 'Open')
			update_feed(st.doc)
			return
				
		# new ticket
		from webnotes.model.doc import Document
		d = Document('Support Ticket')
		d.description = content
		d.subject = mail.mail['Subject']
		d.raised_by = mail.mail['From']
		d.content_type = content_type
		d.status = 'Open'
		try:
			d.save(1)
			# update feed
			update_feed(d)

			# send auto reply
			self.send_auto_reply(d)

		except:
			d.description = 'Unable to extract message'
			d.save(1)
Exemple #4
0
	def process_message(self, mail):
		"""
			Updates message from support email as either new or reply
		"""
		from home import update_feed

		content, content_type = '[Blank Email]', 'text/plain'
		if mail.text_content:
			content, content_type = mail.text_content, 'text/plain'
		else:
			content, content_type = mail.html_content, 'text/html'
			
		thread_list = mail.get_thread_id()


		email_id = mail.mail['From']
		if "<" in mail.mail['From']:
			import re
			re_result = re.findall('(?<=\<)(\S+)(?=\>)', mail.mail['From'])
			if re_result and re_result[0]: email_id = re_result[0]
		
		from webnotes.utils import decode_email_header
		
		full_email_id = decode_email_header(mail.mail['From'])

		for thread_id in thread_list:
			exists = webnotes.conn.sql("""\
				SELECT name
				FROM `tabSupport Ticket`
				WHERE name=%s AND raised_by REGEXP %s
				""" , (thread_id, '(' + email_id + ')'))
			if exists and exists[0] and exists[0][0]:
				from webnotes.model.code import get_obj
				
				st = get_obj('Support Ticket', thread_id)
				st.make_response_record(content, full_email_id, content_type)
				
				# to update modified date
				#webnotes.conn.set(st.doc, 'status', 'Open')
				st.doc.status = 'Open'
				st.doc.save()
				
				update_feed(st.doc, 'on_update')
				webnotes.conn.commit()
				# extract attachments
				self.save_attachments(st.doc, mail.attachments)
				webnotes.conn.begin()
				return
				
		from webnotes.model.doctype import get_property
		opts = get_property('Support Ticket', 'options', 'naming_series')
		# new ticket
		from webnotes.model.doc import Document
		d = Document('Support Ticket')
		d.description = content
		
		d.subject = decode_email_header(mail.mail['Subject'])
		
		d.raised_by = full_email_id
		d.content_type = content_type
		d.status = 'Open'
		d.naming_series = opts and opts.split("\n")[0] or 'SUP'
		try:
			d.save(1)
		except:
			d.description = 'Unable to extract message'
			d.save(1)

		else:
			# update feed
			update_feed(d, 'on_update')

			# send auto reply
			if cint(self.email_settings.send_autoreply):
				self.send_auto_reply(d)

			webnotes.conn.commit()
			# extract attachments
			self.save_attachments(d, mail.attachments)
			webnotes.conn.begin()
Exemple #5
0
 def reopen_ticket(self):
     webnotes.conn.set(self.doc, 'status', 'Open')
     update_feed(self.doc)
Exemple #6
0
 def close_ticket(self):
     webnotes.conn.set(self.doc, 'status', 'Closed')
     update_feed(self.doc)
Exemple #7
0
    def process_message(self, mail):
        """
			Updates message from support email as either new or reply
		"""
        from home import update_feed

        content, content_type = '[Blank Email]', 'text/plain'
        if mail.text_content:
            content, content_type = mail.text_content, 'text/plain'
        else:
            content, content_type = mail.html_content, 'text/html'

        thread_list = mail.get_thread_id()

        email_id = mail.mail['From']
        if "<" in mail.mail['From']:
            import re
            re_result = re.findall('(?<=\<)(\S+)(?=\>)', mail.mail['From'])
            if re_result and re_result[0]: email_id = re_result[0]

        for thread_id in thread_list:
            exists = webnotes.conn.sql(
                """\
				SELECT name
				FROM `tabSupport Ticket`
				WHERE name=%s AND raised_by REGEXP %s
				""", (thread_id, '(' + email_id + ')'))
            if exists and exists[0] and exists[0][0]:
                from webnotes.model.code import get_obj

                st = get_obj('Support Ticket', thread_id)
                st.make_response_record(content, mail.mail['From'],
                                        content_type)
                webnotes.conn.set(st.doc, 'status', 'Open')
                update_feed(st.doc, 'on_update')
                webnotes.conn.commit()
                # extract attachments
                self.save_attachments(st.doc, mail.attachments)
                return

        opts = webnotes.conn.sql("""\
			SELECT options FROM tabDocField
			WHERE parent='Support Ticket' AND fieldname='naming_series'""")
        # new ticket
        from webnotes.model.doc import Document
        d = Document('Support Ticket')
        d.description = content
        d.subject = mail.mail['Subject']
        d.raised_by = mail.mail['From']
        d.content_type = content_type
        d.status = 'Open'
        d.naming_series = (opts and opts[0] and opts[0][0]
                           and opts[0][0].split("\n")[0]) or 'SUP'
        try:
            d.save(1)
        except:
            d.description = 'Unable to extract message'
            d.save(1)

        else:
            # update feed
            update_feed(d, 'on_update')

            # send auto reply
            self.send_auto_reply(d)

            webnotes.conn.commit()

            # extract attachments
            self.save_attachments(d, mail.attachments)
Exemple #8
0
def doclist_all(doc, method):
    """doclist trigger called from webnotes.model.doclist on any event"""
    home.update_feed(doc, method)
Exemple #9
0
	def reopen_ticket(self):
		webnotes.conn.set(self.doc,'status','Open')		
		update_feed(self.doc)		
Exemple #10
0
	def close_ticket(self):
		webnotes.conn.set(self.doc,'status','Closed')
		update_feed(self.doc)
Exemple #11
0
	def process_message(self, mail):
		"""
			Updates message from support email as either new or reply
		"""
		from home import update_feed

		content, content_type = '[Blank Email]', 'text/plain'
		if mail.text_content:
			content, content_type = mail.text_content, 'text/plain'
		else:
			content, content_type = mail.html_content, 'text/html'
			
		thread_list = mail.get_thread_id()


		email_id = mail.mail['From']
		if "<" in mail.mail['From']:
			import re
			re_result = re.findall('(?<=\<)(\S+)(?=\>)', mail.mail['From'])
			if re_result and re_result[0]: email_id = re_result[0]


		for thread_id in thread_list:
			exists = webnotes.conn.sql("""\
				SELECT name
				FROM `tabSupport Ticket`
				WHERE name=%s AND raised_by REGEXP %s
				""" , (thread_id, '(' + email_id + ')'))
			if exists and exists[0] and exists[0][0]:
				from webnotes.model.code import get_obj
				
				st = get_obj('Support Ticket', thread_id)
				st.make_response_record(content, mail.mail['From'], content_type)
				webnotes.conn.set(st.doc, 'status', 'Open')
				update_feed(st.doc)
				# extract attachments
				self.save_attachments(st.doc, mail.attachments)
				return
				
		opts = webnotes.conn.sql("""\
			SELECT options FROM tabDocField
			WHERE parent='Support Ticket' AND fieldname='naming_series'""")
		# new ticket
		from webnotes.model.doc import Document
		d = Document('Support Ticket')
		d.description = content
		d.subject = mail.mail['Subject']
		d.raised_by = mail.mail['From']
		d.content_type = content_type
		d.status = 'Open'
		d.naming_series = (opts and opts[0] and opts[0][0] and opts[0][0].split("\n")[0]) or 'SUP'
		try:
			d.save(1)

			# update feed
			update_feed(d)

			# send auto reply
			self.send_auto_reply(d)

		except:
			d.description = 'Unable to extract message'
			d.save(1)

		else:
			# extract attachments
			self.save_attachments(d, mail.attachments)
Exemple #12
0
def doclist_all(doc, method):
	"""doclist trigger called from webnotes.model.doclist on any event"""
	home.update_feed(doc, method)
Exemple #13
0
    def process_message(self, mail):
        """
			Updates message from support email as either new or reply
		"""
        from home import update_feed

        content, content_type = "[Blank Email]", "text/plain"
        if mail.text_content:
            content, content_type = mail.text_content, "text/plain"
        else:
            content, content_type = mail.html_content, "text/html"

        thread_list = mail.get_thread_id()

        email_id = mail.mail["From"]
        if "<" in mail.mail["From"]:
            import re

            re_result = re.findall("(?<=\<)(\S+)(?=\>)", mail.mail["From"])
            if re_result and re_result[0]:
                email_id = re_result[0]

        for thread_id in thread_list:
            exists = webnotes.conn.sql(
                """\
				SELECT name
				FROM `tabSupport Ticket`
				WHERE name=%s AND raised_by REGEXP %s
				""",
                (thread_id, "(" + email_id + ")"),
            )
            if exists and exists[0] and exists[0][0]:
                from webnotes.model.code import get_obj

                st = get_obj("Support Ticket", thread_id)
                st.make_response_record(content, mail.mail["From"], content_type)

                # to update modified date
                # webnotes.conn.set(st.doc, 'status', 'Open')
                st.doc.status = "Open"
                st.doc.save()

                update_feed(st.doc, "on_update")
                webnotes.conn.commit()
                # extract attachments
                self.save_attachments(st.doc, mail.attachments)
                return

        from webnotes.model.doctype import get_property

        opts = get_property("Support Ticket", "options", "naming_series")
        # new ticket
        from webnotes.model.doc import Document

        d = Document("Support Ticket")
        d.description = content
        d.subject = mail.mail["Subject"]
        d.raised_by = mail.mail["From"]
        d.content_type = content_type
        d.status = "Open"
        d.naming_series = opts and opts.split("\n")[0] or "SUP"
        try:
            d.save(1)
        except:
            d.description = "Unable to extract message"
            d.save(1)

        else:
            # update feed
            update_feed(d, "on_update")

            # send auto reply
            if cint(self.email_settings.send_autoreply):
                self.send_auto_reply(d)

            webnotes.conn.commit()

            # extract attachments
            self.save_attachments(d, mail.attachments)
Exemple #14
0
    def process_message(self, mail):
        """
			Updates message from support email as either new or reply
		"""
        from home import update_feed

        content, content_type = "[Blank Email]", "text/plain"
        if mail.text_content:
            content, content_type = mail.text_content, "text/plain"
        else:
            content, content_type = mail.html_content, "text/html"

        thread_list = mail.get_thread_id()

        email_id = mail.mail["From"]
        if "<" in mail.mail["From"]:
            import re

            re_result = re.findall("(?<=\<)(\S+)(?=\>)", mail.mail["From"])
            if re_result and re_result[0]:
                email_id = re_result[0]

        from webnotes.utils import decode_email_header

        full_email_id = decode_email_header(mail.mail["From"])

        for thread_id in thread_list:
            exists = webnotes.conn.sql(
                """\
				SELECT name
				FROM `tabSupport Ticket`
				WHERE name=%s AND raised_by REGEXP %s
				""",
                (thread_id, "(" + email_id + ")"),
            )
            if exists and exists[0] and exists[0][0]:
                st = webnotes.get_obj("Support Ticket", thread_id)

                from core.doctype.communication.communication import make

                make(
                    content=content,
                    sender=full_email_id,
                    doctype="Support Ticket",
                    name=thread_id,
                    lead=st.doc.lead,
                    contact=st.doc.contact,
                )

                st.doc.status = "Open"
                st.doc.save()

                update_feed(st, "on_update")
                # extract attachments
                self.save_attachments(st.doc, mail.attachments)
                return

        from webnotes.model.doctype import get_property

        opts = get_property("Support Ticket", "options", "naming_series")
        # new ticket
        from webnotes.model.doc import Document

        d = Document("Support Ticket")
        d.description = content

        d.subject = decode_email_header(mail.mail["Subject"])

        d.raised_by = full_email_id
        d.content_type = content_type
        d.status = "Open"
        d.naming_series = opts and opts.split("\n")[0] or "SUP"
        try:
            d.save(1)
            try:
                # extract attachments
                self.save_attachments(d, mail.attachments)
            except Exception, e:
                self.description += "\n\n[Did not pull attachment]"
        except:
            d.description = "Unable to extract message"
            d.save(1)
        else:
            # send auto reply
            if cint(self.email_settings.send_autoreply):
                if "mailer-daemon" not in d.raised_by.lower():
                    self.send_auto_reply(d)
Exemple #15
0
	def process_message(self, mail):
		"""
			Updates message from support email as either new or reply
		"""
		from home import update_feed

		content, content_type = '[Blank Email]', 'text/plain'
		if mail.text_content:
			content, content_type = mail.text_content, 'text/plain'
		else:
			content, content_type = mail.html_content, 'text/html'
			
		thread_list = mail.get_thread_id()

		email_id = mail.mail['From']
		if "<" in mail.mail['From']:
			import re
			re_result = re.findall('(?<=\<)(\S+)(?=\>)', mail.mail['From'])
			if re_result and re_result[0]: 
				email_id = re_result[0]
		
		from webnotes.utils import decode_email_header
		
		full_email_id = decode_email_header(mail.mail['From'])

		for thread_id in thread_list:
			exists = webnotes.conn.sql("""\
				SELECT name
				FROM `tabSupport Ticket`
				WHERE name=%s AND raised_by REGEXP %s
				""" , (thread_id, '(' + email_id + ')'))
			if exists and exists[0] and exists[0][0]:
				st = webnotes.get_obj('Support Ticket', thread_id)
				
				from support.doctype.communication.communication import make
				
				make(content=content, sender=full_email_id, doctype="Support Ticket",
					name=thread_id, lead = st.doc.lead, contact=st.doc.contact)
				
				st.doc.status = 'Open'
				st.doc.save()
				
				update_feed(st.doc, 'on_update')
				# extract attachments
				self.save_attachments(st.doc, mail.attachments)
				return
				
		from webnotes.model.doctype import get_property
		opts = get_property('Support Ticket', 'options', 'naming_series')
		# new ticket
		from webnotes.model.doc import Document
		d = Document('Support Ticket')
		d.description = content
		
		d.subject = decode_email_header(mail.mail['Subject'])
		
		d.raised_by = full_email_id
		d.content_type = content_type
		d.status = 'Open'
		d.naming_series = opts and opts.split("\n")[0] or 'SUP'
		try:
			d.save(1)
		except:
			d.description = 'Unable to extract message'
			d.save(1)

		else:
			# update feed
			update_feed(d, 'on_update')

			# send auto reply
			if cint(self.email_settings.send_autoreply):
				if "mailer-daemon" not in d.raised_by.lower():
					self.send_auto_reply(d)

			# extract attachments
			self.save_attachments(d, mail.attachments)