diff --git a/addons/analytic_contract_crm/analytic_contract_crm.py b/addons/analytic_contract_crm/analytic_contract_crm.py index 6a67319433a..fa93b7d2201 100644 --- a/addons/analytic_contract_crm/analytic_contract_crm.py +++ b/addons/analytic_contract_crm/analytic_contract_crm.py @@ -43,13 +43,14 @@ class account_analytic_account(osv.osv): def _subscribe_salesteam_followers_to_contract(self, cr, uid, obj_id, context=None): follower_obj = self.pool.get('mail.followers') subtype_obj = self.pool.get('mail.message.subtype') - record = self.browse(cr, uid, obj_id, context=context)[0] - if record.manager_id: - if record.manager_id.default_section_id: - followers = [follow.id for follow in record.manager_id.default_section_id.message_follower_ids] + record = self.browse(cr, uid, obj_id, context=context) + manager_id = record and record[0].manager_id or False + if manager_id: + if manager_id.default_section_id: + followers = [follow.id for follow in manager_id.default_section_id.message_follower_ids] contract_subtype_ids = subtype_obj.search(cr, uid, ['|', ('res_model', '=', False), ('res_model', '=', self._name)], context=context) contract_subtypes = subtype_obj.browse(cr, uid, contract_subtype_ids, context=context) - follower_ids = follower_obj.search(cr, uid, [('res_model', '=', 'crm.case.section'), ('res_id', '=', record.manager_id.default_section_id.id)], context=context) + follower_ids = follower_obj.search(cr, uid, [('res_model', '=', 'crm.case.section'), ('res_id', '=', manager_id.default_section_id.id)], context=context) self.write(cr, uid, obj_id, {'message_follower_ids': [(6, 0, followers)]}, context=context) for follower in follower_obj.browse(cr, uid, follower_ids, context=context): if not follower.subtype_ids: diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index f3530800824..e8eaca3c4a3 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -311,7 +311,8 @@ class crm_lead(base_stage, format_address, osv.osv): def _subscribe_salesteam_followers_to_lead(self, cr, uid, obj_id, context=None): follower_obj = self.pool.get('mail.followers') subtype_obj = self.pool.get('mail.message.subtype') - section_id = self.browse(cr, uid, obj_id[0], context=context).section_id + rec = self.browse(cr, uid, obj_id, context=context) + section_id = rec and rec[0].section_id or False if section_id: followers = [follow.id for follow in section_id.message_follower_ids] lead_subtype_ids = subtype_obj.search(cr, uid, ['|', ('res_model', '=', False), ('res_model', '=', self._name)], context=context) diff --git a/addons/sale_crm/sale_crm.py b/addons/sale_crm/sale_crm.py index e2e380d4ec3..75005c1f5e9 100644 --- a/addons/sale_crm/sale_crm.py +++ b/addons/sale_crm/sale_crm.py @@ -37,7 +37,8 @@ class sale_order(osv.osv): def _subscribe_salesteam_followers_to_order(self, cr, uid, order, context=None): follower_obj = self.pool.get('mail.followers') subtype_obj = self.pool.get('mail.message.subtype') - section_id = self.browse(cr, uid, order[0], context=context).section_id + rec = self.browse(cr, uid, order, context=context) + section_id = rec and rec[0].section_id or False if section_id: followers = [follow.id for follow in section_id.message_follower_ids] order_subtype_ids = subtype_obj.search(cr, uid, ['|', ('res_model', '=', False), ('res_model', '=', self._name)], context=context)