[IMP] Project issue: Improved handling of thread_model context value in message_post. Replaced a read by a browse in Project issue write

bzr revid: cbi@openerp.com-20130313083808-o75djyctnj5sgngx
This commit is contained in:
Chris Biersbach 2013-03-13 09:38:08 +01:00
parent 1e73187551
commit 31d218cc67
2 changed files with 9 additions and 7 deletions

View File

@ -925,6 +925,9 @@ class mail_thread(osv.AbstractModel):
model = False
if thread_id:
model = context.get('thread_model', self._name) if self._name == 'mail.thread' else self._name
if model != self._name:
del context['thread_model']
return self.pool.get(model).message_post(cr, uid, thread_id, body=body, subject=subject, type=type, subtype=subtype, parent_id=parent_id, attachments=attachments, context=ctx, content_subtype=content_subtype, **kwargs)
# 1: Handle content subtype: if plaintext, converto into HTML
if content_subtype == 'plaintext':

View File

@ -396,7 +396,7 @@ class project_issue(base_stage, osv.osv):
#Update last action date every time the user changes the stage
if 'stage_id' in vals:
vals['date_action_last'] = time.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)
state = self.pool.get('project.task.type').read(cr, uid, vals['stage_id'], ['state'], context=context)['state']
state = self.pool.get('project.task.type').browse(cr, uid, vals['stage_id'], context=context).state
for issue in self.browse(cr, uid, ids, context=context):
# Change from draft to not draft EXCEPT cancelled: The issue has been opened -> set the opening date
if issue.state == 'draft' and state not in ('draft', 'cancelled'):
@ -560,15 +560,14 @@ class project_issue(base_stage, osv.osv):
if context is None:
context = {}
res = super(project_issue, self).message_post(cr, uid, thread_id, body=body, subject=subject, type=type, subtype=subtype, parent_id=parent_id, attachments=attachments, context=context, content_subtype=content_subtype, **kwargs)
if thread_id:
model = context.get('thread_model', self._name)
if model != self._name:
ctx = context.copy()
del ctx['thread_model']
return self.pool.get(model).message_post(cr, uid, thread_id, body=body, subject=subject, type=type, subtype=subtype, parent_id=parent_id, attachments=attachments, context=ctx, content_subtype=content_subtype, **kwargs)
self.write(cr, uid, thread_id, {'date_action_last': time.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)}, context=context)
if model == self._name:
self.write(cr, uid, thread_id, {'date_action_last': time.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)}, context=context)
return super(project_issue, self).message_post(cr, uid, thread_id, body=body, subject=subject, type=type, subtype=subtype, parent_id=parent_id, attachments=attachments, context=context, content_subtype=content_subtype, **kwargs)
return res
class project(osv.osv):
_inherit = "project.project"