* Add evaluation to get the email/sms addres from the object
* Add new start up attribute to the server --smtp-port * Make change in the misc for the connecting method for smtp server bzr revid: mga@tinyerp.com-20080820111520-amoeqiec817agewa
This commit is contained in:
parent
95518b629b
commit
21d60c3889
|
@ -1059,6 +1059,8 @@
|
|||
<separator colspan="4" string="Email Configuration"/>
|
||||
<field name="address" domain="[('model_id','=',model_id)]"/>
|
||||
<field name="message" select="2" colspan="4"/>
|
||||
<newline/>
|
||||
<label colspan="4" string="Use o to access the current object, you can use the any attributes which is belongs to current selected obect with o, i.e. o.partner_id.name for Invoice Object"/>
|
||||
</page>
|
||||
|
||||
<page string="Other Actions" attrs="{'invisible':[('state','!=','other')]}">
|
||||
|
|
|
@ -330,6 +330,7 @@ class ir_model_fields(osv.osv):
|
|||
return result
|
||||
|
||||
ir_model_fields()
|
||||
|
||||
##
|
||||
# Actions that are run on the server side
|
||||
#
|
||||
|
@ -379,11 +380,6 @@ class actions_server(osv.osv):
|
|||
"""
|
||||
}
|
||||
|
||||
# def on_change_model(self, cr, uid, ids, model_id):
|
||||
# print '**************** : method called'
|
||||
# res = {'value' : {'address': [('key1','Email Value One')]} }
|
||||
# return res
|
||||
|
||||
#
|
||||
# Context should contains:
|
||||
# ids : original ids
|
||||
|
@ -411,14 +407,23 @@ class actions_server(osv.osv):
|
|||
user = config['email_from']
|
||||
subject = action.name
|
||||
|
||||
#TODO : Apply Mail merge in to the Content of the Email
|
||||
print '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ',context
|
||||
obj_pool = self.pool.get(action.model_id.model)
|
||||
id = context.get('active_id')
|
||||
obj = obj_pool.browse(cr, uid, id)
|
||||
|
||||
fields = action.address.complete_name.split('/')
|
||||
for field in fields:
|
||||
obj = getattr(obj, field)
|
||||
|
||||
address = obj
|
||||
|
||||
body = action.message
|
||||
if tools.email_send_attach(user, action.address, subject, body, debug=False) == True:
|
||||
logger.notifyChannel('email', netsvc.LOG_INFO, 'Email successfully send to : %s' % (action.address))
|
||||
#TODO : Apply Mail merge in to the Content of the Email
|
||||
|
||||
if tools.email_send_attach(user, address, subject, body, debug=True) == True:
|
||||
logger.notifyChannel('email', netsvc.LOG_INFO, 'Email successfully send to : %s' % (address))
|
||||
else:
|
||||
logger.notifyChannel('email', netsvc.LOG_ERROR, 'Failed to send email to : %s' % (action.address))
|
||||
logger.notifyChannel('email', netsvc.LOG_ERROR, 'Failed to send email to : %s' % (address))
|
||||
|
||||
if action.state == 'trigger':
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
|
|
|
@ -64,6 +64,7 @@ class configmanager(object):
|
|||
'secure': False,
|
||||
'smtp_server': 'localhost',
|
||||
'smtp_user': False,
|
||||
'smtp_port':25,
|
||||
'smtp_password': False,
|
||||
'stop_after_init': False, # this will stop the server after initialization
|
||||
'price_accuracy': 2,
|
||||
|
@ -96,8 +97,10 @@ class configmanager(object):
|
|||
parser.add_option('--debug', dest='debug_mode', action='store_true', default=False, help='enable debug mode')
|
||||
parser.add_option("--assert-exit-level", dest='assert_exit_level', help="specify the level at which a failed assertion will stop the server " + str(assert_exit_levels))
|
||||
parser.add_option("-S", "--secure", dest="secure", action="store_true", help="launch server over https instead of http", default=False)
|
||||
|
||||
parser.add_option('--email-from', dest='email_from', default='', help='specify the SMTP email address for sending email')
|
||||
parser.add_option('--smtp', dest='smtp_server', default='', help='specify the SMTP server for sending email')
|
||||
parser.add_option('--smtp-port', dest='smtp_port', default='25', help='specify the SMTP port')
|
||||
parser.add_option('--smtp-ssl', dest='smtp_ssl', default='', help='specify the SMTP server support SSL or not')
|
||||
parser.add_option('--smtp-user', dest='smtp_user', default='', help='specify the SMTP username for sending email')
|
||||
parser.add_option('--smtp-password', dest='smtp_password', default='', help='specify the SMTP password for sending email')
|
||||
|
@ -156,7 +159,7 @@ class configmanager(object):
|
|||
self.options['pidfile'] = False
|
||||
|
||||
for arg in ('interface', 'port', 'db_name', 'db_user', 'db_password', 'db_host',
|
||||
'db_port', 'logfile', 'pidfile', 'secure', 'smtp_ssl', 'email_from', 'smtp_server', 'smtp_user', 'smtp_password', 'price_accuracy', 'netinterface', 'netport', 'db_maxconn', 'import_partial', 'addons_path'):
|
||||
'db_port', 'logfile', 'pidfile', 'secure', 'smtp_ssl', 'smtp_port', 'email_from', 'smtp_server', 'smtp_user', 'smtp_password', 'price_accuracy', 'netinterface', 'netport', 'db_maxconn', 'import_partial', 'addons_path'):
|
||||
if getattr(opt, arg):
|
||||
self.options[arg] = getattr(opt, arg)
|
||||
|
||||
|
|
|
@ -403,7 +403,7 @@ def email_send_attach(email_from, email_to, subject, body, email_cc=None, email_
|
|||
s.starttls()
|
||||
s.ehlo()
|
||||
|
||||
s.connect(config['smtp_server'])
|
||||
s.connect(config['smtp_server'], config['smtp_port'])
|
||||
if config['smtp_user'] or config['smtp_password']:
|
||||
s.login(config['smtp_user'], config['smtp_password'])
|
||||
s.sendmail(email_from, flatten([email_to, email_cc, email_bcc]), msg.as_string())
|
||||
|
|
Loading…
Reference in New Issue