if ref_match:
thread_id = int(ref_match.group(1))
model = ref_match.group(2) or model
- model_pool = self.pool.get(model)
- if thread_id and model and model_pool and model_pool.exists(cr, uid, thread_id) \
- and hasattr(model_pool, 'message_update'):
- _logger.info('Routing mail from %s to %s with Message-Id %s: direct reply to model: %s, thread_id: %s, custom_values: %s, uid: %s',
- email_from, email_to, message_id, model, thread_id, custom_values, uid)
- return [(model, thread_id, custom_values, uid)]
+ if thread_id and model in self.pool:
+ model_obj = self.pool[model]
+ if model_obj.exists(cr, uid, thread_id) and hasattr(model_obj, 'message_update'):
- _logger.debug('Routing mail with Message-Id %s: direct reply to model: %s, thread_id: %s, custom_values: %s, uid: %s',
- message_id, model, thread_id, custom_values, uid)
++ _logger.info('Routing mail from %s to %s with Message-Id %s: direct reply to model: %s, thread_id: %s, custom_values: %s, uid: %s',
++ email_from, email_to, message_id, model, thread_id, custom_values, uid)
+ return [(model, thread_id, custom_values, uid)]
# Verify whether this is a reply to a private message
if in_reply_to:
related to.
:param int res_id: id of the document record this mail is related to
"""
- doc_name_get = self.pool.get(model).name_get(cr, uid, [res_id], context=context)
+ doc_name_get = self.pool[model].name_get(cr, uid, [res_id], context=context)
+ record_name = False
if doc_name_get:
record_name = doc_name_get[0][1]
- else:
- record_name = False
- return {'model': model, 'res_id': res_id, 'record_name': record_name}
+ values = {
+ 'model': model,
+ 'res_id': res_id,
+ 'record_name': record_name,
+ }
+ if record_name:
+ values['subject'] = 'Re: %s' % record_name
+ return values
def get_message_data(self, cr, uid, message_id, context=None):
""" Returns a defaults-like dict with initial values for the composition
res_id = msg.res_id
model = msg.model
url = self._make_url(cr, uid, res_id, model)
- name = self.pool.get(model).name_get(cr, uid, [res_id])[0][1]
+ name = self.pool[model].name_get(cr, uid, [res_id])[0][1]
- return (model,res_id, url,name)
+ return (model, res_id, url, name)
def document_type(self, cr, uid, context=None):
"""
@return Dictionary which contain model , url and resource id.
"""
mail_message = self.pool.get('mail.message')
- model_obj = self.pool.get(model)
+ model_obj = self.pool[model]
msg = self.pool.get('mail.thread').message_parse(cr, uid, email)
message_id = msg.get('message-id')
- mail_ids = mail_message.search(cr, uid, [('message_id','=',message_id),('res_id','=',res_id),('model','=',model)])
-
- if message_id and mail_ids :
+ mail_ids = mail_message.search(cr, uid, [('message_id', '=', message_id), ('res_id', '=', res_id), ('model', '=', model)])
+ if message_id and mail_ids:
mail_record = mail_message.browse(cr, uid, mail_ids)[0]
res_id = mail_record.res_id
- notify = "Email already pushed"
+ notify = _("Email already pushed")
elif res_id == 0:
if model == 'res.partner':
- notify = 'User the Partner button to create a new partner'
+ notify = _('Use the Partner button to create a new partner')
else:
res_id = model_obj.message_process(cr, uid, model, email)
- notify = "Mail successfully pushed, a new %s has been created " % model
+ notify = _("Mail successfully pushed, a new %s has been created.") % model
else:
model_obj.message_post(cr, uid, [res_id],
- body= msg.get('body'),
- subject= msg.get('subject'),
- type= 'email',
- parent_id= msg.get('parent_id'),
- attachments= msg.get('attachments'))
- notify = "Mail successfully pushed"
+ body=msg.get('body'),
+ subject=msg.get('subject'),
+ type='email',
+ parent_id=msg.get('parent_id'),
+ attachments=msg.get('attachments'))
+ notify = _("Mail successfully pushed")
url = self._make_url(cr, uid, res_id, model)
return (model, res_id, url, notify)