[MERGE] correction of backlog1
bzr revid: hmo@tinyerp.com-20110421095844-73673t3zs2clyeba
This commit is contained in:
commit
cf032c0bf0
|
@ -307,14 +307,6 @@ class crm_case(object):
|
|||
else:
|
||||
return {'value': {'phone': address.phone}}
|
||||
|
||||
def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, email_from=False, message_id=False, attach=None, context=None):
|
||||
thread_pool = self.pool.get('email.thread')
|
||||
return thread_pool.history(cr, uid, cases, keyword, history=history,\
|
||||
subject=subject, email=email, \
|
||||
details=details, email_from=email_from,\
|
||||
message_id=message_id, attach=attach, \
|
||||
context=context)
|
||||
|
||||
def case_open(self, cr, uid, ids, *args):
|
||||
"""Opens Case
|
||||
@param self: The object pointer
|
||||
|
@ -325,7 +317,7 @@ class crm_case(object):
|
|||
"""
|
||||
|
||||
cases = self.browse(cr, uid, ids)
|
||||
self._history(cr, uid, cases, _('Open'))
|
||||
self.history(cr, uid, cases, _('Open'))
|
||||
for case in cases:
|
||||
data = {'state': 'open', 'active': True}
|
||||
if not case.user_id:
|
||||
|
@ -346,7 +338,7 @@ class crm_case(object):
|
|||
"""
|
||||
cases = self.browse(cr, uid, ids)
|
||||
cases[0].state # to fill the browse record cache
|
||||
self._history(cr, uid, cases, _('Close'))
|
||||
self.history(cr, uid, cases, _('Close'))
|
||||
self.write(cr, uid, ids, {'state': 'done',
|
||||
'date_closed': time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
})
|
||||
|
@ -377,7 +369,7 @@ class crm_case(object):
|
|||
raise osv.except_osv(_('Error !'), _('You can not escalate, You are already at the top level regarding your sales-team category.'))
|
||||
self.write(cr, uid, [case.id], data)
|
||||
cases = self.browse(cr, uid, ids)
|
||||
self._history(cr, uid, cases, _('Escalate'))
|
||||
self.history(cr, uid, cases, _('Escalate'))
|
||||
self._action(cr, uid, cases, 'escalate')
|
||||
return True
|
||||
|
||||
|
@ -391,7 +383,7 @@ class crm_case(object):
|
|||
"""
|
||||
cases = self.browse(cr, uid, ids)
|
||||
cases[0].state # to fill the browse record cache
|
||||
self._history(cr, uid, cases, _('Cancel'))
|
||||
self.history(cr, uid, cases, _('Cancel'))
|
||||
self.write(cr, uid, ids, {'state': 'cancel',
|
||||
'active': True})
|
||||
self._action(cr, uid, cases, 'cancel')
|
||||
|
@ -410,7 +402,7 @@ class crm_case(object):
|
|||
"""
|
||||
cases = self.browse(cr, uid, ids)
|
||||
cases[0].state # to fill the browse record cache
|
||||
self._history(cr, uid, cases, _('Pending'))
|
||||
self.history(cr, uid, cases, _('Pending'))
|
||||
self.write(cr, uid, ids, {'state': 'pending', 'active': True})
|
||||
self._action(cr, uid, cases, 'pending')
|
||||
return True
|
||||
|
@ -425,7 +417,7 @@ class crm_case(object):
|
|||
"""
|
||||
cases = self.browse(cr, uid, ids)
|
||||
cases[0].state # to fill the browse record cache
|
||||
self._history(cr, uid, cases, _('Draft'))
|
||||
self.history(cr, uid, cases, _('Draft'))
|
||||
self.write(cr, uid, ids, {'state': 'draft', 'active': True})
|
||||
self._action(cr, uid, cases, 'draft')
|
||||
return True
|
||||
|
@ -498,7 +490,6 @@ class crm_case(object):
|
|||
openobject_id=str(case.id),
|
||||
attach=attach_to_send
|
||||
)
|
||||
self._history(cr, uid, [case], _('Send'), history=True, subject=subject, email=dest, details=body, email_from=src)
|
||||
return True
|
||||
|
||||
def _check(self, cr, uid, ids=False, context=None):
|
||||
|
|
|
@ -125,7 +125,7 @@ this if you want the rule to send an email to the partner."),
|
|||
|
||||
# Put state change by rule in communication history
|
||||
if hasattr(obj, 'state') and action.act_state:
|
||||
model_obj._history(cr, uid, [obj], _(action.act_state))
|
||||
model_obj.history(cr, uid, [obj], _(action.act_state))
|
||||
|
||||
model_obj.write(cr, uid, [obj.id], write, context)
|
||||
emails = []
|
||||
|
|
|
@ -171,7 +171,7 @@ class crm_merge_opportunity(osv.osv_memory):
|
|||
subject = subject[0] + ", ".join(subject[1:])
|
||||
details = "\n\n".join(details)
|
||||
|
||||
opp_obj._history(cr, uid, [first_opportunity], subject, details=details)
|
||||
opp_obj.history(cr, uid, [first_opportunity], subject, details=details)
|
||||
#data.update({'message_ids' : [(6, 0 ,self._concat_o2m('message_ids', op_ids))]})
|
||||
opp_obj.write(cr, uid, [first_opportunity.id], data)
|
||||
unlink_ids = map(lambda x: x.id, tail_opportunities)
|
||||
|
|
|
@ -309,6 +309,7 @@ class email_message(osv.osv):
|
|||
"""Return Dictionary Object after parse EML Message String
|
||||
@param message: email.message.Message object or string or unicode object
|
||||
"""
|
||||
msg_txt = message
|
||||
if isinstance(message, str):
|
||||
msg_txt = email.message_from_string(message)
|
||||
|
||||
|
@ -318,7 +319,6 @@ class email_message(osv.osv):
|
|||
message = message.encode('utf-8')
|
||||
msg_txt = email.message_from_string(message)
|
||||
|
||||
msg_txt = message
|
||||
message_id = msg_txt.get('message-id', False)
|
||||
msg = {}
|
||||
|
||||
|
|
|
@ -158,10 +158,7 @@ class email_thread(osv.osv):
|
|||
if attach is None:
|
||||
attach = {}
|
||||
|
||||
model = context.get('thread_model', False)
|
||||
if not model:
|
||||
model = self._name
|
||||
model_pool = self.pool.get(model)
|
||||
|
||||
|
||||
if email_date:
|
||||
edate = parsedate(email_date)
|
||||
|
@ -171,6 +168,10 @@ class email_thread(osv.osv):
|
|||
# The script sends the ids of the threads and not the object list
|
||||
|
||||
if all(isinstance(thread_id, (int, long)) for thread_id in threads):
|
||||
model = context.get('thread_model', False)
|
||||
if not model:
|
||||
model = self._name
|
||||
model_pool = self.pool.get(model)
|
||||
threads = model_pool.browse(cr, uid, threads, context=context)
|
||||
|
||||
att_obj = self.pool.get('ir.attachment')
|
||||
|
|
|
@ -372,7 +372,7 @@ class project_issue(crm.crm_case, osv.osv):
|
|||
else:
|
||||
raise osv.except_osv(_('Warning !'), _('You cannot escalate this issue.\nThe relevant Project has not configured the Escalation Project!'))
|
||||
self.write(cr, uid, [case.id], data)
|
||||
self._history(cr, uid, cases, _('Escalate'))
|
||||
self.history(cr, uid, cases, _('Escalate'))
|
||||
return True
|
||||
|
||||
def message_new(self, cr, uid, msg, context=None):
|
||||
|
|
|
@ -120,30 +120,22 @@ class project_tasks(osv.osv):
|
|||
return len(res) and res[0] or False
|
||||
return res
|
||||
|
||||
def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, email_from=False, message_id=False, attach=None, context=None):
|
||||
thread_pool = self.pool.get('email.thread')
|
||||
return thread_pool.history(cr, uid, cases, keyword, history=history,\
|
||||
subject=subject, email=email, \
|
||||
details=details, email_from=email_from,\
|
||||
message_id=message_id, attach=attach, \
|
||||
context=context)
|
||||
|
||||
def do_draft(self, cr, uid, ids, *args, **kwargs):
|
||||
res = super(project_tasks, self).do_draft(cr, uid, ids, *args, **kwargs)
|
||||
tasks = self.browse(cr, uid, ids)
|
||||
self._history(cr, uid, tasks, _('Draft'))
|
||||
self.history(cr, uid, tasks, _('Draft'))
|
||||
return res
|
||||
|
||||
def do_open(self, cr, uid, ids, *args, **kwargs):
|
||||
res = super(project_tasks, self).do_open(cr, uid, ids, *args, **kwargs)
|
||||
tasks = self.browse(cr, uid, ids)
|
||||
self._history(cr, uid, tasks, _('Open'))
|
||||
self.history(cr, uid, tasks, _('Open'))
|
||||
return res
|
||||
|
||||
def do_pending(self, cr, uid, ids, *args, **kwargs):
|
||||
res = super(project_tasks, self).do_pending(cr, uid, ids, *args, **kwargs)
|
||||
tasks = self.browse(cr, uid, ids)
|
||||
self._history(cr, uid, tasks, _('Pending'))
|
||||
self.history(cr, uid, tasks, _('Pending'))
|
||||
return res
|
||||
|
||||
def do_close(self, cr, uid, ids, *args, **kwargs):
|
||||
|
@ -151,13 +143,13 @@ class project_tasks(osv.osv):
|
|||
tasks = self.browse(cr, uid, ids)
|
||||
for task in tasks:
|
||||
if task.state == 'done':
|
||||
self._history(cr, uid, tasks, _('Done'))
|
||||
self.history(cr, uid, tasks, _('Done'))
|
||||
return res
|
||||
|
||||
def do_cancel(self, cr, uid, ids, *args, **kwargs):
|
||||
res = super(project_tasks, self).do_cancel(cr, uid, ids, *args, **kwargs)
|
||||
tasks = self.browse(cr, uid, ids)
|
||||
self._history(cr, uid, tasks, _('Cancel'))
|
||||
self.history(cr, uid, tasks, _('Cancel'))
|
||||
return res
|
||||
|
||||
project_tasks()
|
||||
|
|
|
@ -107,7 +107,7 @@ class crm_make_sale(osv.osv_memory):
|
|||
new_ids.append(new_id)
|
||||
message = _("Opportunity '%s' is converted to Quotation.") % (case.name)
|
||||
self.log(cr, uid, case.id, message)
|
||||
case_obj._history(cr, uid, [case], _("Converted to Sales Quotation(id: %s).") % (new_id))
|
||||
case_obj.history(cr, uid, [case], _("Converted to Sales Quotation(id: %s).") % (new_id))
|
||||
|
||||
if make.close:
|
||||
case_obj.case_close(cr, uid, data)
|
||||
|
|
|
@ -23,28 +23,6 @@ from osv import osv
|
|||
import base64
|
||||
import email
|
||||
import tools
|
||||
import binascii
|
||||
class email_thread(osv.osv):
|
||||
_inherit = "email.thread"
|
||||
def history_message(self, cr, uid, model, res_id, message, context=None):
|
||||
#@param message: string of mail which is read from EML File
|
||||
attachment_pool = self.pool.get('ir.attachment')
|
||||
email_message_pool = self.pool.get('email.message')
|
||||
msg = email_message_pool.parse_message(message)
|
||||
attachments = msg.get('attachments', [])
|
||||
att_ids = []
|
||||
for attachment in attachments:
|
||||
data_attach = {
|
||||
'name': attachment,
|
||||
'datas': binascii.b2a_base64(str(attachments.get(attachment))),
|
||||
'datas_fname': attachment,
|
||||
'description': 'Mail attachment From Thunderbird msg_id: %s' %(msg.get('message_id', '')),
|
||||
'res_model': model,
|
||||
'res_id': res_id,
|
||||
}
|
||||
att_ids.append(attachment_pool.create(cr, uid, data_attach))
|
||||
return self.history(cr, uid, model, res_id, msg, att_ids)
|
||||
email_thread()
|
||||
|
||||
class thunderbird_partner(osv.osv_memory):
|
||||
_name = "thunderbird.partner"
|
||||
|
@ -67,6 +45,7 @@ class thunderbird_partner(osv.osv_memory):
|
|||
msg = dictcreate.get('message')
|
||||
mail = msg
|
||||
msg = self.pool.get('email.message').parse_message(msg)
|
||||
subject = msg.get('Subject', False)
|
||||
thread_pool = self.pool.get('email.thread')
|
||||
message_id = msg.get('message-id', False)
|
||||
msg_pool = self.pool.get('email.message')
|
||||
|
@ -75,7 +54,6 @@ class thunderbird_partner(osv.osv_memory):
|
|||
res_ids = []
|
||||
obj_list= ['crm.lead','project.issue','hr.applicant','res.partner']
|
||||
for ref_id in ref_ids:
|
||||
msg_new = dictcreate.get('message')
|
||||
ref = ref_id.split(',')
|
||||
model = ref[0]
|
||||
res_id = int(ref[1])
|
||||
|
@ -108,7 +86,17 @@ class thunderbird_partner(osv.osv_memory):
|
|||
res['datas'] = base64.b64encode(mail)
|
||||
res['res_id'] = res_id
|
||||
obj_attch.create(cr, uid, res)
|
||||
thread_pool.history_message(cr, uid, model, res_id, msg_new)
|
||||
threads = self.pool.get(model).browse(cr, uid, res_id)
|
||||
thread_pool.history(cr, uid, [threads], _('receive'), history=True,
|
||||
subject = msg.get('subject'),
|
||||
email = msg.get('to'),
|
||||
details = msg.get('body'),
|
||||
email_from = msg.get('from'),
|
||||
email_cc = msg.get('cc'),
|
||||
message_id = msg.get('message-id'),
|
||||
references = msg.get('references', False) or msg.get('in-reply-to', False),
|
||||
attach = msg.get('attachments', {}),
|
||||
email_date = msg.get('date'))
|
||||
res_ids.append(res_id)
|
||||
return len(res_ids)
|
||||
|
||||
|
|
Loading…
Reference in New Issue