From eba05bd705919624a15e9ec7fdfd9884803f8557 Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Tue, 16 Mar 2010 17:15:31 +0530 Subject: [PATCH] [IMP]: crm: Improvement in Opportunity schedule meeting wizard + Quality improvement bzr revid: rpa@tinyerp.com-20100316114531-ff8405ri69ciesvb --- addons/crm/__terp__.py | 2 +- addons/crm/wizard/__init__.py | 6 +- .../crm/wizard/crm_opportunity_to_meeting.py | 98 +++++++++++++++++++ ...ml => crm_opportunity_to_meeting_view.xml} | 18 +++- addons/crm/wizard/opportunity2meeting.py | 77 --------------- 5 files changed, 118 insertions(+), 83 deletions(-) create mode 100644 addons/crm/wizard/crm_opportunity_to_meeting.py rename addons/crm/wizard/{opportunity2meeting.xml => crm_opportunity_to_meeting_view.xml} (60%) delete mode 100644 addons/crm/wizard/opportunity2meeting.py diff --git a/addons/crm/__terp__.py b/addons/crm/__terp__.py index 90ba7e597bb..683d608b5c4 100644 --- a/addons/crm/__terp__.py +++ b/addons/crm/__terp__.py @@ -68,7 +68,7 @@ between mails and Open ERP.""", 'wizard/phonecall2partner_view.xml', 'wizard/phonecall2opportunity.xml', 'wizard/opportunity2partner_view.xml', - 'wizard/opportunity2meeting.xml', + 'wizard/crm_opportunity_to_meeting_view.xml', 'wizard/opportunity2phonecall.xml', 'crm_wizard.xml', 'crm_view.xml', diff --git a/addons/crm/wizard/__init__.py b/addons/crm/wizard/__init__.py index b3761eaf4b3..986b674911d 100644 --- a/addons/crm/wizard/__init__.py +++ b/addons/crm/wizard/__init__.py @@ -19,7 +19,6 @@ # ############################################################################## -import crm_opportunity_wizard import crm_phonecall_wizard import wizard_crm_send_email @@ -29,12 +28,15 @@ import wizard_history_event import crm_lead_to_partner import crm_lead_to_opportunity + +import crm_opportunity_to_meeting + import crm_phonecall2phonecall import phonecall2partner import phonecall2meeting import phonecall_to_opportunity import opportunity2partner -import opportunity2meeting + import opportunity2phonecall # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/crm/wizard/crm_opportunity_to_meeting.py b/addons/crm/wizard/crm_opportunity_to_meeting.py new file mode 100644 index 00000000000..23b8b135833 --- /dev/null +++ b/addons/crm/wizard/crm_opportunity_to_meeting.py @@ -0,0 +1,98 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import osv +from tools.translate import _ + +class crm_opportunity2meeting(osv.osv_memory): + _name = 'crm.opportunity2meeting' + _description = 'Opportunity To Meeting' + + def action_cancel(self, cr, uid, ids, context=None): + """ + Closes Opportunity to Meeting form + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of Opportunity to Meeting IDs + @param context: A standard dictionary for contextual values + + """ + return {'type': 'ir.actions.act_window_close'} + + def action_makeMeeting(self, cr, uid, ids, context=None): + """ + This opens Meeting's calendar view to schedule meeting on current Opportunity + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of Opportunity to Meeting IDs + @param context: A standard dictionary for contextual values + + @return : Dictionary value for created Meeting view + """ + value = {} + record_ids = context and context.get('active_ids', []) or [] + if record_ids: + opp_obj = self.pool.get('crm.opportunity') + data_obj = self.pool.get('ir.model.data') + + result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_meetings_filter') + res = data_obj.read(cr, uid, result, ['res_id']) + id1 = data_obj._get_id(cr, uid, 'crm', 'crm_case_calendar_view_meet') + id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_form_view_meet') + id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_tree_view_meet') + if id1: + id1 = data_obj.browse(cr, uid, id1, context=context).res_id + if id2: + id2 = data_obj.browse(cr, uid, id2, context=context).res_id + if id3: + id3 = data_obj.browse(cr, uid, id3, context=context).res_id + + for this in self.browse(cr, uid, ids, context=context): + for opp in opp_obj.browse(cr, uid, record_ids, context=context): + context = { + 'default_opportunity_id': opp.id, + 'default_partner_id': opp.partner_id and opp.partner_id.id or False, + 'default_section_id': opp.section_id and opp.section_id.id or False, + 'default_email_from': opp.email_from, + 'default_state': 'open', + 'default_name': opp.name + } + + value = { + 'name': _('Meetings'), + 'domain' : "[('user_id','=',%s)]" % (uid), + 'context': context, + 'view_type': 'form', + 'view_mode': 'calendar,form,tree', + 'res_model': 'crm.meeting', + 'view_id': False, + 'views': [(id1, 'calendar'), (id2, 'form'), (id3, 'tree')], + 'type': 'ir.actions.act_window', + 'search_view_id': res['res_id'] + } + + return value + +crm_opportunity2meeting() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/crm/wizard/opportunity2meeting.xml b/addons/crm/wizard/crm_opportunity_to_meeting_view.xml similarity index 60% rename from addons/crm/wizard/opportunity2meeting.xml rename to addons/crm/wizard/crm_opportunity_to_meeting_view.xml index a8851c53d2c..99229aa738d 100644 --- a/addons/crm/wizard/opportunity2meeting.xml +++ b/addons/crm/wizard/crm_opportunity_to_meeting_view.xml @@ -1,17 +1,28 @@ + + + crm.opportunity2meeting.form crm.opportunity2meeting form -
-