|
|
@ -1,8 +1,9 @@ |
|
|
|
from lxml import etree |
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
from openerp import api, models, fields, SUPERUSER_ID |
|
|
|
from openerp.tools import email_split |
|
|
|
from openerp.tools.translate import _ |
|
|
|
|
|
|
|
|
|
|
|
class wizard(models.TransientModel): |
|
|
|
_name = 'mail_move_message.wizard' |
|
|
|
|
|
|
@ -34,7 +35,7 @@ class wizard(models.TransientModel): |
|
|
|
if 'message_id' in res: |
|
|
|
message = self.env['mail.message'].browse(res['message_id']) |
|
|
|
email_from = message.email_from |
|
|
|
parts = email_split(email_from.replace(' ',',')) |
|
|
|
parts = email_split(email_from.replace(' ', ',')) |
|
|
|
if parts: |
|
|
|
email = parts[0] |
|
|
|
name = email_from.find(email) != -1 and email_from[:email_from.index(email)].replace('"', '').replace('<', '').strip() or email_from |
|
|
@ -140,7 +141,7 @@ class wizard(models.TransientModel): |
|
|
|
operation = 'write' |
|
|
|
context = self._context |
|
|
|
|
|
|
|
if not ( self.model and self.res_id ): |
|
|
|
if not (self.model and self.res_id): |
|
|
|
return True |
|
|
|
model_obj = self.pool[self.model] |
|
|
|
mids = model_obj.exists(cr, uid, [self.res_id]) |
|
|
@ -170,8 +171,8 @@ class wizard(models.TransientModel): |
|
|
|
r.check_access() |
|
|
|
if not r.parent_id or not (r.parent_id.model == r.model and |
|
|
|
r.parent_id.res_id == r.res_id): |
|
|
|
#link with the first message of record |
|
|
|
parent = self.env['mail.message'].search([('model','=',r.model), ('res_id','=',r.res_id)], order='id', limit=1) |
|
|
|
# link with the first message of record |
|
|
|
parent = self.env['mail.message'].search([('model', '=', r.model), ('res_id', '=', r.res_id)], order='id', limit=1) |
|
|
|
r.parent_id = parent.id or None |
|
|
|
|
|
|
|
r.message_id.move(r.parent_id.id, r.res_id, r.model, r.move_back, r.move_followers) |
|
|
@ -333,7 +334,7 @@ class mail_message(models.Model): |
|
|
|
return [] |
|
|
|
if isinstance(ids, (long, int)): |
|
|
|
ids = [ids] |
|
|
|
reads = self.read(cr, uid, ids, ['record_name','model', 'res_id'], context=context) |
|
|
|
reads = self.read(cr, uid, ids, ['record_name', 'model', 'res_id'], context=context) |
|
|
|
res = [] |
|
|
|
for record in reads: |
|
|
|
name = record['record_name'] or '' |
|
|
|