[IMP] ir.xml: created view for ir_mail_server and added menu

bzr revid: rha@tinyerp.com-20110321131209-jqwa3mop83nuy7av
This commit is contained in:
Rifakat Haradwala (Open ERP) 2011-03-21 18:42:09 +05:30
parent a3c6bf9016
commit 75e5720f4e
3 changed files with 79 additions and 39 deletions

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
@ -15,7 +15,7 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@ -36,6 +36,7 @@ import ir_rule
import wizard
import ir_config_parameter
import osv_memory_autovacuum
import ir_mail_server
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1942,5 +1942,77 @@
<field name="args">()</field>
</record>
<!-- ir.mail.server -->
<record model="ir.ui.view" id="ir_mail_server_form">
<field name="name">ir.mail.server.form</field>
<field name="model">ir.mail.server</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Smtp Server Configuration">
<group colspan="4">
<field name="name"/>
</group>
<notebook colspan="4">
<page string="Configuration">
<separator string="Server Information" colspan="4"/>
<group colspan="4" col="8">
<field name="smtp_host"/>
<field name="smtp_port"/>
<field name="smtp_ssl"/>
<field name="smtp_tls"/>
</group>
<separator string="User Information" colspan="4"/>
<group col="6" colspan="4">
<field name="smtp_user"/>
<field name="smtp_pass" password="True"/>
</group>
<separator string="" colspan="4"/>
<label string="" colspan="2"/>
<button name="test_smtp_connection" type="object" string="Test Connection" icon="gtk-network" colspan="2"/>
</page>
</notebook>
</form>
</field>
</record>
<record model="ir.ui.view" id="ir_mail_server_tree">
<field name="name">ir.mail.server.tree</field>
<field name="model">ir.mail.server</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="SMTP Server">
<field name="name"/>
<field name="smtp_host"/>
<button name="test_smtp_connection" type="object" string="Test Connection" icon="gtk-network"/>
</tree>
</field>
</record>
<record id="view_ir_mail_server_search" model="ir.ui.view">
<field name="name">ir.mail.server.search</field>
<field name="model">ir.mail.server</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Smtp Server">
<field name="name"/>
</search>
</field>
</record>
<record model="ir.actions.act_window" id="action_ir_mail_server_tree_all">
<field name="name">Email Accounts</field>
<field name="res_model">ir.mail.server</field>
<field name="view_type">form</field>
<field name="view_mode">form,tree</field>
<field name="view_id" ref="ir_mail_server_tree" />
<field name="context">{'group_by': [], 'search_default_draft': 1, 'search_default_my': 1}</field>
<field name="search_view_id" ref="view_ir_mail_server_search"/>
</record>
<menuitem name="Email Accounts" id="menu_email_smtp_server_all" parent="base.menu_config" action="action_ir_mail_server_tree_all" sequence="15"/>
</data>
</openerp>

View File

@ -24,33 +24,8 @@ from osv import fields
from tools.translate import _
import tools
#import time
#import binascii
#import email
#from email.header import decode_header
#from email.utils import parsedate
#import base64
#import re
#import logging
#import xmlrpclib
#_logger = logging.getLogger('mailgate')
#import re
import smtplib
#import base64
#from email import Encoders
#from email.mime.base import MIMEBase
#from email.mime.multipart import MIMEMultipart
#from email.mime.text import MIMEText
#from email.header import decode_header, Header
#from email.utils import formatdate
#import netsvc
#import datetime
#import tools
#import logging
#EMAIL_PATTERN = re.compile(r'([^()\[\] ,<:\\>@";]+@[^()\[\] ,<:\\>@";]+)') # See RFC822
import netsvc
class ir_mail_server(osv.osv):
"""
@ -65,9 +40,6 @@ class ir_mail_server(osv.osv):
help="The Name is used as the Sender name along with the provided From Email, \
unless it is already specified in the From Email, e.g: John Doe <john@doe.com>",
),
'email_id': fields.char('From Email',
size=120, required=True,
help="eg: 'john@doe.com' or 'John Doe <john@doe.com>'"),
'smtp_host': fields.char('Server',
size=120, required=True,
help="Enter name of outgoing server, eg: smtp.yourdomain.com"),
@ -97,15 +69,11 @@ unless it is already specified in the From Email, e.g: John Doe <john@doe.com>",
}
_sql_constraints = [
(
'email_uniq',
'unique (email_id)',
'Another setting already exists with this email ID !')
]
def name_get(self, cr, uid, ids, context=None):
return [(a["id"], "%s (%s)" % (a['email_id'], a['name'])) for a in self.read(cr, uid, ids, ['name', 'email_id'], context=context)]
return [(a["id"], "(%s)" % (a['name'])) for a in self.read(cr, uid, ids, ['name'], context=context)]
def test_smtp_connection(self, cr, uid, ids, context=None):
"""
@ -113,8 +81,8 @@ unless it is already specified in the From Email, e.g: John Doe <john@doe.com>",
"""
try:
for smtp_server in self.browse(cr, uid, ids, context=context):
smtp = tools.connect_smtp_server(smtp_server.smtpserver, smtp_server.smtpport, user_name=smtp_server.smtpuname,
user_password=smtp_server.smtppass, ssl=smtp_server.smtpssl, tls=smtp_server.smtptls)
smtp = tools.connect_smtp_server(smtp_server.smtp_host, smtp_server.smtp_port, user_name=smtp_server.smtp_user,
user_password=smtp_server.smtp_pass, ssl=smtp_server.smtp_ssl, tls=smtp_server.smtp_tls)
try:
smtp.quit()
except Exception:
@ -128,7 +96,6 @@ unless it is already specified in the From Email, e.g: John Doe <john@doe.com>",
raise osv.except_osv(_("SMTP Connection: Test Successfully!"), '')
ir_mail_server()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: