[PEP8] mail_environment

pull/12/head
Yannick Vaucher 2014-07-11 17:46:06 +02:00
parent 71e9ffb564
commit cc2dbd6c85
2 changed files with 119 additions and 101 deletions

View File

@ -26,8 +26,10 @@
'description': """ 'description': """
Extend mail and fetch mail with server environment module. Extend mail and fetch mail with server environment module.
In config files, sections outgoint_mail and incoming_mails are default values for all Outgoing Mail Servers and Fetchmail Servers. In config files, sections outgoint_mail and incoming_mails are default values
For each server, you can (re)define values with a section named "outgoing_mail.resource_name" where resource_name is the name of your server. for all Outgoing Mail Servers and Fetchmail Servers.
For each server, you can (re)define values with a section named
"outgoing_mail.resource_name" where resource_name is the name of your server.
Exemple of config file : Exemple of config file :
@ -64,4 +66,3 @@ password = openerp
'installable': True, 'installable': True,
'active': False, 'active': False,
} }
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -52,43 +52,48 @@ class IrMail(osv.osv):
return res return res
_columns = { _columns = {
'smtp_host': fields.function(_get_smtp_conf, 'smtp_host': fields.function(
method=True, _get_smtp_conf,
string='SMTP Server', method=True,
type="char", string='SMTP Server',
multi='outgoing_mail_config', type="char",
size=128), multi='outgoing_mail_config',
'smtp_port': fields.function(_get_smtp_conf, size=128),
method=True, 'smtp_port': fields.function(
string='SMTP Port', _get_smtp_conf,
type="integer", method=True,
multi='outgoing_mail_config', string='SMTP Port',
help="SMTP Port. Usually 465 for SSL, and 25 or 587 for other cases.", type="integer",
size=5), multi='outgoing_mail_config',
'smtp_user': fields.function(_get_smtp_conf, help="SMTP Port. Usually 465 for SSL, and 25 or 587 for other cases.",
method=True, size=5),
string='Username', 'smtp_user': fields.function(
type="char", _get_smtp_conf,
multi='outgoing_mail_config', method=True,
help="Optional username for SMTP authentication", string='Username',
size=64), type="char",
'smtp_pass': fields.function(_get_smtp_conf, multi='outgoing_mail_config',
method=True, help="Optional username for SMTP authentication",
string='Password', size=64),
type="char", 'smtp_pass': fields.function(
multi='outgoing_mail_config', _get_smtp_conf,
help="Optional password for SMTP authentication", method=True,
size=64), string='Password',
'smtp_encryption' :fields.function(_get_smtp_conf, type="char",
method=True, multi='outgoing_mail_config',
string='smtp_encryption', help="Optional password for SMTP authentication",
type="char", size=64),
multi='outgoing_mail_config', 'smtp_encryption': fields.function(
help="Choose the connection encryption scheme:\n" _get_smtp_conf,
"- none: SMTP sessions are done in cleartext.\n" method=True,
"- starttls: TLS encryption is requested at start of SMTP session (Recommended)\n" string='smtp_encryption',
"- ssl: SMTP sessions are encrypted with SSL/TLS through a dedicated port (default: 465)", type="char",
size=64)} multi='outgoing_mail_config',
help="Choose the connection encryption scheme:\n"
"- none: SMTP sessions are done in cleartext.\n"
"- starttls: TLS encryption is requested at start of SMTP session (Recommended)\n"
"- ssl: SMTP sessions are encrypted with SSL/TLS through a dedicated port (default: 465)",
size=64)}
IrMail() IrMail()
@ -108,13 +113,15 @@ class FetchmailServer(osv.osv):
key_types = {'port': int, key_types = {'port': int,
'is_ssl': lambda a: bool(int(a)), 'is_ssl': lambda a: bool(int(a)),
'attach': lambda a: bool(int(a)), 'attach': lambda a: bool(int(a)),
'original': lambda a: bool(int(a)),} 'original': lambda a: bool(int(a)),
}
# default vals # default vals
config_vals = {'port': 993, config_vals = {'port': 993,
'is_ssl': 0, 'is_ssl': 0,
'attach': 0, 'attach': 0,
'original': 0} 'original': 0,
}
if serv_config.has_section(global_section_name): if serv_config.has_section(global_section_name):
config_vals.update(serv_config.items(global_section_name)) config_vals.update(serv_config.items(global_section_name))
@ -132,7 +139,7 @@ class FetchmailServer(osv.osv):
result_ids = [] result_ids = []
# read all incomming servers values # read all incomming servers values
all_ids = self.search(cr, uid, [], context=context) all_ids = self.search(cr, uid, [], context=context)
results = self.read(cr, uid, all_ids, ['id','type'], context=context) results = self.read(cr, uid, all_ids, ['id', 'type'], context=context)
args = args[:] args = args[:]
i = 0 i = 0
while i < len(args): while i < len(args):
@ -145,64 +152,74 @@ class FetchmailServer(osv.osv):
for search_vals in args[i][2]: for search_vals in args[i][2]:
for res in results: for res in results:
if (res['type'] == search_vals) and (res['id'] not in result_ids): if (res['type'] == search_vals) and (res['id'] not in result_ids):
result_ids.append(res['id']) result_ids.append(res['id'])
else: else:
continue continue
i += 1 i += 1
return [('id', 'in', result_ids)] return [('id', 'in', result_ids)]
_columns = { _columns = {
'server': fields.function(_get_incom_conf, 'server': fields.function(
method=True, _get_incom_conf,
string='Server', method=True,
type="char", string='Server',
multi='income_mail_config', type="char",
size=256, help="Hostname or IP of the mail server"), multi='income_mail_config',
'port': fields.function(_get_incom_conf, size=256, help="Hostname or IP of the mail server"),
method=True, 'port': fields.function(
string='Port', _get_incom_conf,
type="integer", method=True,
multi='income_mail_config', string='Port',
help="Hostname or IP of the mail server"), type="integer",
'type': fields.function(_get_incom_conf, multi='income_mail_config',
method=True, help="Hostname or IP of the mail server"),
string='Type', 'type': fields.function(
type="char", _get_incom_conf,
multi='income_mail_config', method=True,
fnct_search=_type_search, string='Type',
size=64, type="char",
help="pop, imap, local"), multi='income_mail_config',
'is_ssl': fields.function(_get_incom_conf, fnct_search=_type_search,
method=True, size=64,
string='Is SSL', help="pop, imap, local"),
type="boolean", 'is_ssl': fields.function(
multi='income_mail_config', _get_incom_conf,
help='Connections are encrypted with SSL/TLS through' method=True,
' a dedicated port (default: IMAPS=993, POP3S=995)'), string='Is SSL',
'attach': fields.function(_get_incom_conf, type="boolean",
method=True, multi='income_mail_config',
string='Keep Attachments', help='Connections are encrypted with SSL/TLS through'
type="boolean", ' a dedicated port (default: IMAPS=993, POP3S=995)'),
multi='income_mail_config', 'attach': fields.function(
help="Whether attachments should be downloaded. " _get_incom_conf,
"If not enabled, incoming emails will be stripped of any attachments before being processed"), method=True,
'original': fields.function(_get_incom_conf, string='Keep Attachments',
method=True, type="boolean",
string='Keep Original', multi='income_mail_config',
type="boolean", help="Whether attachments should be downloaded. "
multi='income_mail_config', "If not enabled, incoming emails will be stripped of any "
help="Whether a full original copy of each email should be kept for reference" "attachments before being processed"),
"and attached to each processed message. This will usually double the size of your message database."), 'original': fields.function(
'user': fields.function(_get_incom_conf, _get_incom_conf,
method=True, method=True,
string='Username', string='Keep Original',
type="char", type="boolean",
multi='income_mail_config', multi='income_mail_config',
size=64), help="Whether a full original copy of each email should be kept "
'password': fields.function(_get_incom_conf, "for reference and attached to each processed message. This "
method=True, "will usually double the size of your message database."),
string='password', 'user': fields.function(
type="char", _get_incom_conf,
multi='income_mail_config', method=True,
size=64)} string='Username',
type="char",
multi='income_mail_config',
size=64),
'password': fields.function(
_get_incom_conf,
method=True,
string='password',
type="char",
multi='income_mail_config',
size=64)}
FetchmailServer() FetchmailServer()