[MERGE] correction of backlog1 in message_new() and message_pdate()
bzr revid: hmo@tinyerp.com-20110420084321-npp1sat63yawcx5p
This commit is contained in:
commit
4ac2b7677d
|
@ -348,7 +348,22 @@ class crm_lead(crm_case, osv.osv):
|
|||
if res:
|
||||
vals.update(res)
|
||||
|
||||
return self.create(cr, uid, vals, context)
|
||||
res_id = self.create(cr, uid, vals, context)
|
||||
|
||||
attachments = msg.get('attachments', {})
|
||||
self.history(cr, uid, [res_id], _('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 = attachments,
|
||||
email_date = msg.get('date'),
|
||||
context = context)
|
||||
|
||||
return res_id
|
||||
|
||||
def message_update(self, cr, uid, ids, msg, vals={}, default_act='pending', context=None):
|
||||
"""
|
||||
|
@ -385,6 +400,19 @@ class crm_lead(crm_case, osv.osv):
|
|||
if case.state in CRM_LEAD_PENDING_STATES:
|
||||
values.update(state=crm.AVAILABLE_STATES[1][0]) #re-open
|
||||
res = self.write(cr, uid, [case.id], values, context=context)
|
||||
|
||||
attachments = msg.get('attachments', {})
|
||||
self.history(cr, uid, ids, _('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 = attachments,
|
||||
email_date = msg.get('date'),
|
||||
context = context)
|
||||
return res
|
||||
|
||||
def on_change_optin(self, cr, uid, ids, optin):
|
||||
|
|
|
@ -202,7 +202,22 @@ class crm_claim(crm.crm_case, osv.osv):
|
|||
if res:
|
||||
vals.update(res)
|
||||
|
||||
return self.create(cr, uid, vals, context)
|
||||
res_id = self.create(cr, uid, vals, context)
|
||||
|
||||
attachments = msg.get('attachments', {})
|
||||
self.history(cr, uid, [res_id], _('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 = attachments,
|
||||
email_date = msg.get('date'),
|
||||
context = context)
|
||||
|
||||
return res_id
|
||||
|
||||
def message_update(self, cr, uid, ids, msg, vals={}, default_act='pending', context=None):
|
||||
"""
|
||||
|
@ -239,6 +254,19 @@ class crm_claim(crm.crm_case, osv.osv):
|
|||
if case.state in CRM_CLAIM_PENDING_STATES:
|
||||
values.update(state=crm.AVAILABLE_STATES[1][0]) #re-open
|
||||
res = self.write(cr, uid, [case.id], values, context=context)
|
||||
|
||||
attachments = msg.get('attachments', {})
|
||||
self.history(cr, uid, ids, _('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 = attachments,
|
||||
email_date = msg.get('date'),
|
||||
context = context)
|
||||
return res
|
||||
|
||||
crm_claim()
|
||||
|
|
|
@ -125,7 +125,22 @@ class crm_helpdesk(crm.crm_case, osv.osv):
|
|||
if res:
|
||||
vals.update(res)
|
||||
|
||||
return self.create(cr, uid, vals, context)
|
||||
res_id = self.create(cr, uid, vals, context)
|
||||
|
||||
attachments = msg.get('attachments', {})
|
||||
self.history(cr, uid, [res_id], _('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 = attachments,
|
||||
email_date = msg.get('date'),
|
||||
context = context)
|
||||
|
||||
return res_id
|
||||
|
||||
def message_update(self, cr, uid, ids, msg, vals={}, default_act='pending', context=None):
|
||||
"""
|
||||
|
@ -162,6 +177,19 @@ class crm_helpdesk(crm.crm_case, osv.osv):
|
|||
if case.state in CRM_HELPDESK_STATES:
|
||||
values.update(state=crm.AVAILABLE_STATES[1][0]) #re-open
|
||||
res = self.write(cr, uid, [case.id], values, context=context)
|
||||
|
||||
attachments = msg.get('attachments', {})
|
||||
self.history(cr, uid, ids, _('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 = attachments,
|
||||
email_date = msg.get('date'),
|
||||
context = context)
|
||||
return res
|
||||
|
||||
crm_helpdesk()
|
||||
|
|
|
@ -325,7 +325,22 @@ class hr_applicant(crm.crm_case, osv.osv):
|
|||
res = thread_pool.get_partner(cr, uid, msg.get('from'))
|
||||
if res:
|
||||
vals.update(res)
|
||||
return self.create(cr, uid, vals, context=context)
|
||||
res_id = self.create(cr, uid, vals, context)
|
||||
|
||||
attachments = msg.get('attachments', {})
|
||||
self.history(cr, uid, [res_id], _('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 = attachments,
|
||||
email_date = msg.get('date'),
|
||||
context = context)
|
||||
|
||||
return res_id
|
||||
|
||||
def message_update(self, cr, uid, ids, msg, vals={}, default_act='pending', context=None):
|
||||
"""
|
||||
|
@ -360,6 +375,19 @@ class hr_applicant(crm.crm_case, osv.osv):
|
|||
|
||||
vals.update(vls)
|
||||
res = self.write(cr, uid, ids, vals, context=context)
|
||||
|
||||
attachments = msg.get('attachments', {})
|
||||
self.history(cr, uid, ids, _('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 = attachments,
|
||||
email_date = msg.get('date'),
|
||||
context = context)
|
||||
return res
|
||||
|
||||
def case_open(self, cr, uid, ids, *args):
|
||||
|
|
|
@ -206,6 +206,8 @@ class email_message(osv.osv):
|
|||
|
||||
def schedule_with_attach(self, cr, uid, email_from, email_to, subject, body, model=False, email_cc=None, email_bcc=None, reply_to=False, attach=None,
|
||||
message_id=False, references=False, openobject_id=False, debug=False, subtype='plain', x_headers={}, priority='3', smtp_server_id=False, context=None, auto_delete=False):
|
||||
if context is None:
|
||||
context = {}
|
||||
attachment_obj = self.pool.get('ir.attachment')
|
||||
if email_to and type(email_to) != list:
|
||||
email_to = [email_to]
|
||||
|
|
|
@ -75,14 +75,11 @@ class email_thread(osv.osv):
|
|||
if not model:
|
||||
model = self._name
|
||||
model_pool = self.pool.get(model)
|
||||
if hasattr(model_pool, 'message_new'):
|
||||
res_id = model_pool.message_new(cr, uid, msg, context)
|
||||
else:
|
||||
fields = model_pool.fields_get(cr, uid, context=context)
|
||||
data = model_pool.default_get(cr, uid, fields, context=context)
|
||||
if 'name' in fields and not data.get('name',False):
|
||||
data['name'] = msg.get('from','')
|
||||
res_id = model_pool.create(cr, uid, data, context=context)
|
||||
fields = model_pool.fields_get(cr, uid, context=context)
|
||||
data = model_pool.default_get(cr, uid, fields, context=context)
|
||||
if 'name' in fields and not data.get('name',False):
|
||||
data['name'] = msg.get('from','')
|
||||
res_id = model_pool.create(cr, uid, data, context=context)
|
||||
|
||||
attachments = msg.get('attachments', {})
|
||||
self.history(cr, uid, [res_id], _('receive'), history=True,
|
||||
|
@ -93,7 +90,7 @@ class email_thread(osv.osv):
|
|||
email_cc = msg.get('cc'),
|
||||
message_id = msg.get('message-id'),
|
||||
references = msg.get('references', False) or msg.get('in-reply-to', False),
|
||||
attach = attachments.items(),
|
||||
attach = attachments,
|
||||
email_date = msg.get('date'),
|
||||
context = context)
|
||||
return res_id
|
||||
|
@ -109,8 +106,6 @@ class email_thread(osv.osv):
|
|||
if not model:
|
||||
model = self._name
|
||||
model_pool = self.pool.get(model)
|
||||
if hasattr(model_pool, 'message_update'):
|
||||
model_pool.message_update(cr, uid, ids, msg, vals=vals, default_act=default_act, context=context)
|
||||
attachments = msg.get('attachments', {})
|
||||
self.history(cr, uid, ids, _('receive'), history=True,
|
||||
subject = msg.get('subject'),
|
||||
|
@ -120,7 +115,7 @@ class email_thread(osv.osv):
|
|||
email_cc = msg.get('cc'),
|
||||
message_id = msg.get('message-id'),
|
||||
references = msg.get('references', False) or msg.get('in-reply-to', False),
|
||||
attach = attachments.items(),
|
||||
attach = attachments,
|
||||
email_date = msg.get('date'),
|
||||
context = context)
|
||||
return True
|
||||
|
@ -161,7 +156,7 @@ class email_thread(osv.osv):
|
|||
if context is None:
|
||||
context = {}
|
||||
if attach is None:
|
||||
attach = []
|
||||
attach = {}
|
||||
|
||||
model = context.get('thread_model', False)
|
||||
if not model:
|
||||
|
@ -183,11 +178,11 @@ class email_thread(osv.osv):
|
|||
|
||||
for thread in threads:
|
||||
attachments = []
|
||||
for attachment in attach:
|
||||
for fname, fcontent in attach.items():
|
||||
data_attach = {
|
||||
'name': attachment[0],
|
||||
'datas': binascii.b2a_base64(str(attachment[1])),
|
||||
'datas_fname': attachment[0],
|
||||
'name': fname,
|
||||
'datas': binascii.b2a_base64(str(fcontent)),
|
||||
'datas_fname': fname,
|
||||
'description': _('Mail attachment'),
|
||||
'res_model': thread._name,
|
||||
'res_id': thread.id,
|
||||
|
@ -305,7 +300,6 @@ class email_thread(osv.osv):
|
|||
email_message_pool = self.pool.get('email.message')
|
||||
res_id = False
|
||||
|
||||
|
||||
# Parse Message
|
||||
# Warning: message_from_string doesn't always work correctly on unicode,
|
||||
# we must use utf-8 strings here :-(
|
||||
|
@ -316,9 +310,10 @@ class email_thread(osv.osv):
|
|||
|
||||
# Create New Record into particular model
|
||||
def create_record(msg):
|
||||
new_res_id = self.message_new(cr, uid, msg, context=context)
|
||||
if custom_values:
|
||||
model_pool.write(cr, uid, [res_id], custom_values, context=context)
|
||||
if hasattr(model_pool, 'message_new'):
|
||||
new_res_id = model_pool.message_new(cr, uid, msg, context=context)
|
||||
if custom_values:
|
||||
model_pool.write(cr, uid, [new_res_id], custom_values, context=context)
|
||||
return new_res_id
|
||||
|
||||
res_id = False
|
||||
|
@ -340,7 +335,8 @@ class email_thread(osv.osv):
|
|||
if res_id:
|
||||
res_id = int(res_id)
|
||||
if model_pool.exists(cr, uid, res_id):
|
||||
self.message_update(cr, uid, [res_id], msg, {}, context=context)
|
||||
if hasattr(model_pool, 'message_update'):
|
||||
model_pool.message_update(cr, uid, [res_id], msg, {}, context=context)
|
||||
|
||||
if not res_id:
|
||||
res_id = create_record(msg)
|
||||
|
|
|
@ -393,9 +393,23 @@ class project_issue(crm.crm_case, osv.osv):
|
|||
if res:
|
||||
vals.update(res)
|
||||
context.update({'state_to' : 'draft'})
|
||||
res = self.create(cr, uid, vals, context=context)
|
||||
self.convert_to_bug(cr, uid, [res], context=context)
|
||||
return res
|
||||
|
||||
res_id = self.create(cr, uid, vals, context)
|
||||
|
||||
attachments = msg.get('attachments', {})
|
||||
self.history(cr, uid, [res_id], _('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 = attachments,
|
||||
email_date = msg.get('date'),
|
||||
context = context)
|
||||
self.convert_to_bug(cr, uid, [res_id], context=context)
|
||||
return res_id
|
||||
|
||||
def message_update(self, cr, uid, ids, msg, vals=None, default_act='pending', context=None):
|
||||
"""
|
||||
|
@ -438,6 +452,19 @@ class project_issue(crm.crm_case, osv.osv):
|
|||
|
||||
vals.update(vls)
|
||||
res = self.write(cr, uid, ids, vals)
|
||||
|
||||
attachments = msg.get('attachments', {})
|
||||
self.history(cr, uid, ids, _('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 = attachments,
|
||||
email_date = msg.get('date'),
|
||||
context = context)
|
||||
return res
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
|
|
|
@ -52,9 +52,24 @@ class project_tasks(osv.osv):
|
|||
res = thread_obj.get_partner(cr, uid, msg_from)
|
||||
if res:
|
||||
data.update(res)
|
||||
return self.create(cr, uid, data)
|
||||
res_id = self.create(cr, uid, vals, context)
|
||||
|
||||
def message_update(self, cr, uid, id, msg, data={}, default_act='pending'):
|
||||
attachments = msg.get('attachments', {})
|
||||
self.history(cr, uid, [res_id], _('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 = attachments,
|
||||
email_date = msg.get('date'),
|
||||
context = context)
|
||||
|
||||
return res_id
|
||||
|
||||
def message_update(self, cr, uid, ids, msg, data={}, default_act='pending'):
|
||||
thread_obj = self.pool.get('email.thread')
|
||||
msg_actions, body_data = thread_obj.msg_act_get(msg)
|
||||
data.update({
|
||||
|
@ -75,8 +90,21 @@ class project_tasks(osv.osv):
|
|||
if msg_actions['priority'] in ('1','2','3','4','5'):
|
||||
data['priority'] = msg_actions['priority']
|
||||
|
||||
self.write(cr, uid, [id], data)
|
||||
getattr(self,act)(cr, uid, [id])
|
||||
self.write(cr, uid, ids, data)
|
||||
getattr(self,act)(cr, uid, ids)
|
||||
|
||||
attachments = msg.get('attachments', {})
|
||||
self.history(cr, uid, ids, _('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 = attachments,
|
||||
email_date = msg.get('date'),
|
||||
context = context)
|
||||
return True
|
||||
|
||||
def thread_followers(self, cr, uid, ids, context=None):
|
||||
|
|
Loading…
Reference in New Issue