[IMP]: Improve subtype state mapping in project

bzr revid: atp@tinyerp.com-20121003180417-wi7jy1veyj5fxygl
This commit is contained in:
Atul Patel (OpenERP)
2012-10-03 23:34:17 +05:30
parent 307b705a9f
commit 74cfb3db10
2 changed files with 18 additions and 10 deletions
+2 -1
View File
@@ -1099,6 +1099,7 @@ class task(base_stage, osv.osv):
task_record = self.browse(cr, uid, task_id, context=context)
project_obj = self.pool.get("project.project")
subtype_obj = self.pool.get('mail.message.subtype')
subtype_ids = []
if task_record.project_id:
project_subtype = task_record.project_id.message_subtype_data
for key in project_subtype:
@@ -1106,7 +1107,7 @@ class task(base_stage, osv.osv):
if subtype_ids:
subtype_obj.write(cr,uid, subtype_ids, {'default': project_subtype[key]['default']},context=context)
project_follower_ids = [follower.id for follower in task_record.project_id.message_follower_ids]
self.message_subscribe(cr, uid, [task_id], project_follower_ids,
self.message_subscribe(cr, uid, [task_id], project_follower_ids, subtype_ids = subtype_ids,
context=context)
self._store_history(cr, uid, [task_id], context=context)
self.create_send_note(cr, uid, [task_id], context=context)
+16 -9
View File
@@ -363,14 +363,18 @@ class project_issue(base_stage, osv.osv):
#Update last action date every time the user change the stage, the state or send a new email
logged_fields = ['stage_id', 'state', 'message_ids']
subtype_obj = self.pool.get('mail.message.subtype')
name = False
if any([field in vals for field in logged_fields]):
vals['date_action_last'] = time.strftime('%Y-%m-%d %H:%M:%S')
if vals.get('project_id'):
project_id = self.pool.get('project.project').browse(cr, uid, vals.get('project_id'), context=context)
for key in project_id.message_subtype_data:
subtype_ids = subtype_obj.search(cr, uid, [('res_model', '=', self._name), ('name', '=', key)], context=context)
if subtype_ids:
subtype_obj.write(cr,uid, subtype_ids, {'default': project_id.message_subtype_data[key]['default']},context=context)
if key == 'New Task' and project_id.message_subtype_data[key]['default'] == True:
name = 'created'
if key == 'Task Closed' and project_id.message_subtype_data[key]['default'] == True:
name = 'closed'
subtype_ids = subtype_obj.search(cr, uid, [('res_model', '=', self._name), ('name', 'ilike', name)], context=context)
subtype_obj.write(cr,uid, subtype_ids, {'default': project_id.message_subtype_data[key]['default']},context=context)
vals['message_follower_ids'] = [(4, follower.id) for follower in project_id.message_follower_ids]
return super(project_issue, self).write(cr, uid, ids, vals, context)
@@ -392,14 +396,17 @@ class project_issue(base_stage, osv.osv):
subtype_obj = self.pool.get('mail.message.subtype')
obj_id = super(project_issue, self).create(cr, uid, vals, context=context)
project_id = self.browse(cr, uid, obj_id, context=context).project_id
project_subtype = project_id.message_subtype_data
for key in project_subtype:
subtype_ids = subtype_obj.search(cr, uid, [('res_model', '=', self._name), ('name', 'ilike', key)], context=context)
if subtype_ids:
subtype_obj.write(cr,uid, subtype_ids, {'default': project_subtype[key]['default']},context=context)
name = False
if project_id:
for key in project_id.message_subtype_data:
if key == 'New Task' and project_id.message_subtype_data[key]['default'] == True:
name = 'created'
if key == 'Task Closed' and project_id.message_subtype_data[key]['default'] == True:
name = 'closed'
subtype_ids = subtype_obj.search(cr, uid, [('res_model', '=', self._name), ('name', 'ilike', name)], context=context)
subtype_obj.write(cr,uid, subtype_ids, {'default': project_id.message_subtype_data[key]['default']},context=context)
followers = [follower.id for follower in project_id.message_follower_ids]
self.message_subscribe(cr, uid, [obj_id], followers, context=context)
self.message_subscribe(cr, uid, [obj_id], followers, subtype_ids= subtype_ids, context=context)
self.create_send_note(cr, uid, [obj_id], context=context)
return obj_id