Mantavya Gajjar (Open ERP) has proposed merging
lp:~openerp-dev/openobject-server/trunk-bug--mga into lp:openobject-server.
Requested reviews:
Vo Minh Thu (OpenERP) (vmt-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-bug--mga/+merge/69986
Fix a problem of sending emails through server action which using sendmail tool.
--
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-bug--mga/+merge/69986
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-server/trunk-bug--mga.
=== modified file 'openerp/addons/base/ir/ir_actions.py'
--- openerp/addons/base/ir/ir_actions.py 2011-07-06 15:40:01 +0000
+++ openerp/addons/base/ir/ir_actions.py 2011-08-01 11:51:23 +0000
@@ -32,6 +32,7 @@
import os
from xml import dom
from report.report_sxw import report_sxw, report_rml
+from socket import gethostname
class actions(osv.osv):
_name = 'ir.actions.actions'
@@ -598,16 +599,18 @@
logger = logging.getLogger(self._name)
if context is None:
context = {}
+ user = self.pool.get('res.users').browse(cr, uid, uid)
for action in self.browse(cr, uid, ids, context):
obj_pool = self.pool.get(action.model_id.model)
obj = obj_pool.browse(cr, uid, context['active_id'], context=context)
cxt = {
- 'context': dict(context), # copy context to prevent side-effects of eval
- 'object': obj,
+ 'context':dict(context), # copy context to prevent side-effects of eval
+ 'object':obj,
'time':time,
- 'cr': cr,
- 'pool' : self.pool,
- 'uid' : uid
+ 'cr':cr,
+ 'pool':self.pool,
+ 'uid':uid,
+ 'user':user
}
expr = eval(str(action.condition), cxt)
if not expr:
@@ -629,13 +632,14 @@
'uid': uid,
'object':obj,
'obj': obj,
+ 'user':user
}
eval(action.code, localdict, mode="exec", nocopy=True) # nocopy allows to return 'action'
if 'action' in localdict:
return localdict['action']
if action.state == 'email':
- user = config['email_from']
+ email_from = config['email_from']
address = str(action.email)
try:
address = eval(str(action.email), cxt)
@@ -643,16 +647,20 @@
pass
if not address:
- logger.info('Partner Email address not Specified!')
+ logger.info('Partner email address not specified!')
continue
- if not user:
- logger.info('Email-From address not Specified at server!')
- raise osv.except_osv(_('Error'), _("Please specify server option --email-from !"))
+
+ if not email_from:
+ logger.info('Email from address not specify at server option --email-from !')
+ if user.user_email:
+ email_from = user.user_email
+ else:
+ email_from = "%s@%s" % (user.login, gethostname())
subject = self.merge_message(cr, uid, action.subject, action, context)
body = self.merge_message(cr, uid, action.message, action, context)
- if tools.email_send(user, [address], subject, body, debug=False, subtype='html') == True:
+ if tools.email_send(email_from, [address], subject, body, debug=False, subtype='html') == True:
logger.info('Email successfully sent to: %s', address)
else:
logger.warning('Failed to send email to: %s', address)
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp