Merge branch 'master' into latest

Conflicts:
	index.html
	version.num
This commit is contained in:
Anand Doshi 2012-01-30 11:59:05 +05:30
commit e72de12993
8 changed files with 110 additions and 37 deletions

View File

@ -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]])

View File

@ -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']);
}
}

View File

@ -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))

View File

@ -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')

View File

@ -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"
},
]

View File

@ -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')
cancel_event('support.doctype.support_ticket.get_support_mails')

View File

@ -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': '<div class="help_box">Set your outgoing mail settings here. All system generated notifications, emails will go from this mail server</div>'
},
@ -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': '<div class="help_box">To automatically create Support Tickets from your incoming mail, set your pop3 settings here.</div>'
},
@ -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'
}
]

View File

@ -1 +1 @@
233
233