[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 _
|
from openerp.tools.translate import _
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
MAX_POP_MESSAGES = 50
|
||||||
|
|
||||||
class fetchmail_server(osv.osv):
|
class fetchmail_server(osv.osv):
|
||||||
"""Incoming POP/IMAP mail server account"""
|
"""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()
|
imap_server.logout()
|
||||||
elif server.type == 'pop':
|
elif server.type == 'pop':
|
||||||
try:
|
try:
|
||||||
pop_server = server.connect()
|
while True:
|
||||||
(numMsgs, totalSize) = pop_server.stat()
|
pop_server = server.connect()
|
||||||
pop_server.list()
|
(numMsgs, totalSize) = pop_server.stat()
|
||||||
for num in range(1, numMsgs + 1):
|
pop_server.list()
|
||||||
(header, msges, octets) = pop_server.retr(num)
|
for num in range(1, min(MAX_POP_MESSAGES, numMsgs) + 1):
|
||||||
msg = '\n'.join(msges)
|
(header, msges, octets) = pop_server.retr(num)
|
||||||
res_id = None
|
msg = '\n'.join(msges)
|
||||||
try:
|
res_id = None
|
||||||
res_id = mail_thread.message_process(cr, uid, server.object_id.model,
|
try:
|
||||||
msg,
|
res_id = mail_thread.message_process(cr, uid, server.object_id.model,
|
||||||
save_original=server.original,
|
msg,
|
||||||
strip_attachments=(not server.attach),
|
save_original=server.original,
|
||||||
context=context)
|
strip_attachments=(not server.attach),
|
||||||
pop_server.dele(num)
|
context=context)
|
||||||
except Exception:
|
pop_server.dele(num)
|
||||||
_logger.exception('Failed to process mail from %s server %s.', server.type, server.name)
|
except Exception:
|
||||||
failed += 1
|
_logger.exception('Failed to process mail from %s server %s.', server.type, server.name)
|
||||||
if res_id and server.action_id:
|
failed += 1
|
||||||
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)})
|
if res_id and server.action_id:
|
||||||
cr.commit()
|
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)})
|
||||||
_logger.info("Fetched %d email(s) on %s server %s; %d succeeded, %d failed.", numMsgs, server.type, server.name, (numMsgs - failed), failed)
|
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:
|
except Exception:
|
||||||
_logger.exception("General failure when trying to fetch mail from %s server %s.", server.type, server.name)
|
_logger.exception("General failure when trying to fetch mail from %s server %s.", server.type, server.name)
|
||||||
finally:
|
finally:
|
||||||
|
|
|
@ -1527,7 +1527,7 @@ class Action(http.Controller):
|
||||||
except Exception:
|
except Exception:
|
||||||
action_id = 0 # force failed read
|
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:
|
if base_action:
|
||||||
ctx = {}
|
ctx = {}
|
||||||
action_type = base_action[0]['type']
|
action_type = base_action[0]['type']
|
||||||
|
@ -1536,7 +1536,7 @@ class Action(http.Controller):
|
||||||
ctx.update(request.context)
|
ctx.update(request.context)
|
||||||
action = request.session.model(action_type).read([action_id], False, ctx)
|
action = request.session.model(action_type).read([action_id], False, ctx)
|
||||||
if action:
|
if action:
|
||||||
value = clean_action(action[0])
|
value = clean_action(dict(action[0], **base_action[0]))
|
||||||
return value
|
return value
|
||||||
|
|
||||||
@http.route('/web/action/run', type='json', auth="user")
|
@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() {
|
build_eval_context: function() {
|
||||||
var a_dataset = this.dataset;
|
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