diff --git a/js/legacy/widgets/form/email.js b/js/legacy/widgets/form/email.js index 7947c30c0e..fa79682d74 100644 --- a/js/legacy/widgets/form/email.js +++ b/js/legacy/widgets/form/email.js @@ -39,7 +39,9 @@ sendmail = function(emailto, emailfrom, cc, subject, message, fmt, with_attachme 'full_domain': wn.urllib.get_base_url(), 'with_attachments':with_attachments ? 1 : 0, 'dt':cur_frm.doctype, - 'dn':cur_frm.docname + 'dn':cur_frm.docname, + 'customer': cur_frm.doc.customer || '', + 'supplier': cur_frm.doc.supplier || '' }, function(r, rtxt) { // diff --git a/py/webnotes/utils/email_lib/__init__.py b/py/webnotes/utils/email_lib/__init__.py index 75da76223c..37411b7513 100644 --- a/py/webnotes/utils/email_lib/__init__.py +++ b/py/webnotes/utils/email_lib/__init__.py @@ -110,7 +110,8 @@ def get_contact_list(): Returns contacts (from autosuggest) """ - cond = ['`%s` like "%s%%"' % (f, webnotes.form.getvalue('txt')) for f in webnotes.form.getvalue('where').split(',')] + cond = ['`%s` like "%s%%"' % (f, + webnotes.form.getvalue('txt')) for f in webnotes.form.getvalue('where').split(',')] cl = webnotes.conn.sql("select `%s` from `tab%s` where %s" % ( webnotes.form.getvalue('select') ,webnotes.form.getvalue('from') diff --git a/py/webnotes/utils/email_lib/form_email.py b/py/webnotes/utils/email_lib/form_email.py index 8885c79695..dc9bfabb6e 100644 --- a/py/webnotes/utils/email_lib/form_email.py +++ b/py/webnotes/utils/email_lib/form_email.py @@ -141,10 +141,6 @@ class FormEmail: # form itself (only in the html message) html_message += self.body - # form link - html_message += self.get_form_link() - text_message += self.get_form_link() - # footer footer = get_footer() if footer: @@ -155,7 +151,34 @@ class FormEmail: # message as text self.email.set_text(html2text(unicode(text_message, 'utf-8'))) self.email.set_html(html_message) - + + def make_communication(self): + """make email communication""" + from webnotes.model.doc import Document + comm = Document('Communication') + comm.communication_medium = 'Email' + comm.subject = self.subject + comm.content = self.message + comm.category = 'Sent Mail' + comm.action = 'Sent Mail' + comm.naming_series = 'COMM-' + try: + comm_cols = [c[0] for c in webnotes.conn.sql("""desc tabCommunication""")] + + # tag to record + if self.dt in comm_cols: + comm.fields[self.dt] = self.dn + + # tag to customer, supplier (?) + if self.customer: + comm.customer = self.customer + if self.supplier: + comm.supplier = self.supplier + + comm.save(1) + except Exception, e: + if e.args[0]!=1146: raise e + def send(self): """ Send the form with html attachment @@ -182,4 +205,6 @@ class FormEmail: self.email.cc = [self.cc] self.email.send(send_now=1) + self.make_communication() + webnotes.msgprint('Sent') diff --git a/wnf.py b/wnf.py index f0e618c35f..5bfede1d6c 100755 --- a/wnf.py +++ b/wnf.py @@ -95,6 +95,7 @@ def pull(remote, branch): os.chdir('..') def apply_latest_patches(): + import webnotes.modules.patch_handler webnotes.modules.patch_handler.run_all() print '\n'.join(webnotes.modules.patch_handler.log_list)