[IMP] update followers

bzr revid: fka@tinyerp.com-20121217091402-pylrooffkzykcnu9
This commit is contained in:
Foram Katharotiya (OpenERP) 2012-12-17 14:44:02 +05:30
parent 7608fe70de
commit 1f2f15c51d
5 changed files with 21 additions and 6 deletions

View File

@ -39,10 +39,14 @@ class account_analytic_account(osv.osv):
def write(self, cr, uid, ids, vals, context=None):
if isinstance(ids, (int, long)):
ids = [ids]
if vals.get('manager_id'):
section_id = self.pool.get('res.users').browse(cr, uid, vals.get('manager_id'), context=context).default_section_id
if section_id:
vals.setdefault('message_follower_ids', [])
vals['message_follower_ids'] += [(6, 0,[follower.id]) for follower in section_id.message_follower_ids]
res = super(account_analytic_account, self).write(cr, uid, ids, vals, context=context)
# subscribe new salesteam followers & subtypes to the contract
if vals.get('manager_id'):
section_id = self.pool.get('res.users').browse(cr, uid, vals.get('manager_id'), context=context).default_section_id
if section_id:
self._subscribe_followers_subtype(cr, uid, ids, section_id, 'crm.case.section', context=context)
return res

View File

@ -915,9 +915,8 @@ class crm_lead(base_stage, format_address, osv.osv):
vals['probability'] = stage.probability
if vals.get('section_id'):
section_id = self.pool.get('crm.case.section').browse(cr, uid, vals.get('section_id'), context=context)
if section_id:
vals.setdefault('message_follower_ids', [])
vals['message_follower_ids'] += [(6, 0,[follower.id]) for follower in section_id.message_follower_ids]
vals.setdefault('message_follower_ids', [])
vals['message_follower_ids'] += [(6, 0,[follower.id]) for follower in section_id.message_follower_ids]
res = super(crm_lead,self).write(cr, uid, ids, vals, context)
# subscribe new salesteam followers & subtypes to the lead
if vals.get('section_id'):

View File

@ -1122,6 +1122,11 @@ class task(base_stage, osv.osv):
def write(self, cr, uid, ids, vals, context=None):
if isinstance(ids, (int, long)):
ids = [ids]
if vals.get('project_id'):
project_id = self.pool.get('project.project').browse(cr, uid, vals.get('project_id'), context=context)
if project_id:
vals.setdefault('message_follower_ids', [])
vals['message_follower_ids'] += [(6, 0,[follower.id]) for follower in project_id.message_follower_ids]
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')

View File

@ -373,10 +373,14 @@ class project_issue(base_stage, osv.osv):
vals['date_action_last'] = time.strftime('%Y-%m-%d %H:%M:%S')
# subscribe new project followers to the issue
if vals.get('project_id'):
project_id = self.pool.get('project.project').browse(cr, uid, vals.get('project_id'), context=context)
vals.setdefault('message_follower_ids', [])
vals['message_follower_ids'] += [(6, 0,[follower.id]) for follower in project_id.message_follower_ids]
res = super(project_issue, self).write(cr, uid, ids, vals, context)
if vals.get('project_id'):
self._subscribe_followers_subtype(cr, uid, ids, vals.get('project_id'), 'project.project', context=context)
return super(project_issue, self).write(cr, uid, ids, vals, context)
return res
def onchange_task_id(self, cr, uid, ids, task_id, context=None):
if not task_id:

View File

@ -38,6 +38,9 @@ class sale_order(osv.osv):
return order
def write(self, cr, uid, ids, vals, context=None):
if vals.get('section_id'):
section_id = self.pool.get('crm.case.section').browse(cr, uid, vals.get('section_id'), context=context)
vals['message_follower_ids'] = [(6, 0, [follower.id]) for follower in section_id.message_follower_ids]
res = super(sale_order, self).write(cr, uid, ids, vals, context=context)
# subscribe new salesteam followers & subtypes to the sale order
if vals.get('section_id'):