diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 8d0c295176c..21ddb8bf3bc 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -1235,43 +1235,3 @@ class crm_lost_reason(osv.Model): _defaults = { 'active': True, } - - -class crm_team(osv.Model): - _inherit = "crm.team" - def action_your_pipeline(self, cr, uid, context={}): - imd = self.pool.get('ir.actions.act_window') - imd2 = self.pool.get('ir.model.data') - action = imd.for_xml_id(cr, uid, 'crm', "crm_lead_opportunities_tree_view", context=context) - view_form = imd2.xmlid_lookup(cr, uid, 'crm.crm_case_form_view_oppor')[2] - view_tree = imd2.xmlid_lookup(cr, uid, 'crm.crm_case_tree_view_oppor')[2] - view_kanban = imd2.xmlid_lookup(cr, uid, 'crm.crm_case_kanban_view_leads')[2] - user = self.pool.get('res.users').browse(cr, uid, uid, context=context) - team_id = user.sale_team_id.id - if not team_id: - team_id = self.search(cr, uid, [], context=context, limit=1) - team_id = team_id and team_id[0] - action['help'] = """ -
Click here to add new opportunities
- Looks like you are not a member of a sales team. You should add yourself - as a member of one of the sales team. -
""" - if team_id: - action['help'] += "As you don't belong to any sales team, Odoo opens the first one by default.
" - newcontext = eval(action['context'], {'uid': uid}) - if team_id: - newcontext.update({ - 'default_team_id': team_id, - 'search_default_team_id': team_id - }) - result = { - 'name': action['name'], - 'help': action['help'], - 'type': action['type'], - 'views': [[view_kanban, 'kanban'], [view_tree, 'tree'], [view_form, 'form'], [False, 'graph'], [False, 'calendar'], [False, 'pivot']], - 'target': action['target'], - 'context': newcontext, - 'res_model': action['res_model'], - } - return result - diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index eb1b94b0614..582833f2881 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -471,39 +471,38 @@Click here to add new opportunities
+ Looks like you are not a member of a sales team. You should add yourself + as a member of one of the sales team. +
""" + if user_team_id: + action['help'] += "As you don't belong to any sales team, Odoo opens the first one by default.
" + + action_context = eval(action['context'], {'uid': uid}) + if user_team_id: + action_context.update({ + 'default_team_id': user_team_id, + 'search_default_team_id': user_team_id + }) + + tree_view_id = IrModelData.xmlid_to_res_id(cr, uid, 'crm.crm_case_tree_view_oppor') + form_view_id = IrModelData.xmlid_to_res_id(cr, uid, 'crm.crm_case_form_view_oppor') + kanb_view_id = IrModelData.xmlid_to_res_id(cr, uid, 'crm.crm_case_kanban_view_leads') + action.update({ + 'views': [ + [kanb_view_id, 'kanban'], + [tree_view_id, 'tree'], + [form_view_id, 'form'], + [False, 'graph'], + [False, 'calendar'], + [False, 'pivot'] + ], + 'context': action_context, + }) + return action