[IMP] ir_mail_server.py: implemented onchange for tls and ssl boolean field

bzr revid: rha@tinyerp.com-20110325115702-6066ifi582eztgfq
This commit is contained in:
Rifakat Haradwala (Open ERP)
2011-03-25 17:27:02 +05:30
parent 2bf882fbf7
commit 6a76b19d2e
3 changed files with 17 additions and 12 deletions
+2 -2
View File
@@ -1959,8 +1959,8 @@
<group colspan="4" col="8">
<field name="smtp_host"/>
<field name="smtp_port"/>
<field name="smtp_ssl"/>
<field name="smtp_tls"/>
<field name="smtp_ssl" on_change="on_change_ssl(smtp_ssl)"/>
<field name="smtp_tls" on_change="on_change_tls(smtp_tls)"/>
<field name="priority"/>
</group>
+14 -8
View File
@@ -102,16 +102,11 @@ unless it is already specified in the From Email, e.g: John Doe <john@doe.com>",
required=False),
'smtp_tls':fields.boolean('TLS'),
'smtp_ssl':fields.boolean('SSL/TLS'),
'priority': fields.integer('Priority', help=""),
'priority': fields.integer('Priority', help="If no specific server is requested for a mail then the highest priority one is used"),
}
_defaults = {
'name':lambda self, cursor, user, context:self.pool.get( 'res.users'
).read(cursor, user, user, ['name'], context)['name'],
'smtp_port': tools.config.get('smtp_port',25),
'smtp_host': tools.config.get('smtp_server','localhost'),
'smtp_ssl': tools.config.get('smtp_ssl',False),
'smtp_tls': True,
'smtp_port': 25,
'priority': 10,
}
@@ -244,7 +239,6 @@ unless it is already specified in the From Email, e.g: John Doe <john@doe.com>",
if id:
smtp_server = self.browse(cr, uid, id)
if not (id and smtp_server):
server = self.search(cr, uid, [], order='priority', limit=1)
smtp_server = self.browse(cr, uid, server[0])
@@ -280,6 +274,18 @@ unless it is already specified in the From Email, e.g: John Doe <john@doe.com>",
return message_id
return False
def on_change_ssl(self, cr, uid, ids, smtp_ssl):
smtp_port = 0
if smtp_ssl:
smtp_port = 465
return {'value':{'smtp_ssl':smtp_ssl,'smtp_tls':False,'smtp_port':smtp_port}}
def on_change_tls(self, cr, uid, ids, smtp_tls):
smtp_port = 0
if smtp_tls:
smtp_port = 0
return {'value':{'smtp_tls':smtp_tls,'smtp_ssl':False,'smtp_port':smtp_port}}
ir_mail_server()
+1 -2
View File
@@ -430,11 +430,10 @@ def generate_tracking_message_id(openobject_id):
def email_send(smtp_from, smtp_to_list, message, ssl=False, debug=False, smtp_server=None, smtp_port=None,
smtp_user=None, smtp_password=None, cr=None):
print 'email tool:'
if not cr:
db_name = getattr(threading.currentThread(), 'dbname', None)
if db_name:
cr = pooler.get_db_only(dbname).cursor()
cr = pooler.get_db_only(db_name).cursor()
else:
raise Exception("No database cursor found!")
try: