[MERGE] merged trunk.

bzr revid: vmt@openerp.com-20110822111142-11251h9i4ueguq6g
This commit is contained in:
Vo Minh Thu 2011-08-22 13:11:42 +02:00
commit c086f79ae1
2 changed files with 32 additions and 11 deletions

View File

@ -33,6 +33,7 @@ from report.report_sxw import report_sxw, report_rml
from tools.config import config
from tools.safe_eval import safe_eval as eval
from tools.translate import _
from socket import gethostname
class actions(osv.osv):
_name = 'ir.actions.actions'
@ -598,16 +599,18 @@ class actions_server(osv.osv):
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,
'time':time,
'time': time,
'cr': cr,
'pool' : self.pool,
'uid' : uid
'pool': self.pool,
'uid': uid,
'user': user
}
expr = eval(str(action.condition), cxt)
if not expr:
@ -629,13 +632,14 @@ class actions_server(osv.osv):
'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 @@ class actions_server(osv.osv):
pass
if not address:
logger.info('Partner Email address not Specified!')
logger.info('No partner email address specified, not sending any email.')
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.debug('--email-from command line option is not specified, using a fallback value instead.')
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)

View File

@ -136,6 +136,14 @@ class integer(_column):
_symbol_get = lambda self,x: x or 0
class integer_big(_column):
"""Experimental 64 bit integer column type, currently unused.
TODO: this field should work fine for values up
to 32 bits, but greater values will not fit
in the XML-RPC int type, so a specific
get() method is needed to pass them as floats,
like what we do for integer functional fields.
"""
_type = 'integer_big'
# do not reference the _symbol_* of integer class, as that would possibly
# unbind the lambda functions
@ -915,8 +923,13 @@ class function(_column):
else:
result = sanitize_binary_value(value)
if field_type == "integer":
result = tools.ustr(value)
if field_type in ("integer","integer_big") and value > xmlrpclib.MAXINT:
# integer/long values greater than 2^31-1 are not supported
# in pure XMLRPC, so we have to pass them as floats :-(
# This is not needed for stored fields and non-functional integer
# fields, as their values are constrained by the database backend
# to the same 32bits signed int limit.
result = float(value)
return result
def get(self, cr, obj, ids, name, uid=False, context=None, values=None):