[ADD] add suptype in task of the related project.

bzr revid: nco@tinyerp.com-20121003102718-vycgkv7y4odup01q
This commit is contained in:
Nimesh (Open ERP)
2012-10-03 15:57:18 +05:30
parent b79e554eea
commit cfbb548717
+17
View File
@@ -1097,7 +1097,16 @@ class task(base_stage, osv.osv):
def create(self, cr, uid, vals, context=None):
task_id = super(task, self).create(cr, uid, vals, context=context)
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')
if task_record.project_id:
poject_id = self.browse(cr, uid, task_id, context=context).project_id.id
pro_subtype = project_obj.browse(cr, uid, poject_id, context=context).message_subtype_data
for key in pro_subtype:
subtype_ids = subtype_obj.search(cr, uid, [('res_model', '=', self._name), ('name', '=', key)], context=context)
if subtype_ids:
for subtype_id in subtype_ids:
subtype_obj.write(cr,uid, subtype_id, {'default': pro_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,
context=context)
@@ -1110,9 +1119,17 @@ class task(base_stage, osv.osv):
def write(self, cr, uid, ids, vals, context=None):
if isinstance(ids, (int, long)):
ids = [ids]
project_obj = self.pool.get("project.project")
subtype_obj = self.pool.get('mail.message.subtype')
if vals.get('project_id'):
project_id = self.pool.get('project.project').browse(cr, uid, vals.get('project_id'), context=context)
vals['message_follower_ids'] = [(4, follower.id) for follower in project_id.message_follower_ids]
pro_subtype = project_obj.browse(cr, uid, project_id.id, context=context).message_subtype_data
for key in pro_subtype:
subtype_ids = subtype_obj.search(cr, uid, [('res_model', '=', self._name), ('name', '=', key)], context=context)
if subtype_ids:
for subtype_id in subtype_ids:
subtype_obj.write(cr,uid, subtype_id, {'default': pro_subtype[key]['default']},context=context)
if vals and not 'kanban_state' in vals and 'stage_id' in vals:
new_stage = vals.get('stage_id')
vals_reset_kstate = dict(vals, kanban_state='normal')