diff --git a/erpnext/accounts/doctype/gl_control/gl_control.py b/erpnext/accounts/doctype/gl_control/gl_control.py index 387fc6380fc..001df8406f6 100644 --- a/erpnext/accounts/doctype/gl_control/gl_control.py +++ b/erpnext/accounts/doctype/gl_control/gl_control.py @@ -505,9 +505,9 @@ def manage_recurring_invoices(): and notify the concerned people """ rv = webnotes.conn.sql("""select name, recurring_id from `tabReceivable Voucher` where ifnull(convert_into_recurring_invoice, 0) = 1 - and next_date = %s and next_date <= end_date order by next_date desc""", nowdate()) + and next_date = %s and next_date <= end_date and docstatus=1 order by next_date desc""", nowdate()) for d in rv: - if not webnotes.conn.sql("""select name from `tabReceivable Voucher` where posting_date = %s and recurring_id = %s""", (nowdate(), d[1])): + if not webnotes.conn.sql("""select name from `tabReceivable Voucher` where posting_date = %s and recurring_id = %s and docstatus=1""", (nowdate(), d[1])): prev_rv = get_obj('Receivable Voucher', d[0], with_children=1) new_rv = create_new_invoice(prev_rv) @@ -524,6 +524,7 @@ def create_new_invoice(prev_rv): new_rv.doc.posting_date = new_rv.doc.next_date new_rv.doc.aging_date = new_rv.doc.next_date new_rv.doc.due_date = add_days(new_rv.doc.next_date, cint(date_diff(prev_rv.doc.due_date, prev_rv.doc.posting_date))) + new_rv.doc.owner = prev_rv.doc.owner new_rv.doc.save() # submit and after submit @@ -588,5 +589,5 @@ def send_notification(new_rv): msg = hd + tbl + totals from webnotes.utils.email_lib import sendmail - sendmail(recipients = [new_rv.doc.email_notification_address], \ + sendmail(recipients = new_rv.doc.notification_email_address.split(", "), \ sender=new_rv.doc.owner, subject=subject, parts=[['text/plain', msg]]) diff --git a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js index bac1a1b0bd5..56de4c97239 100644 --- a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js +++ b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js @@ -439,7 +439,7 @@ cur_frm.cscript['View Ledger Entry'] = function(){ cur_frm.cscript.convert_into_recurring_invoice = function(doc) { if (doc.convert_into_recurring_invoice) { doc.repeat_on_day_of_month = doc.posting_date.split('-')[2]; - doc.notification_email_address = doc.owner + ', ' + doc.contact_email; + doc.notification_email_address = [doc.owner, doc.contact_email].join(', '); refresh_field(['repeat_on_day_of_month', 'notification_email_address']); } } diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py index 55bf8b85352..d43900b177f 100644 --- a/erpnext/buying/doctype/supplier/supplier.py +++ b/erpnext/buying/doctype/supplier/supplier.py @@ -158,8 +158,7 @@ class DocType: ('Payable Voucher', 'supplier'), ('Purchase Order', 'supplier'), ('Purchase Receipt', 'supplier'), - ('Serial No', 'supplier'), - ('Supplier Quotation', 'supplier')] + ('Serial No', 'supplier')] for rec in update_fields: sql("update `tab%s` set supplier_name = '%s' where %s = '%s'" %(rec[0],newdn,rec[1],olddn)) diff --git a/erpnext/patches/jan_mar_2012/email_settings_reload.py b/erpnext/patches/jan_mar_2012/email_settings_reload.py new file mode 100644 index 00000000000..bfe3efeae95 --- /dev/null +++ b/erpnext/patches/jan_mar_2012/email_settings_reload.py @@ -0,0 +1,13 @@ +def execute(): + """ + * Change type of mail_port field to int + * reload email settings + """ + import webnotes + webnotes.conn.sql(""" + UPDATE `tabDocField` SET fieldtype='Int' + WHERE parent = 'Email Settings' AND fieldname = 'mail_port' + """) + + from webnotes.modules.module_manager import reload_doc + reload_doc('setup', 'doctype', 'email_settings') diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index 2193207837e..d56ba2f8472 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -45,4 +45,9 @@ patch_list = [ 'patch_file': 'doclabel_in_doclayer', 'description': "Show DocType Labels instead of DocType names in Customize Form View" }, + { + 'patch_module': 'patches.jan_mar_2012', + 'patch_file': 'email_settings_reload', + 'description': "Change type of mail_port field to Int and reload email_settings doctype" + }, ] diff --git a/erpnext/setup/doctype/email_settings/email_settings.py b/erpnext/setup/doctype/email_settings/email_settings.py index ef0a7631d89..c5e6a8e6a13 100644 --- a/erpnext/setup/doctype/email_settings/email_settings.py +++ b/erpnext/setup/doctype/email_settings/email_settings.py @@ -21,6 +21,82 @@ class DocType: """ if self.doc.fields.get(key): webnotes.conn.set_value('Control Panel', None, key, self.doc.fields[key]) + + def validate(self): + """ + Checks connectivity to email servers before saving + """ + self.validate_outgoing() + self.validate_incoming() + + + def validate_outgoing(self): + """ + Checks incoming email settings + """ + if self.doc.outgoing_mail_server: + from webnotes.utils import cint + import _socket + from webnotes.utils.email_lib.send import EMail + out_email = EMail() + out_email.server = self.doc.outgoing_mail_server.encode('utf-8') + out_email.port = cint(self.doc.mail_port) + out_email.use_ssl = self.doc.use_ssl + try: + out_email.login = self.doc.mail_login.encode('utf-8') + out_email.password = self.doc.mail_password.encode('utf-8') + except AttributeError, e: + webnotes.msgprint('Login Id or Mail Password missing. Please enter and try again.') + webnotes.msgprint(e) + + try: + sess = out_email.smtp_connect() + try: + sess.quit() + except: + pass + except _socket.error, e: + # Invalid mail server -- due to refusing connection + webnotes.msgprint('Invalid Outgoing Mail Server. Please rectify and try again.') + webnotes.msgprint(e) + except smtplib.SMTPAuthenticationError, e: + webnotes.msgprint('Invalid Login Id or Mail Password. Please rectify and try again.') + except smtplib.SMTPException, e: + webnotes.msgprint('There is something wrong with your Outgoing Mail Settings. \ + Please contact us at support@erpnext.com') + webnotes.msgprint(e) + + + def validate_incoming(self): + """ + Checks support ticket email settings + """ + if self.doc.sync_support_mails and self.doc.support_host: + from webnotes.utils.email_lib.receive import POP3Mailbox + from webnotes.model.doc import Document + import _socket, poplib + inc_email = Document('Incoming Email Settings') + inc_email.host = self.doc.support_host.encode('utf-8') + inc_email.use_ssl = self.doc.support_use_ssl + try: + inc_email.username = self.doc.support_username.encode('utf-8') + inc_email.password = self.doc.support_password.encode('utf-8') + except AttributeError, e: + webnotes.msgprint('User Name or Support Password missing. Please enter and try again.') + webnotes.msgprint(e) + + pop_mb = POP3Mailbox(inc_email) + + try: + pop_mb.connect() + except _socket.error, e: + # Invalid mail server -- due to refusing connection + webnotes.msgprint('Invalid POP3 Mail Server. Please rectify and try again.') + webnotes.msgprint(e) + except poplib.error_proto, e: + webnotes.msgprint('Invalid User Name or Support Password. Please rectify and try again.') + webnotes.msgprint(e) + def on_update(self): """ @@ -39,4 +115,4 @@ class DocType: set_event('support.doctype.support_ticket.get_support_mails', 60*5, 1) else: from webnotes.utils.scheduler import cancel_event - cancel_event('support.doctype.support_ticket.get_support_mails') \ No newline at end of file + cancel_event('support.doctype.support_ticket.get_support_mails') diff --git a/erpnext/setup/doctype/email_settings/email_settings.txt b/erpnext/setup/doctype/email_settings/email_settings.txt index ef6efe609f7..b6e52fc69a0 100644 --- a/erpnext/setup/doctype/email_settings/email_settings.txt +++ b/erpnext/setup/doctype/email_settings/email_settings.txt @@ -5,18 +5,19 @@ { 'creation': '2010-08-08 17:08:59', 'docstatus': 0, - 'modified': '2011-07-25 15:03:51', + 'modified': '2012-01-25 18:44:45', 'modified_by': 'Administrator', 'owner': 'harshada@webnotestech.com' }, # These values are common for all DocType { - '_last_update': '1311586371', + '_last_update': '1325570647', 'allow_copy': 1, 'allow_email': 1, 'allow_print': 1, 'colour': 'White:FFF', + 'default_print_format': 'Standard', 'doctype': 'DocType', 'in_create': 1, 'issingle': 1, @@ -24,7 +25,7 @@ 'name': '__common__', 'section_style': 'Simple', 'server_code_error': ' ', - 'version': 34 + 'version': 35 }, # These values are common for all DocField @@ -59,21 +60,18 @@ # DocPerm { - 'doctype': 'DocPerm', - 'idx': 1 + 'doctype': 'DocPerm' }, # DocPerm { - 'doctype': 'DocPerm', - 'idx': 2 + 'doctype': 'DocPerm' }, # DocField { 'doctype': 'DocField', 'fieldtype': 'Section Break', - 'idx': 1, 'label': 'Outgoing Mails' }, @@ -81,7 +79,6 @@ { 'doctype': 'DocField', 'fieldtype': 'HTML', - 'idx': 2, 'label': '1', 'options': '
Set your outgoing mail settings here. All system generated notifications, emails will go from this mail server
' }, @@ -91,7 +88,6 @@ 'doctype': 'DocField', 'fieldname': 'outgoing_mail_server', 'fieldtype': 'Data', - 'idx': 3, 'label': 'Outgoing Mail Server' }, @@ -99,8 +95,7 @@ { 'doctype': 'DocField', 'fieldname': 'mail_port', - 'fieldtype': 'Data', - 'idx': 4, + 'fieldtype': 'Int', 'label': 'Mail Port' }, @@ -109,7 +104,6 @@ 'doctype': 'DocField', 'fieldname': 'use_ssl', 'fieldtype': 'Check', - 'idx': 5, 'label': 'Use SSL' }, @@ -118,7 +112,6 @@ 'doctype': 'DocField', 'fieldname': 'mail_login', 'fieldtype': 'Data', - 'idx': 6, 'label': 'Login Id' }, @@ -127,7 +120,6 @@ 'doctype': 'DocField', 'fieldname': 'mail_password', 'fieldtype': 'Password', - 'idx': 7, 'label': 'Mail Password' }, @@ -136,7 +128,6 @@ 'doctype': 'DocField', 'fieldname': 'auto_email_id', 'fieldtype': 'Data', - 'idx': 8, 'label': 'Auto Email Id' }, @@ -145,7 +136,6 @@ 'description': 'Set the POP3 email settings to pull emails directly from a mailbox and create Support Tickets', 'doctype': 'DocField', 'fieldtype': 'Section Break', - 'idx': 9, 'label': 'Support Ticket Mail Settings' }, @@ -153,7 +143,6 @@ { 'doctype': 'DocField', 'fieldtype': 'HTML', - 'idx': 10, 'label': '2', 'options': '
To automatically create Support Tickets from your incoming mail, set your pop3 settings here.
' }, @@ -162,7 +151,6 @@ { 'doctype': 'DocField', 'fieldtype': 'Section Break', - 'idx': 11, 'options': 'Simple' }, @@ -173,7 +161,6 @@ 'doctype': 'DocField', 'fieldname': 'sync_support_mails', 'fieldtype': 'Check', - 'idx': 12, 'label': 'Sync Support Mails' }, @@ -184,7 +171,6 @@ 'doctype': 'DocField', 'fieldname': 'support_email', 'fieldtype': 'Data', - 'idx': 13, 'label': 'Support Email' }, @@ -195,7 +181,6 @@ 'doctype': 'DocField', 'fieldname': 'support_host', 'fieldtype': 'Data', - 'idx': 14, 'label': 'POP3 Mail Server' }, @@ -204,7 +189,6 @@ 'doctype': 'DocField', 'fieldname': 'support_use_ssl', 'fieldtype': 'Check', - 'idx': 15, 'label': 'Use SSL' }, @@ -213,7 +197,6 @@ 'doctype': 'DocField', 'fieldname': 'support_username', 'fieldtype': 'Data', - 'idx': 16, 'label': 'User Name' }, @@ -222,15 +205,13 @@ 'doctype': 'DocField', 'fieldname': 'support_password', 'fieldtype': 'Password', - 'idx': 17, 'label': 'Support Password' }, # DocField { 'doctype': 'DocField', - 'fieldtype': 'Column Break', - 'idx': 18 + 'fieldtype': 'Column Break' }, # DocField @@ -240,7 +221,6 @@ 'doctype': 'DocField', 'fieldname': 'support_signature', 'fieldtype': 'Text', - 'idx': 19, 'label': 'Signature' }, @@ -251,7 +231,6 @@ 'doctype': 'DocField', 'fieldname': 'support_autoreply', 'fieldtype': 'Text', - 'idx': 20, 'label': 'Autoreply' } ] \ No newline at end of file diff --git a/version.num b/version.num index f937f7e2b36..0c56bea5944 100644 --- a/version.num +++ b/version.num @@ -1 +1 @@ -233 \ No newline at end of file +233