[MERGE] forward port of branch 7.0 up to 1d76586
This commit is contained in:
commit
a8fdc60b88
|
@ -39,6 +39,7 @@ from openerp import tools
|
|||
from openerp.tools.translate import _
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
MAX_POP_MESSAGES = 50
|
||||
|
||||
class fetchmail_server(osv.osv):
|
||||
"""Incoming POP/IMAP mail server account"""
|
||||
|
@ -222,27 +223,31 @@ openerp_mailgate: "|/path/to/openerp-mailgate.py --host=localhost -u %(uid)d -p
|
|||
imap_server.logout()
|
||||
elif server.type == 'pop':
|
||||
try:
|
||||
pop_server = server.connect()
|
||||
(numMsgs, totalSize) = pop_server.stat()
|
||||
pop_server.list()
|
||||
for num in range(1, numMsgs + 1):
|
||||
(header, msges, octets) = pop_server.retr(num)
|
||||
msg = '\n'.join(msges)
|
||||
res_id = None
|
||||
try:
|
||||
res_id = mail_thread.message_process(cr, uid, server.object_id.model,
|
||||
msg,
|
||||
save_original=server.original,
|
||||
strip_attachments=(not server.attach),
|
||||
context=context)
|
||||
pop_server.dele(num)
|
||||
except Exception:
|
||||
_logger.exception('Failed to process mail from %s server %s.', server.type, server.name)
|
||||
failed += 1
|
||||
if res_id and server.action_id:
|
||||
action_pool.run(cr, uid, [server.action_id.id], {'active_id': res_id, 'active_ids': [res_id], 'active_model': context.get("thread_model", server.object_id.model)})
|
||||
cr.commit()
|
||||
_logger.info("Fetched %d email(s) on %s server %s; %d succeeded, %d failed.", numMsgs, server.type, server.name, (numMsgs - failed), failed)
|
||||
while True:
|
||||
pop_server = server.connect()
|
||||
(numMsgs, totalSize) = pop_server.stat()
|
||||
pop_server.list()
|
||||
for num in range(1, min(MAX_POP_MESSAGES, numMsgs) + 1):
|
||||
(header, msges, octets) = pop_server.retr(num)
|
||||
msg = '\n'.join(msges)
|
||||
res_id = None
|
||||
try:
|
||||
res_id = mail_thread.message_process(cr, uid, server.object_id.model,
|
||||
msg,
|
||||
save_original=server.original,
|
||||
strip_attachments=(not server.attach),
|
||||
context=context)
|
||||
pop_server.dele(num)
|
||||
except Exception:
|
||||
_logger.exception('Failed to process mail from %s server %s.', server.type, server.name)
|
||||
failed += 1
|
||||
if res_id and server.action_id:
|
||||
action_pool.run(cr, uid, [server.action_id.id], {'active_id': res_id, 'active_ids': [res_id], 'active_model': context.get("thread_model", server.object_id.model)})
|
||||
cr.commit()
|
||||
if numMsgs < MAX_POP_MESSAGES:
|
||||
break
|
||||
pop_server.quit()
|
||||
_logger.info("Fetched %d email(s) on %s server %s; %d succeeded, %d failed.", numMsgs, server.type, server.name, (numMsgs - failed), failed)
|
||||
except Exception:
|
||||
_logger.exception("General failure when trying to fetch mail from %s server %s.", server.type, server.name)
|
||||
finally:
|
||||
|
|
|
@ -1527,7 +1527,7 @@ class Action(http.Controller):
|
|||
except Exception:
|
||||
action_id = 0 # force failed read
|
||||
|
||||
base_action = Actions.read([action_id], ['type'], request.context)
|
||||
base_action = Actions.read([action_id], ['name', 'type'], request.context)
|
||||
if base_action:
|
||||
ctx = {}
|
||||
action_type = base_action[0]['type']
|
||||
|
@ -1536,7 +1536,7 @@ class Action(http.Controller):
|
|||
ctx.update(request.context)
|
||||
action = request.session.model(action_type).read([action_id], False, ctx)
|
||||
if action:
|
||||
value = clean_action(action[0])
|
||||
value = clean_action(dict(action[0], **base_action[0]))
|
||||
return value
|
||||
|
||||
@http.route('/web/action/run', type='json', auth="user")
|
||||
|
|
|
@ -1177,7 +1177,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
|||
},
|
||||
build_eval_context: function() {
|
||||
var a_dataset = this.dataset;
|
||||
return new instance.web.CompoundContext(this._build_view_fields_values(), a_dataset.get_context());
|
||||
return new instance.web.CompoundContext(a_dataset.get_context(), this._build_view_fields_values());
|
||||
},
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue