[REM]: crm: Removed crm lead and crm opportunity model from crm (Made new module for crm lead and opportunity).

bzr revid: atp@tinyerp.co.in-20100427154616-ztpe1nzygskuqpxe
This commit is contained in:
atp (Open ERP)
2010-04-27 21:16:16 +05:30
parent 6bad2cd526
commit 3bd30dddb3
28 changed files with 12 additions and 3104 deletions
-2
View File
@@ -24,8 +24,6 @@ import crm_mailgate
import crm_action_rule
import crm_segmentation
import crm_meeting
import crm_opportunity
import crm_lead
import crm_phonecall
import crm_claim
import crm_fundraising
+10 -55
View File
@@ -54,78 +54,33 @@ between mails and Open ERP.""",
],
'init_xml': [
'crm_data.xml',
'crm_meeting_data.xml',
'crm_claims_data.xml',
'crm_fund_data.xml',
'crm_helpdesk_data.xml',
'crm_lead_data.xml',
'crm_meeting_data.xml',
'crm_opportunity_data.xml',
'crm_phonecall_data.xml',
],
'update_xml': [
'wizard/crm_lead_to_partner_view.xml',
'wizard/crm_lead_to_opportunity_view.xml',
'wizard/crm_phonecall_to_phonecall_view.xml',
'wizard/crm_phonecall_to_partner_view.xml',
'wizard/crm_phonecall_to_opportunity_view.xml',
'wizard/crm_opportunity_to_phonecall_view.xml',
'wizard/crm_partner_to_opportunity_view.xml',
'wizard/crm_send_email_view.xml',
'wizard/crm_email_add_cc_view.xml',
'crm_view.xml',
'crm_action_rule_view.xml',
'crm_lead_view.xml',
'crm_lead_menu.xml',
'crm_meeting_view.xml',
'crm_meeting_menu.xml',
'crm_phonecall_view.xml',
'crm_phonecall_menu.xml',
'crm_opportunity_view.xml',
'crm_opportunity_menu.xml',
'crm_fund_view.xml',
'crm_fund_menu.xml',
'crm_claims_view.xml',
'crm_claims_menu.xml',
'crm_helpdesk_view.xml',
'crm_helpdesk_menu.xml',
'security/crm_security.xml',
'security/ir.model.access.csv',
'report/crm_report_view.xml',
'report/crm_claim_report_view.xml',
'report/crm_lead_report_view.xml',
'report/crm_fundraising_report_view.xml',
'report/crm_opportunity_report_view.xml' ,
'report/crm_phonecall_report_view.xml',
'process/crm_configuration_process.xml',
],
'demo_xml': [
'test/test_crm_meeting.yml',
'crm_demo.xml',
'crm_claims_demo.xml',
'crm_fund_demo.xml',
'crm_helpdesk_demo.xml',
'crm_lead_demo.xml',
'crm_meeting_demo.xml',
'crm_opportunity_demo.xml',
'crm_phonecall_demo.xml'
],
'test': ['test/test_crm_lead.yml',
'test/test_crm_opportunity.yml',
'test/test_crm_phonecall.yml',
'test/test_crm_fund.yml',
'test/test_crm_claim.yml',
'test/test_crm_helpdesk.yml',
],
# 'test': [#'test/test_crm_lead.yml',
# 'test/test_crm_opportunity.yml',
# 'test/test_crm_phonecall.yml',
# 'test/test_crm_fund.yml',
# 'test/test_crm_claim.yml',
# 'test/test_crm_helpdesk.yml',
# 'test/test_crm_meeting.yml',
# ],
'installable': True,
'active': False,
'certificate': '0079056041421',
-198
View File
@@ -1,198 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv, orm
from datetime import datetime, timedelta
import crm
import math
import time
import mx.DateTime
from tools.translate import _
class crm_lead(osv.osv):
""" CRM Lead Case """
_name = "crm.lead"
_description = "Leads Cases"
_order = "priority, id desc"
_inherit = ['res.partner.address', 'crm.case']
def case_open(self, cr, uid, ids, *args):
"""
@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 case's Ids
@param *args: Give Tuple Value
"""
res = super(crm_lead, self).case_open(cr, uid, ids, *args)
self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S')})
return res
def _compute_day(self, cr, uid, ids, fields, args, context={}):
"""
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Openday’s IDs
@return: difference between current date and log date
@param context: A standard dictionary for contextual values
"""
cal_obj = self.pool.get('resource.calendar')
res_obj = self.pool.get('resource.resource')
res = {}
for lead in self.browse(cr, uid, ids , context):
for field in fields:
res[lead.id] = {}
duration = 0
ans = False
if field == 'day_open':
if lead.date_open:
date_create = datetime.strptime(lead.create_date, "%Y-%m-%d %H:%M:%S")
date_open = datetime.strptime(lead.date_open, "%Y-%m-%d %H:%M:%S")
ans = date_open - date_create
date_until = lead.date_open
elif field == 'day_close':
if lead.date_closed:
date_create = datetime.strptime(lead.create_date, "%Y-%m-%d %H:%M:%S")
date_close = datetime.strptime(lead.date_closed, "%Y-%m-%d %H:%M:%S")
date_until = lead.date_closed
ans = date_close - date_create
if ans:
resource_id = False
if lead.user_id:
resource_ids = res_obj.search(cr, uid, [('user_id','=',lead.user_id.id)])
if len(resource_ids):
resource_id = resource_ids[0]
duration = float(ans.days)
if lead.section_id.resource_calendar_id:
duration = float(ans.days) * 24
new_dates = cal_obj.interval_get(cr,
uid,
lead.section_id.resource_calendar_id and lead.section_id.resource_calendar_id.id or False,
mx.DateTime.strptime(lead.create_date, '%Y-%m-%d %H:%M:%S'),
duration,
resource=resource_id
)
no_days = []
date_until = mx.DateTime.strptime(date_until, '%Y-%m-%d %H:%M:%S')
for in_time, out_time in new_dates:
if in_time.date not in no_days:
no_days.append(in_time.date)
if out_time > date_until:
break
duration = len(no_days)
res[lead.id][field] = abs(int(duration))
return res
_columns = {
'categ_id': fields.many2one('crm.case.categ', 'Lead Source', \
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.opportunity')]"),
'type_id': fields.many2one('crm.case.resource.type', 'Lead Type', \
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.lead')]"),
'partner_name': fields.char("Contact Name", size=64),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'date_closed': fields.datetime('Closed', readonly=True),
'stage_id': fields.many2one('crm.case.stage', 'Stage', \
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.lead')]"),
'opportunity_id': fields.many2one('crm.opportunity', 'Opportunity'),
'user_id': fields.many2one('res.users', 'Salesman'),
'referred': fields.char('Referred By', size=64),
'date_open': fields.datetime('Opened', readonly=True),
'day_open': fields.function(_compute_day, string='Days to Open', \
method=True, multi='day_open', type="float", store=True),
'day_close': fields.function(_compute_day, string='Days to Close', \
method=True, multi='day_close', type="float", store=True),
'function_name': fields.char('Function', size=64),
}
_defaults = {
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.lead', context=c),
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
}
def convert_opportunity(self, cr, uid, ids, context=None):
""" Precomputation for converting lead to opportunity
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of closeday’s IDs
@param context: A standard dictionary for contextual values
@return: Value of action in dict
"""
if not context:
context = {}
context.update({'active_ids': ids})
data_obj = self.pool.get('ir.model.data')
data_id = data_obj._get_id(cr, uid, 'crm', 'view_crm_lead2opportunity_create')
value = {}
view_id = False
if data_id:
view_id = data_obj.browse(cr, uid, data_id, context=context).res_id
for case in self.browse(cr, uid, ids):
context.update({'opportunity_id': case.id})
context.update({'active_id': case.id})
if not case.partner_id:
data_id = data_obj._get_id(cr, uid, 'crm', 'view_crm_lead2opportunity_partner')
view_id1 = False
if data_id:
view_id1 = data_obj.browse(cr, uid, data_id, context=context).res_id
value = {
'name': _('Create Partner'),
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'crm.lead2opportunity.partner',
'view_id': False,
'context': context,
'views': [(view_id1, 'form')],
'type': 'ir.actions.act_window',
'target': 'new',
'nodestroy': True
}
break
else:
value = {
'name': _('Create Opportunity'),
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'crm.lead2opportunity',
'view_id': False,
'context': context,
'views': [(view_id, 'form')],
'type': 'ir.actions.act_window',
'target': 'new',
'nodestroy': True
}
return value
crm_lead()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-81
View File
@@ -1,81 +0,0 @@
<?xml version="1.0"?>
<openerp>
<data noupdate="1">
<!-- CASE STATUS(stage_id) -->
<record model="crm.case.stage" id="stage_lead1">
<field name="name">New</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_lead2">
<field name="name">Assigned</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_lead3">
<field name="name">In Process</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_lead4">
<field name="name">Converted</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_lead5">
<field name="name">Recycled</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_lead6">
<field name="name">Dead</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<!-- CASE CATEGORY2(category2_id) -->
<record model="crm.case.resource.type" id="type_lead1">
<field name="name">Telesales</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.resource.type" id="type_lead2">
<field name="name">Mail</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.resource.type" id="type_lead3">
<field name="name">Email</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.resource.type" id="type_lead4">
<field name="name">Print</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.resource.type" id="type_lead5">
<field name="name">Web</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.resource.type" id="type_lead6">
<field name="name">Radio</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.resource.type" id="type_lead7">
<field name="name">Television</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.resource.type" id="type_lead8">
<field name="name">Newsletter</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
</data>
</openerp>
-112
View File
@@ -1,112 +0,0 @@
<?xml version="1.0"?>
<openerp>
<data noupdate="1">
<!--
((((((((((( Demo Cases )))))))))))
-->
<!--For Leads-->
<record id="crm_case_itisatelesalescampaign0" model="crm.lead">
<field name="type_id" ref="crm.type_lead1"/>
<field eval="'3'" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="'Luc Latour'" name="name"/>
<field eval="'open'" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'(726) 782-0636'" name="mobile"/>
<field eval="1" name="active"/>
<field name="categ_id" ref="crm.categ_oppor6"/>
<field name="stage_id" ref="crm.stage_lead1"/>
<field eval="'The Oil Company'" name="partner_name"/>
<field eval="'(769) 703-274'" name="phone"/>
</record>
<record id="crm_case_electonicgoodsdealer0" model="crm.lead">
<field name="type_id" ref="crm.type_lead7"/>
<field eval="'4'" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="'Marc Dufour'" name="name"/>
<field eval="'open'" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'(392) 895-7917'" name="mobile"/>
<field eval="1" name="active"/>
<field name="categ_id" ref="crm.categ_oppor2"/>
<field name="stage_id" ref="crm.stage_lead2"/>
<field eval="'Le Club SARL'" name="partner_name"/>
<field eval="'(956) 293-2595'" name="phone"/>
</record>
<record id="crm_case_developingwebapplications0" model="crm.lead">
<field name="type_id" ref="crm.type_lead5"/>
<field eval="'2'" name="priority"/>
<field name="user_id" ref="base.user_demo"/>
<field eval="'Fabien Pinckaers'" name="name"/>
<field eval="'done'" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'(820) 167-3208'" name="mobile"/>
<field eval="1" name="active"/>
<field name="categ_id" ref="crm.categ_oppor4"/>
<field name="stage_id" ref="crm.stage_lead4"/>
<field eval="'TheKompany'" name="partner_name"/>
<field eval="'(079) 681-2139'" name="phone"/>
<field eval="'contact@tecsas.fr'" name="email_from"/>
</record>
<record id="crm_case_qrecorp0" model="crm.lead">
<field name="type_id" ref="crm.type_lead8"/>
<field eval="'3'" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="'Henry Mc Coy'" name="name"/>
<field eval="'draft'" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'(077) 582-4035'" name="mobile"/>
<field eval="1" name="active"/>
<field name="categ_id" ref="crm.categ_oppor1"/>
<field name="stage_id" ref="crm.stage_lead1"/>
<field eval="'The Gas Company'" name="partner_name"/>
<field eval="'(514) 698-4118'" name="phone"/>
</record>
<record id="crm_case_itdeveloper0" model="crm.lead">
<field name="type_id" ref="crm.type_lead4"/>
<field eval="'3'" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="'Carrie Helle'" name="name"/>
<field eval="'pending'" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'(333) 715-1450'" name="mobile"/>
<field eval="1" name="active"/>
<field name="categ_id" ref="crm.categ_oppor6"/>
<field name="stage_id" ref="crm.stage_lead3"/>
<field eval="'Stonage IT'" name="partner_name"/>
<field eval="'(855) 924-4364'" name="phone"/>
</record>
<record id="crm_case_mgroperations0" model="crm.lead">
<field name="partner_address_id" ref="base.res_partner_address_1"/>
<field eval="1" name="active"/>
<field name="type_id" ref="crm.type_lead3"/>
<field name="partner_id" ref="base.res_partner_9"/>
<field eval="'3'" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="'Tina Pinero'" name="name"/>
<field eval="'cancel'" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'(468) 017-2684'" name="mobile"/>
<field name="categ_id" ref="crm.categ_oppor8"/>
<field name="stage_id" ref="crm.stage_lead6"/>
<field eval="'Opensides SPRL'" name="partner_name"/>
<field eval="'(373) 907-1009'" name="phone"/>
<field eval="'info@opensides.be'" name="email_from"/>
</record>
<record id="crm_case_vpoperations0" model="crm.lead">
<field eval="1" name="active"/>
<field name="type_id" ref="crm.type_lead8"/>
<field eval="'3'" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="'Wendi Baltz'" name="name"/>
<field eval="'done'" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'(463) 014-1208'" name="mobile"/>
<field name="categ_id" ref="crm.categ_oppor4"/>
<field name="stage_id" ref="crm.stage_lead4"/>
<field eval="'Gardner Group'" name="partner_name"/>
<field eval="'(282) 603-7489'" name="phone"/>
</record>
</data>
</openerp>
-33
View File
@@ -1,33 +0,0 @@
<?xml version="1.0"?>
<openerp>
<data noupdate="1">
<record model="ir.actions.act_window" id="crm_case_category_act_leads_all">
<field name="name">Leads</field>
<field name="res_model">crm.lead</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="crm_case_tree_view_leads"/>
<field name="search_view_id" ref="crm.view_crm_case_leads_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_tree_view_leads_all">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="crm_case_tree_view_leads"/>
<field name="act_window_id" ref="crm_case_category_act_leads_all"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_form_view_leads_all">
<field name="sequence" eval="3"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_case_form_view_leads"/>
<field name="act_window_id" ref="crm_case_category_act_leads_all"/>
</record>
<menuitem id="base.menu_sales" name="Sales"
parent="base.menu_base_partner" sequence="1" />
<menuitem parent="base.menu_sales" name="Leads"
groups="base.group_extended"
id="menu_crm_case_categ0_act_leads"
action="crm_case_category_act_leads_all" sequence="1" />
</data>
</openerp>
-331
View File
@@ -1,331 +0,0 @@
<?xml version="1.0"?>
<openerp>
<data>
<!--Lead Stage Form view -->
<record id="crm_lead_stage_act" model="ir.actions.act_window">
<field name="name">Lead Stages</field>
<field name="res_model">crm.case.stage</field>
<field name="view_type">form</field>
<field name="view_id" ref="crm.crm_case_stage_tree"/>
<field name="domain">[('object_id.model', '=', 'crm.lead')]</field>
<field name="context">{'object_id':'crm.lead'}</field>
</record>
<menuitem action="crm_lead_stage_act" id="menu_crm_lead_stage_act"
groups="base.group_extended"
parent="crm.menu_crm_case_stage" />
<!-- Resource Type Form View -->
<record id="crm_lead_resource_act" model="ir.actions.act_window">
<field name="name">Lead Resource Type</field>
<field name="res_model">crm.case.resource.type</field>
<field name="view_type">form</field>
<field name="view_id" ref="crm.crm_case_resource_type_tree"/>
<field name="domain">[('object_id.model', '=', 'crm.lead')]</field>
<field name="context">{'object_id':'crm.lead'}</field>
</record>
<menuitem action="crm_lead_resource_act"
id="menu_crm_lead_resource_act"
groups="base.group_extended"
parent="crm.menu_crm_case_resource_type" />
<!-- CRM Lead Form View -->
<record model="ir.ui.view" id="crm_case_form_view_leads">
<field name="name">CRM - Leads Form</field>
<field name="model">crm.lead</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Leads Form">
<group colspan="4" col="7">
<field name="name" required="1"/>
<field name="priority"/>
<field name="date_deadline"/>
<button
name="convert_opportunity"
string="Convert"
help="Convert to Opportunity"
icon="gtk-index"
type="object"
attrs="{'invisible':[('opportunity_id','!=',False)]}"/>
<newline />
<field name="section_id" colspan="1"
widget="selection" />
<field name="user_id" />
<field name="stage_id" widget="selection"
domain="[('object_id.model', '=', 'crm.lead')]" />
<group col="2" colspan="1">
<button name="stage_previous" string="Previous"
states="open,pending" type="object"
icon="gtk-go-back" />
<button name="stage_next" string="Next"
states="open,pending" type="object"
icon="gtk-go-forward" />
</group>
</group>
<notebook colspan="4">
<page string="Lead">
<group colspan="2" col="4">
<separator string="Contact" colspan="4" col="4"/>
<field name="partner_name" string="Contact Name" colspan="4"/>
<newline/>
<field domain="[('domain', '=', 'contact')]" name="title"/>
<field name="function_name" />
<field name="street" colspan="4"/>
<field name="street2" colspan="4"/>
<field name="zip"/>
<field name="city"/>
<field name="country_id"/>
<field name="state_id"/>
</group>
<group colspan="2" col="3">
<separator string="Communication" colspan="4" col="3"/>
<field name="email_from" widget="email"/>
<newline/>
<field name="phone"/>
<newline/>
<field name="fax"/>
<newline/>
<field name="mobile"/>
<newline/>
<separator string="Links" colspan="4" col="3"/>
<field name="partner_id"/>
<button
name="%(action_crm_lead2partner)d"
icon="gtk-index" type="action"
string="Create"
attrs="{'invisible':[('partner_id','!=',False)]}"/>
<field name="opportunity_id"/>
</group>
<separator colspan="4" string="Notes"/>
<field name="description" nolabel="1" colspan="4"/>
<separator colspan="4"/>
<group col="8" colspan="4">
<field name="state"/>
<button name="case_close" string="Close"
states="open,draft,pending" type="object"
icon="gtk-close" />
<button name="case_open" string="Open"
states="draft,pending" type="object"
icon="gtk-go-forward" />
<button name="case_cancel" string="Cancel"
states="draft,open,pending" type="object"
icon="gtk-cancel" />
<button name="case_pending" string="Pending"
states="draft,open" type="object"
icon="gtk-media-pause" />
<button name="case_escalate" string="Escalate"
states="open,draft,pending" type="object"
groups="base.group_extended"
icon="gtk-go-up" />
<button name="case_reset"
string="Reset to Draft" states="done,cancel"
type="object" icon="gtk-convert" />
</group>
</page>
<page string="Extra Info" groups="base.group_extended">
<group colspan="2" col="2">
<separator string="Categories" colspan="2" col="2"/>
<field name="company_id"
groups="base.group_multi_company"
widget="selection" colspan="2" />
<field name="categ_id"
widget="selection"
domain="[('object_id.model', '=', 'crm.opportunity')]" />
<field name="type_id" string="Campaign" select="1"/>
<field name="referred"/>
</group>
<group colspan="2" col="2">
<separator string="Dates" colspan="2" col="2"/>
<field name="create_date"/>
<field name="write_date"/>
<field name="date_closed"/>
<field name="date_open"/>
</group>
<group colspan="2" col="2">
<separator string="Statistics" colspan="2" col="2"/>
<field name="day_open"/>
<field name="day_close"/>
</group>
</page>
<page string="Emails" groups="base.group_extended">
<group colspan="4">
<field colspan="4" name="email_cc" string="CC"/>
</group>
<field name="history_line" colspan="4" nolabel="1" mode="form,tree">
<form string="Communication history">
<group col="7" colspan="4">
<field name="date"/>
<field name="email_to"/>
<field name="email_from"/>
<button
string="Add a CC"
name="%(crm.action_view_crm_email_add_cc_wizard)d"
icon="gtk-add" type="action"/>
</group>
<newline/>
<field name="description" colspan="4" nolabel="1"/>
<button colspan="4"
string="Reply to Last Email"
name="%(action_crm_send_mail)d"
context="{'mail':'reply', 'model': 'crm.lead', 'include_original' : True}"
icon="gtk-undo" type="action" />
</form>
<tree string="Communication history">
<field name="description"/>
<field name="email_to"/>
<field name="date"/>
</tree>
</field>
<button colspan="4" string="Send New Email"
name="%(action_crm_send_mail)d"
context="{'mail':'new', 'model': 'crm.lead'}"
icon="gtk-go-forward" type="action" />
</page>
</notebook>
</form>
</field>
</record>
<!-- CRM Lead Tree View -->
<record model="ir.ui.view" id="crm_case_tree_view_leads">
<field name="name">CRM - Leads Tree</field>
<field name="model">crm.lead</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Leads Tree" colors="blue:state=='pending';grey:state in ('cancel', 'done')">
<field name="create_date"/>
<field name="partner_name"/>
<field name="name"/>
<field name="email_from"/>
<field name="phone"/>
<field name="categ_id" invisible="1"/>
<field name="type_id" invisible="1"/>
<field name="referred" invisible="1"/>
<field name="stage_id"/>
<button name="stage_previous" string="Previous"
states="open,pending" type="object" icon="gtk-go-back" />
<button name="stage_next" string="Next"
states="open,pending" type="object"
icon="gtk-go-forward" />
<field name="section_id"
invisible="context.get('invisible_section', True)" />
<field name="user_id" />
<field name="state" />
<button name="case_open" string="Open"
states="draft,pending" type="object"
icon="gtk-go-forward" />
<button name="case_close" string="Close"
states="open,draft,pending" type="object"
icon="gtk-close" />
<button string="Convert to Opportunity"
name="convert_opportunity"
states="draft,open,pending" icon="gtk-index"
type="object" />
<button name="case_escalate" string="Escalate"
states="open,draft,pending" type="object"
icon="gtk-go-up" />
<button name="case_cancel" string="Cancel"
states="draft,open,pending" type="object"
icon="gtk-cancel" />
</tree>
</field>
</record>
<!-- CRM Lead Calendar View -->
<record model="ir.ui.view" id="crm_case_calendar_view_leads">
<field name="name">CRM - Leads Calendar</field>
<field name="model">crm.lead</field>
<field name="type">calendar</field>
<field name="priority" eval="2"/>
<field name="arch" type="xml">
<calendar string="Meeting For Leads Generation"
date_start="create_date" color="user_id"
date_delay="duration">
<field name="name" />
<field name="partner_name" />
<field name="partner_contact" />
</calendar>
</field>
</record>
<!-- CRM Lead Search View -->
<record id="view_crm_case_leads_filter" model="ir.ui.view">
<field name="name">CRM - Leads Search</field>
<field name="model">crm.lead</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search Leads">
<filter icon="terp-project"
string="Current"
default="1"
domain="[('state','in',('draft','open'))]"/>
<filter icon="terp-project"
string="Open"
domain="[('state','=','open')]"/>
<filter icon="terp-project"
string="Pending"
domain="[('state','=','pending')]"/>
<separator orientation="vertical"/>
<filter icon="gtk-home" string="Today"
domain="[('create_date','&lt;', time.strftime('%%Y-%%m-%%d 23:59:59')), \
('create_date','&gt;=', time.strftime('%%Y-%%m-%%d 23:59:59'))]"
help="Todays' Opportunities" />
<filter icon="gtk-media-rewind" string="7 Days"
help="Opportunities during last 7 days"
domain="[('create_date','&lt;', time.strftime('%%Y-%%m-%%d')),\
('create_date','&gt;=',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
/>
<separator orientation="vertical"/>
<field name="partner_name"/>
<field name="email_from"/>
<field name="user_id" widget="selection">
<filter icon="terp-partner"
domain="[('user_id','=',uid)]"
help="My Leads" default="1"
/>
<filter icon="terp-partner"
domain="[('user_id','=', False)]"
help="Unassigned Leads" />
</field>
<field name="section_id" default="context.get('section_id', False)" widget="selection"
context="{'invisible_section': False}">
<filter icon="terp-crm"
context="{'invisible_section': False}"
domain="[('section_id.user_id','=',uid)]"
help="My section"/>
<filter icon="terp-crm"
context="{'invisible_section': False}"
domain="[]"
help="Show Sales Team"/>
</field>
<newline/>
<group expand="1" string="Group By..." colspan="14">
<filter string="Stage" icon="terp-crm" domain="[]" context="{'group_by':'stage_id'}"/>
<filter string="State" icon="terp-crm" domain="[]" context="{'group_by':'state'}"/>
<filter string="Source" icon="terp-crm" domain="[]" context="{'group_by':'categ_id'}"/>
<filter string="Type" icon="terp-crm" domain="[]" context="{'group_by':'type'}"/>
<separator orientation="vertical"/>
<filter string="Team" icon="terp-crm" domain="[]" context="{'group_by':'section_id'}"/>
<filter string="Salesman" icon="terp-crm" domain="[]" context="{'group_by':'user_id'}"/>
<filter string="Referrer" icon="terp-crm" domain="[]" context="{'group_by':'referred'}"/>
<separator orientation="vertical"/>
<filter string="Creation" icon="terp-project"
domain="[]" context="{'group_by':'create_date'}" />
</group>
</search>
</field>
</record>
</data>
</openerp>
-249
View File
@@ -1,249 +0,0 @@
#-*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from datetime import datetime
from osv import fields,osv,orm
from tools.translate import _
import crm
import time
import mx.DateTime
AVAILABLE_STATES = [
('draft','Draft'),
('open','Open'),
('cancel', 'Lost'),
('done', 'Converted'),
('pending','Pending')
]
class crm_opportunity(osv.osv):
""" Opportunity Cases """
_name = "crm.opportunity"
_description = "Opportunity Cases"
_order = "priority,date_action,id desc"
_inherit = 'crm.case'
def case_open(self, cr, uid, ids, *args):
"""
@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 case's Ids
@param *args: Give Tuple Value
"""
res = super(crm_opportunity, self).case_open(cr, uid, ids, *args)
self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S')})
return res
def _compute_day(self, cr, uid, ids, fields, args, context={}):
"""
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Openday’s IDs
@return: difference between current date and log date
@param context: A standard dictionary for contextual values
"""
cal_obj = self.pool.get('resource.calendar')
res_obj = self.pool.get('resource.resource')
res = {}
for opportunity in self.browse(cr, uid, ids , context):
for field in fields:
res[opportunity.id] = {}
duration = 0
ans = False
if field == 'day_open':
if opportunity.date_open:
date_create = datetime.strptime(opportunity.create_date, "%Y-%m-%d %H:%M:%S")
date_open = datetime.strptime(opportunity.date_open, "%Y-%m-%d %H:%M:%S")
ans = date_open - date_create
date_until = opportunity.date_open
elif field == 'day_close':
if opportunity.date_closed:
date_create = datetime.strptime(opportunity.create_date, "%Y-%m-%d %H:%M:%S")
date_close = datetime.strptime(opportunity.date_closed, "%Y-%m-%d %H:%M:%S")
date_until = opportunity.date_closed
ans = date_close - date_create
if ans:
resource_id = False
if opportunity.user_id:
resource_ids = res_obj.search(cr, uid, [('user_id','=',opportunity.user_id.id)])
if resource_ids and len(resource_ids):
resource_id = resource_ids[0]
duration = float(ans.days)
if opportunity.section_id.resource_calendar_id:
duration = float(ans.days) * 24
new_dates = cal_obj.interval_get(cr,
uid,
opportunity.section_id.resource_calendar_id and opportunity.section_id.resource_calendar_id.id or False,
mx.DateTime.strptime(opportunity.create_date, '%Y-%m-%d %H:%M:%S'),
duration,
resource=resource_id
)
no_days = []
date_until = mx.DateTime.strptime(date_until, '%Y-%m-%d %H:%M:%S')
for in_time, out_time in new_dates:
if in_time.date not in no_days:
no_days.append(in_time.date)
if out_time > date_until:
break
duration = len(no_days)
res[opportunity.id][field] = abs(int(duration))
return res
_columns = {
'stage_id': fields.many2one ('crm.case.stage', 'Stage', \
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.opportunity')]"),
'categ_id': fields.many2one('crm.case.categ', 'Category', \
domain="[('section_id','=',section_id), \
('object_id.model', '=', 'crm.opportunity')]"),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'referred': fields.char('Referred By', size=64),
'probability': fields.float('Probability (%)'),
'planned_revenue': fields.float('Expected Revenue'),
'ref': fields.reference('Reference', selection=crm._links_get, size=128),
'ref2': fields.reference('Reference 2', selection=crm._links_get, size=128),
'date_closed': fields.datetime('Closed', readonly=True),
'user_id': fields.many2one('res.users', 'Salesman'),
'phone': fields.char("Phone", size=64),
'date_deadline': fields.date('Expected Closing'),
'date_action': fields.date('Next Action'),
'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True,
help='The state is set to \'Draft\', when a case is created.\
\nIf the case is in progress the state is set to \'Open\'.\
\nWhen the case is over, the state is set to \'Done\'.\
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
'date_open': fields.datetime('Opened', readonly=True),
'day_open': fields.function(_compute_day, string='Days to Open', \
method=True, multi='day_open', type="float", store=True),
'day_close': fields.function(_compute_day, string='Days to Close', \
method=True, multi='day_close', type="float", store=True),
}
def onchange_stage_id(self, cr, uid, ids, stage_id, context={}):
""" @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 stage’s IDs
@stage_id: change state id on run time """
if not stage_id:
return {'value':{}}
stage = self.pool.get('crm.case.stage').browse(cr, uid, stage_id, context)
if not stage.on_change:
return {'value':{}}
return {'value':{'probability':stage.probability}}
def stage_next(self, cr, uid, ids, context={}):
""" @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 stage next’s IDs
@param context: A standard dictionary for contextual values """
res = super(crm_opportunity, self).stage_next(cr, uid, ids, context=context)
for case in self.browse(cr, uid, ids, context):
if case.stage_id and case.stage_id.on_change:
self.write(cr, uid, [case.id], {'probability': case.stage_id.probability})
return res
def stage_previous(self, cr, uid, ids, context={}):
""" @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 stage previous’s IDs
@param context: A standard dictionary for contextual values """
res = super(crm_opportunity, self).stage_previous(cr, uid, ids, context=context)
for case in self.browse(cr, uid, ids, context):
if case.stage_id and case.stage_id.on_change:
self.write(cr, uid, [case.id], {'probability': case.stage_id.probability})
return res
_defaults = {
'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.opportunity', context=c),
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
'state' : 'draft',
}
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 = {}
for opp in self.browse(cr, uid, ids):
data_obj = self.pool.get('ir.model.data')
# Get meeting views
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
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'],
'nodestroy': True
}
return value
crm_opportunity()
-95
View File
@@ -1,95 +0,0 @@
<?xml version="1.0"?>
<openerp>
<data noupdate="1">
<record model="crm.case.categ" id="categ_oppor1">
<field name="name">Existing Customer</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.categ" id="categ_oppor2">
<field name="name">Self Generated</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.categ" id="categ_oppor3">
<field name="name">Employee</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.categ" id="categ_oppor4">
<field name="name">Partner</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.categ" id="categ_oppor5">
<field name="name">Campaign</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.categ" id="categ_oppor6">
<field name="name">Website</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.categ" id="categ_oppor7">
<field name="name">Word of mouth</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.categ" id="categ_oppor8">
<field name="name">Other</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<!-- CASE STATUS(stage_id) -->
<record model="crm.case.stage" id="stage_oppor1">
<field name="name">Prospecting</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_oppor2">
<field name="name">Needs Analysis</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_oppor3">
<field name="name">Value Proposition</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_oppor4">
<field name="name">Proposal/Price Quote</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_oppor5">
<field name="name">Negotiation/Review</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_oppor6">
<field name="name">Closed Won</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_oppor7">
<field name="name">Closed Lost</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<!-- Case Resource(type_id) -->
<record model="crm.case.resource.type" id="type_oppor1">
<field name="name">Existing Business</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.resource.type" id="type_oppor2">
<field name="name">New Business</field>
<field name="section_id" ref="section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
</data>
</openerp>
-88
View File
@@ -1,88 +0,0 @@
<?xml version="1.0"?>
<openerp>
<data noupdate="1">
<!--
((((((((((( Demo Cases )))))))))))
-->
<!--For Opportunity-->
<record id="crm_case_construstazunits0" model="crm.opportunity">
<field eval="60" name="probability"/>
<field name="partner_address_id" ref="base.res_partner_address_zen"/>
<field eval="1" name="active"/>
<field name="type_id" ref="crm.type_oppor1"/>
<field name="partner_id" ref="base.res_partner_3"/>
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="&quot;open&quot;" name="state"/>
<field eval="85000.0" name="planned_revenue"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="categ_id" ref="crm.categ_oppor1"/>
<field name="stage_id" ref="crm.stage_oppor3"/>
<field eval="&quot;CONS TRUST (AZ) 529701 - 1000 units&quot;" name="name"/>
</record>
<record id="crm_case_rdroundfundingunits0" model="crm.opportunity">
<field name="partner_address_id" ref="base.res_partner_address_15"/>
<field eval="1" name="active"/>
<field name="type_id" ref="crm.type_oppor2"/>
<field name="partner_id" ref="base.res_partner_11"/>
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="&quot;draft&quot;" name="state"/>
<field eval="45000.0" name="planned_revenue"/>
<field eval="50" name="probability"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="categ_id" ref="crm.categ_oppor5"/>
<field name="stage_id" ref="crm.stage_oppor1"/>
<field eval="&quot;3rd Round Funding - 1000 units &quot;" name="name"/>
</record>
<record id="crm_case_mediapoleunits0" model="crm.opportunity">
<field eval="10" name="probability"/>
<field name="partner_address_id" ref="base.res_partner_address_3"/>
<field eval="1" name="active"/>
<field name="type_id" ref="crm.type_oppor1"/>
<field name="partner_id" ref="base.res_partner_8"/>
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="&quot;pending&quot;" name="state"/>
<field eval="55000.0" name="planned_revenue"/>
<field eval="70" name="probability"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="categ_id" ref="crm.categ_oppor7"/>
<field name="stage_id" ref="crm.stage_oppor5"/>
<field eval="&quot;Mediapole - 5000 units&quot;" name="name"/>
<field eval="&quot;info@mediapole.net&quot;" name="email_from"/>
</record>
<record id="crm_case_abcfuelcounits0" model="crm.opportunity">
<field eval="40" name="probability"/>
<field name="partner_address_id" ref="base.res_partner_address_1"/>
<field eval="1" name="active"/>
<field name="type_id" ref="crm.type_oppor1"/>
<field name="partner_id" ref="base.res_partner_9"/>
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_demo"/>
<field eval="&quot;open&quot;" name="state"/>
<field eval="45000.0" name="planned_revenue"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="categ_id" ref="crm.categ_oppor5"/>
<field name="stage_id" ref="crm.stage_oppor4"/>
<field eval="&quot;ABC FUEL CO 829264 - 1000 units &quot;" name="name"/>
<field eval="&quot;info@opensides.be&quot;" name="email_from"/>
</record>
<record id="crm_case_dirtminingltdunits0" model="crm.opportunity">
<field eval="80" name="probability"/>
<field name="partner_address_id" ref="base.res_partner_address_wong"/>
<field eval="1" name="active"/>
<field name="partner_id" ref="base.res_partner_maxtor"/>
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="&quot;done&quot;" name="state"/>
<field eval="42000.0" name="planned_revenue"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="categ_id" ref="crm.categ_oppor2"/>
<field name="stage_id" ref="crm.stage_oppor6"/>
<field eval="&quot;Dirt Mining Ltd 271742 - 1000 units&quot;" name="name"/>
</record>
</data>
</openerp>
-57
View File
@@ -1,57 +0,0 @@
<?xml version="1.0"?>
<openerp>
<data noupdate="1">
<act_window
id="act_crm_opportunity_crm_meeting_new"
name="Meetings"
res_model="crm.meeting"
src_model="crm.opportunity"
view_mode="tree,form,calendar,"
context="{'default_duration': 4.0, 'default_opportunity_id': active_id}"
domain="[('user_id','=',uid), ('opportunity_id', '=', active_id)]"
view_type="form"/>
<act_window
id="act_crm_opportunity_crm_phonecall_new"
name="Phone calls"
res_model="crm.phonecall"
src_model="crm.opportunity"
view_mode="calendar,tree,form"
context="{'default_duration': 1.0}"
domain="[('user_id','=',uid)]"
view_type="form"/>
<record model="ir.actions.act_window" id="crm_case_category_act_oppor11">
<field name="name">Opportunities</field>
<field name="res_model">crm.opportunity</field>
<field name="view_mode">tree,form,graph</field>
<field name="view_id" ref="crm_case_tree_view_oppor"/>
<field name="search_view_id" ref="crm.view_crm_case_opportunities_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_tree_view_oppor11">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="crm_case_tree_view_oppor"/>
<field name="act_window_id" ref="crm_case_category_act_oppor11"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_form_view_oppor11">
<field name="sequence" eval="2"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_case_form_view_oppor"/>
<field name="act_window_id" ref="crm_case_category_act_oppor11"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_graph_view_oppor11">
<field name="sequence" eval="4"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="crm_case_graph_view_opportunity"/>
<field name="act_window_id" ref="crm_case_category_act_oppor11"/>
</record>
<menuitem id="base.menu_sales" name="Sales"
parent="base.menu_base_partner" sequence="1" />
<menuitem name="Opportunities" id="menu_crm_case_opp"
parent="base.menu_sales" action="crm_case_category_act_oppor11"
sequence="2" />
</data>
</openerp>
-329
View File
@@ -1,329 +0,0 @@
<?xml version="1.0"?>
<openerp>
<data>
<!-- Opportunity Categories Form View -->
<record id="crm_opportunity_categ_action" model="ir.actions.act_window">
<field name="name">Opportunity Categories</field>
<field name="res_model">crm.case.categ</field>
<field name="view_type">form</field>
<field name="view_id" ref="crm.crm_case_categ_tree-view"/>
<field name="domain">[('object_id.model', '=', 'crm.opportunity')]</field>
<field name="context">{'object_id':'crm.opportunity'}</field>
</record>
<menuitem action="crm_opportunity_categ_action"
id="menu_crm_case_opportunity-act"
parent="crm.menu_crm_case_categ" />
<!-- Opportunity Stages Form View-->
<record id="crm_opportunity_stage_act" model="ir.actions.act_window">
<field name="name">Opportunity Stages</field>
<field name="res_model">crm.case.stage</field>
<field name="view_type">form</field>
<field name="view_id" ref="crm.crm_case_stage_tree"/>
<field name="domain">[('object_id.model', '=', 'crm.opportunity')]</field>
<field name="context">{'object_id':'crm.opportunity'}</field>
</record>
<menuitem action="crm_opportunity_stage_act"
id="menu_crm_opportunity_stage_act"
parent="crm.menu_crm_case_stage" />
<!-- Opportunity Resource Type Form View -->
<record id="crm_opportunity_resource_act" model="ir.actions.act_window">
<field name="name">Opportunity Resource Type</field>
<field name="res_model">crm.case.resource.type</field>
<field name="view_type">form</field>
<field name="view_id" ref="crm.crm_case_resource_type_tree"/>
<field name="domain">[('object_id.model', '=', 'crm.opportunity')]</field>
<field name="context">{'object_id':'crm.opportunity'}</field>
</record>
<menuitem action="crm_opportunity_resource_act"
id="menu_crm_opportunity_resource_act"
parent="crm.menu_crm_case_resource_type" />
<!-- Opportunities Form View -->
<record model="ir.ui.view" id="crm_case_form_view_oppor">
<field name="name">Opportunities</field>
<field name="model">crm.opportunity</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Opportunities">
<group colspan="4" col="7">
<field name="name" string="Opportunity"/>
<label string="Stage:" align="1.0"/>
<group colspan="1" col="4">
<field name="stage_id" nolabel="1"
on_change="onchange_stage_id(stage_id)"
widget="selection"
domain="[('object_id.model', '=', 'crm.opportunity')]" />
<button name="stage_previous"
states="open,pending" type="object"
icon="gtk-go-back" string="" />
<button name="stage_next" states="open,pending"
type="object" icon="gtk-go-forward" string="" />
</group>
<field name="user_id"/>
<button name="action_makeMeeting" type="object"
string="Schedule Meeting" icon="gtk-redo" />
<field name="planned_revenue"/>
<field name="probability"/>
<field name="date_deadline" string="Expected Closing"/>
<button string="Schedule Call"
name="%(opportunity2phonecall_act)d" icon="gtk-redo" type="action" />
<newline/>
<field name="date_action"/>
<field name="priority" string="Priority"/>
</group>
<notebook colspan="4">
<page string="Opportunity">
<group col="3" colspan="2">
<separator colspan="4" string="Contacts"/>
<field name="partner_id" select="1"
on_change="onchange_partner_id(partner_id, email_from)"
colspan="2" />
<field name="partner_address_id"
string="Contact"
on_change="onchange_partner_address_id(partner_address_id, email_from)"
colspan="1" />
<field name="email_from" string="Email" />
<field name="phone"/>
</group>
<group col="2" colspan="2">
<separator colspan="2" string="Categorization"/>
<field name="section_id" colspan="1" widget="selection"/>
<field name="categ_id" select="1"
string="Category" widget="selection"
domain="[('object_id.model', '=', 'crm.opportunity')]" />
</group>
<separator colspan="4" string="Details"/>
<field name="description" nolabel="1" colspan="4"/>
<separator colspan="4"/>
<group col="8" colspan="4">
<field name="state"/>
<button name="case_open" string="Open"
states="draft,pending" type="object"
icon="gtk-go-forward" />
<button name="case_escalate" string="Escalate"
states="open,draft,pending" type="object"
groups="base.group_extended"
icon="gtk-go-up" />
<button name="case_pending" string="Pending"
states="draft,open" type="object"
icon="gtk-media-pause" />
<button name="case_close" string="Mark Won"
states="open,draft,pending" type="object"
icon="gtk-close" />
<button name="case_cancel" string="Mark Lost"
states="draft,open,pending" type="object"
icon="gtk-cancel" />
<button name="case_reset" string="Reset to New"
states="done,cancel" type="object"
icon="gtk-convert" />
</group>
</page>
<page string="History" groups="base.group_extended">
<group col="2" colspan="2">
<separator string="Dates" colspan="2"/>
<field name="create_date"/>
<field name="write_date"/>
<field name="date_closed"/>
<field name="date_open"/>
</group>
<group col="2" colspan="2">
<separator string="Misc" colspan="2"/>
<field name="active"/>
<field name="day_open"/>
<field name="day_close"/>
<field name="referred"/>
</group>
<separator colspan="4" string="References"/>
<field name="ref"/>
<field name="ref2"/>
<field name="log_ids" nolabel="1" colspan="4">
<form string="Actions">
<separator string="Action Information" colspan="4"/>
<field name="name" colspan="4"/>
<field name="date"/>
<field name="user_id"/>
</form>
</field>
</page>
<page string="Emails" groups="base.group_extended">
<group colspan="4">
<field colspan="4" name="email_cc" string="CC"/>
</group>
<field name="history_line" colspan="4" nolabel="1" mode="form,tree">
<form string="Communication history">
<group col="7" colspan="4">
<field name="date"/>
<field name="email_to"/>
<field name="email_from"/>
<button
string="Add a CC"
name="%(crm.action_view_crm_email_add_cc_wizard)d"
icon="gtk-add" type="action"/>
</group>
<newline/>
<field name="description" colspan="4" nolabel="1"/>
<button colspan="4"
string="Reply to Last Email"
name="%(action_crm_send_mail)d"
context="{'mail':'reply', 'model': 'crm.opportunity'}"
icon="gtk-undo" type="action" />
</form>
<tree string="Communication history">
<field name="description"/>
<field name="email_to"/>
<field name="date"/>
</tree>
</field>
<button colspan="4" string="Send New Email"
name="%(action_crm_send_mail)d"
context="{'mail':'new', 'model': 'crm.opportunity'}"
icon="gtk-go-forward" type="action" />
</page>
</notebook>
</form>
</field>
</record>
<!-- Opportunities Tree View -->
<record model="ir.ui.view" id="crm_case_tree_view_oppor">
<field name="name">Opportunities Tree</field>
<field name="model">crm.opportunity</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Opportunities" colors="blue:state=='pending';grey:state in ('cancel','done')">
<field name="create_date"/>
<field name="name" string="Opportunity"/>
<field name="partner_id"/>
<field name="stage_id"/>
<field name="categ_id" invisible="1"/>
<button name="stage_previous" string="Previous"
states="open,pending" type="object" icon="gtk-go-back" />
<button name="stage_next" string="Next"
states="open,pending" type="object"
icon="gtk-go-forward" />
<field name="planned_revenue" sum="Total of Planned Revenue"/>
<field name="probability" widget="progressbar" avg="Avg. of Probability"/>
<field name="date_action"/>
<field name="section_id"/>
<field name="user_id"/>
<field name="priority"/>
<field name="state"/>
<button name="case_open" string="Open"
states="draft,pending" type="object"
icon="gtk-go-forward" />
<button name="case_close" string="Won"
states="open,draft,pending" type="object"
icon="gtk-close" />
<button name="case_pending" string="Pending"
states="open,draft" type="object"
icon="gtk-media-pause" />
<button name="case_cancel" string="Lost"
states="draft,open,pending" type="object"
icon="gtk-cancel" />
</tree>
</field>
</record>
<!-- Opportunities Graph View -->
<record model="ir.ui.view" id="crm_case_graph_view_opportunity">
<field name="name">CRM - Opportunity Graph</field>
<field name="model">crm.opportunity</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Opportunity by Categories" type="bar" orientation="horizontal">
<field name="categ_id"/>
<field name="planned_revenue" operator="+"/>
<field name="state" group="True"/>
</graph>
</field>
</record>
<!-- Opportunities Search View -->
<record id="view_crm_case_opportunities_filter" model="ir.ui.view">
<field name="name">CRM - Opportunities Search</field>
<field name="model">crm.opportunity</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search Opportunities">
<filter icon="terp-project"
string="Current"
default="1"
domain="[('state','in',('draft','open'))]"/>
<filter icon="terp-project"
string="Open"
domain="[('state','=','open')]"/>
<filter icon="terp-project"
string="Pending"
domain="[('state','=','pending')]"/>
<separator orientation="vertical"/>
<filter icon="gtk-home" string="Today"
domain="[('create_date','&lt;', time.strftime('%%Y-%%m-%%d 23:59:59')), ('create_date','&gt;=', time.strftime('%%Y-%%m-%%d 23:59:59'))]"
help="Todays' Opportunities" />
<filter icon="gtk-media-rewind" string="7 Days"
help="Opportunities during last 7 days"
domain="[('create_date','&lt;', time.strftime('%%Y-%%m-%%d')),\
('create_date','&gt;=',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
/>
<separator orientation="vertical"/>
<field name="name" string="Opportunity"/>
<field name="partner_id"/>
<field name="user_id" widget="selection">
<filter icon="terp-partner"
domain="[('user_id','=',uid)]"
help="My Opportunities" default="1"
/>
<filter icon="terp-partner"
domain="[('user_id','=', False)]"
help="Unassigned Opportunities" />
</field>
<field name="section_id"
default="context.get('section_id', False)" select="1"
widget="selection">
<filter icon="terp-crm"
domain="[('section_id','=',context.get('section_id',False))]"
help="My section" />
</field>
<newline/>
<group expand="1" string="Group By..." colspan="16">
<filter string="Stage" icon="terp-crm" domain="[]"
context="{'group_by':'stage_id'}" />
<filter string="Priority" icon="terp-crm" domain="[]"
context="{'group_by':'priority'}" />
<filter string="Category" icon="terp-crm"
domain="[]" context="{'group_by':'categ_id'}" />
<separator orientation="vertical" />
<filter string="Partner" icon="terp-crm" domain="[]"
context="{'group_by':'partner_id'}" />
<filter string="Salesman" icon="terp-crm"
domain="[]" context="{'group_by':'user_id'}" />
<separator orientation="vertical" />
<filter string="Creation" icon="terp-project"
domain="[]" context="{'group_by':'create_date'}" />
<filter string="Exp.Closing" icon="terp-project"
domain="[]" context="{'group_by':'date_deadline'}" />
</group>
</search>
</field>
</record>
</data>
</openerp>
-2
View File
@@ -22,10 +22,8 @@
#import report_businessopp
import crm_report
import crm_claim_report
import crm_lead_report
import crm_phonecall_report
import crm_fundraising_report
import crm_opportunity_report
import crm_helpdesk_report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-88
View File
@@ -1,88 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields,osv
import tools
AVAILABLE_STATES = [
('draft','Draft'),
('open','Open'),
('cancel', 'Cancelled'),
('done', 'Closed'),
('pending','Pending')
]
class crm_lead_report(osv.osv):
""" CRM Lead Report """
_name = "crm.lead.report"
_auto = False
_inherit = "crm.case.report"
_description = "CRM Lead Report"
_columns = {
'delay_close': fields.float('Delay to close',digits=(16,2),readonly=True, group_operator="avg",help="Number of Days to close the case"),
'categ_id': fields.many2one('crm.case.categ', 'Category',\
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.lead')]" , readonly=True),
'stage_id': fields.many2one ('crm.case.stage', 'Stage', \
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.lead')]", readonly=True),
'partner_id': fields.many2one('res.partner', 'Partner' , readonly=True),
'company_id': fields.many2one('res.company', 'Company', readonly=True),
}
def init(self, cr):
"""
CRM Lead Report
@param cr: the current row, from the database cursor
"""
tools.drop_view_if_exists(cr, 'crm_lead_report')
cr.execute("""
create or replace view crm_lead_report as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY') as name,
to_char(c.create_date, 'MM') as month,
to_char(c.create_date, 'YYYY-MM-DD') as day,
c.state as state,
c.user_id,
c.stage_id,
c.company_id,
c.section_id,
c.categ_id,
c.partner_id,
count(*) as nbr,
0 as avg_answers,
0.0 as perc_done,
0.0 as perc_cancel,
date_trunc('day',c.create_date) as create_date,
avg(extract('epoch' from (c.date_closed-c.create_date)))/(3600*24) as delay_close
from
crm_lead c
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'),\
c.state, c.user_id,c.section_id,c.stage_id,categ_id,c.partner_id,c.company_id
,c.create_date,to_char(c.create_date, 'YYYY-MM-DD')
)""")
crm_lead_report()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-116
View File
@@ -1,116 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Leads by user and section Tree View -->
<record id="view_report_crm_lead_tree" model="ir.ui.view">
<field name="name">crm.lead.report.tree</field>
<field name="model">crm.lead.report</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Leads">
<field name="name" invisible="1"/>
<field name="month" invisible="1"/>
<field name="section_id" invisible="1"/>
<field name="user_id" invisible="1"/>
<field name="company_id" invisible="1"/>
<field name="partner_id" invisible="1"/>
<field name="day" invisible="1"/>
<field name="nbr" string="#Leads" sum="#Leads"/>
<field name="delay_close" sum='Avg Closing Delay'/>
<field name="state" invisible="1"/>
<field name="stage_id" invisible="1"/>
<field name="categ_id" invisible="1"/>
</tree>
</field>
</record>
<!-- Leads by user and section Form View -->
<record id="view_report_crm_lead_form" model="ir.ui.view">
<field name="name">crm.lead.report.form</field>
<field name="model">crm.lead.report</field>
<field name="inherit_id" ref="view_crm_case_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="nbr" position="after">
<field name="delay_close"/>
<field name="stage_id"/>
</field>
</field>
</record>
<!-- Leads by user and section Graph View -->
<record id="view_report_crm_lead_graph" model="ir.ui.view">
<field name="name">crm.lead.report.graph</field>
<field name="model">crm.lead.report</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="Leads" type="bar">
<field name="state"/>
<field name="nbr" operator="+"/>
<field group="True" name="user_id"/>
</graph>
</field>
</record>
<!-- Leads by user and section Search View -->
<record id="view_report_crm_lead_filter" model="ir.ui.view">
<field name="name">crm.lead.report.select</field>
<field name="model">crm.lead.report</field>
<field name="inherit_id" ref="view_crm_case_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<data>
<xpath expr='//search[@string="Search"]/group[@string="Extended options..."]/filter[@string="Cancel"]' position='after'>
<group>
<separator orientation="vertical"/>
<field name="stage_id" widget="selection" domain="[('object_id.model', '=', 'crm.lead')]"/>
<field name="categ_id" widget="selection" domain="[('object_id.model', '=', 'crm.lead')]"/>
</group>
</xpath>
<xpath
expr='//search[@string="Search"]/group[@string="Group By..."]/filter[@string="State"]'
position='after'>
<filter string="Stage" icon="terp-sale" domain="[]"
context="{'group_by':'stage_id'}" />
</xpath>
</data>
</field>
</record>
<!-- Leads by user and section Action -->
<record id="action_report_crm_lead" model="ir.actions.act_window">
<field name="name">Leads</field>
<field name="res_model">crm.lead.report</field>
<field name="view_type">form</field>
<field name="context">{"search_default_User":1,"search_default_This Month":1,'group_by_no_leaf':1,'group_by':[]}</field>
<field name="view_mode">tree,graph</field>
<field name="search_view_id" ref="view_report_crm_lead_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_report_crm_lead_tree">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_report_crm_lead_tree"/>
<field name="act_window_id" ref="action_report_crm_lead"/>
</record>
<record model="ir.actions.act_window.view" id="action_report_crm_lead_graph">
<field name="sequence" eval="2"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_report_crm_lead_graph"/>
<field name="act_window_id" ref="action_report_crm_lead"/>
</record>
<menuitem name="Leads" id="menu_report_crm_leads_tree"
groups="base.group_extended"
parent="base.next_id_64" action="action_report_crm_lead" />
</data>
</openerp>
-100
View File
@@ -1,100 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields,osv
import tools
AVAILABLE_STATES = [
('draft','Draft'),
('open','Open'),
('cancel', 'Cancelled'),
('done', 'Closed'),
('pending','Pending')
]
class crm_opportunity_report(osv.osv):
""" CRM Opportunity Report """
_name = "crm.opportunity.report"
_auto = False
_inherit = "crm.case.report"
_description = "CRM Opportunity Report"
_columns = {
'probability': fields.float('Avg. Probability', readonly=True,group_operator='avg'),
'amount_revenue': fields.float('Est.Revenue', readonly=True),
'amount_revenue_prob': fields.float('Est. Rev*Prob.', readonly=True),
'delay_close': fields.float('Delay to close',digits=(16,2),readonly=True, group_operator="avg",help="Number of Days to close the case"),
'categ_id': fields.many2one('crm.case.categ', 'Category',\
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.opportunity')]", readonly=True),
'stage_id':fields.many2one('crm.case.stage', 'Stage',\
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.opportunity')]", readonly=True),
'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
'company_id': fields.many2one('res.company', 'Company', readonly=True),
'user_id':fields.many2one('res.users', 'User', readonly=True),
}
def init(self, cr):
""" Display Est.Revenue , Average Probability ,Est.Revenue Probability
@param cr: the current row, from the database cursor
"""
tools.drop_view_if_exists(cr, 'crm_opportunity_report')
cr.execute("""
create or replace view crm_opportunity_report as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY') as name,
to_char(c.create_date, 'MM') as month,
to_char(c.create_date, 'YYYY-MM-DD') as day,
c.state as state,
c.user_id,
c.section_id,
c.categ_id,
c.stage_id,
c.partner_id,
c.company_id,
count(*) as nbr,
0 as avg_answers,
0.0 as perc_done,
0.0 as perc_cancel,
date_trunc('day',c.create_date) as create_date,
sum(planned_revenue) as amount_revenue,
sum((planned_revenue*probability)/100.0)::decimal(16,2) as amount_revenue_prob,
avg(probability)::decimal(16,2) as probability,
avg(extract('epoch' from (c.date_closed-c.create_date)))/(3600*24) as delay_close
from
crm_opportunity c
group by
to_char(c.create_date, 'YYYY'),
to_char(c.create_date, 'MM'),
to_char(c.create_date, 'YYYY-MM-DD'),
c.state,
c.user_id,
c.section_id,
c.stage_id,
c.categ_id,
c.partner_id,
company_id,
create_date
)""")
crm_opportunity_report()
@@ -1,122 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Opportunities by user and section Tree View -->
<record id="view_report_crm_opportunity_tree" model="ir.ui.view">
<field name="name">crm.opportunity.report.tree</field>
<field name="model">crm.opportunity.report</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Opportunities">
<field name="name" invisible="1"/>
<field name="month" invisible="1"/>
<field name="section_id" invisible="1"/>
<field name="user_id" invisible="1"/>
<field name="company_id" invisible="1"/>
<field name="partner_id" invisible="1"/>
<field name="nbr" string="#Opportunities" sum="#Opportunities"/>
<field name="amount_revenue" sum="Total Revenue"/>
<field name="probability" widget="progressbar" avg="Probability"/>
<field name="amount_revenue_prob" sum="Est. Rev*Prob"/>
<field name="delay_close" avg="Avg Closing Delay"/>
<field name="state" invisible="1"/>
<field name="stage_id" invisible="1"/>
<field name="categ_id" invisible="1"/>
<field name="day" invisible="1"/>
</tree>
</field>
</record>
<!-- Opportunities by user and section Form View -->
<record id="view_report_crm_opportunity_form" model="ir.ui.view">
<field name="name">crm.opportunity.report.form</field>
<field name="model">crm.opportunity.report</field>
<field name="inherit_id" ref="view_crm_case_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="nbr" position="after">
<field name="delay_close"/>
<field name="amount_revenue"/>
<field name="amount_costs"/>
<field name="amount_revenue_prob"/>
<field name="probability"/>
</field>
</field>
</record>
<!-- Opportunities by user and section Graph View -->
<record id="view_report_crm_opportunity_graph" model="ir.ui.view">
<field name="name">crm.opportunity.report.graph</field>
<field name="model">crm.opportunity.report</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="Opportunity" type="bar">
<field name="state"/>
<field name="nbr" operator="+"/>
<field group="True" name="user_id"/>
</graph>
</field>
</record>
<!-- Opportunities by user and section Search View -->
<record id="view_report_crm_opportunity_filter" model="ir.ui.view">
<field name="name">crm.opportunity.report.select</field>
<field name="model">crm.opportunity.report</field>
<field name="inherit_id" ref="view_crm_case_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<data>
<xpath expr='//search[@string="Search"]/group[@string="Extended options..."]/filter[@string="Cancel"]' position='after'>
<group>
<separator orientation="vertical"/>
<field name="stage_id" widget="selection" domain="[('object_id.model', '=', 'crm.opportunity')]"/>
<field name="categ_id" widget="selection" domain="[('object_id.model', '=', 'crm.opportunity')]"/>
</group>
</xpath>
<xpath
expr='//search[@string="Search"]/group[@string="Group By..."]/filter[@string="State"]'
position='after'>
<filter string="Stage" icon="terp-sale" domain="[]"
context="{'group_by':'stage_id'}" />
<separator orientation="vertical" />
<filter string="Partner" icon="terp-partner"
domain="[]" context="{'group_by':'partner_id'}" />
</xpath>
</data>
</field>
</record>
<!-- Opportunities by user and section Action -->
<record id="action_report_crm_opportunity" model="ir.actions.act_window">
<field name="name">Opportunities</field>
<field name="res_model">crm.opportunity.report</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="context">{"search_default_User":1,"search_default_This Month":1,'group_by_no_leaf':1,'group_by':[]}</field>
<field name="search_view_id" ref="view_report_crm_opportunity_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_report_crm_opportunity_tree">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_report_crm_opportunity_tree"/>
<field name="act_window_id" ref="action_report_crm_opportunity"/>
</record>
<record model="ir.actions.act_window.view" id="action_report_crm_opportunity_graph">
<field name="sequence" eval="2"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_report_crm_opportunity_graph"/>
<field name="act_window_id" ref="action_report_crm_opportunity"/>
</record>
<menuitem name="Opportunities"
action="action_report_crm_opportunity"
id="menu_report_crm_opportunity_tree" parent="base.next_id_64" />
</data>
</openerp>
-8
View File
@@ -9,8 +9,6 @@
"access_crm_fundraising","crm.fundraising","model_crm_fundraising","crm.group_crm_manager",1,1,1,1
"access_crm_helpdesk","crm.helpdesk","model_crm_helpdesk","crm.group_crm_manager",1,1,1,1
"access_crm_meeting","crm.meeting","model_crm_meeting","crm.group_crm_manager",1,1,1,1
"access_crm_lead","crm.lead","model_crm_lead","crm.group_crm_manager",1,1,1,1
"access_crm_opportunity","crm.opportunity","model_crm_opportunity","crm.group_crm_manager",1,1,1,1
"access_crm_phonecall","crm.phonecall","model_crm_phonecall","crm.group_crm_manager",1,1,1,1
"access_crm_case_log","crm.case.log","model_crm_case_log","crm.group_crm_user",1,1,1,1
"access_crm_case_history","crm.case.history","model_crm_case_history","crm.group_crm_user",1,1,1,1
@@ -28,17 +26,11 @@
"access_crm_case_report_manager","crm.case.report manager","model_crm_case_report","crm.group_crm_manager",1,1,1,1
"access_crm_claim_report_user","crm.claim.report","model_crm_claim_report","crm.group_crm_user",1,0,0,0
"access_crm_fundraising_report_user","crm.fundraising.report","model_crm_fundraising_report","crm.group_crm_user",1,0,0,0
"access_crm_lead_report_user","crm.lead.report","model_crm_lead_report","crm.group_crm_user",1,0,0,0
"access_crm_phonecall_report_user","crm.phonecall.report","model_crm_phonecall_report","crm.group_crm_user",1,0,0,0
"access_crm_opportunity_report_user","crm.opportunity.report","model_crm_opportunity_report","crm.group_crm_user",1,0,0,0
"access_report_crm_case_service_dashboard","report.crm.case.service.dashboard","model_report_crm_case_service_dashboard","crm.group_crm_user",1,0,0,0
"access_crm_lead2partner","crm.lead2partner","model_crm_lead2partner","crm.group_crm_user",1,1,1,1
"access_crm_lead2opportunity","crm.lead2opportunity","model_crm_lead2opportunity","crm.group_crm_user",1,1,1,1
"access_crm_opportunity2phonecall","crm.opportunity2phonecall","model_crm_opportunity2phonecall","crm.group_crm_user",1,1,1,1
"access_crm_phonecall2phonecall","crm.phonecall2phonecall","model_crm_phonecall2phonecall","crm.group_crm_user",1,1,1,1
"access_crm_phonecall2partner","crm.phonecall2partner","model_crm_phonecall2partner","crm.group_crm_user",1,1,1,1
"access_crm_phonecall2opportunity","crm.phonecall2opportunity","model_crm_phonecall2opportunity","crm.group_crm_user",1,1,1,1
"access_report_crm_helpdesk","report.crm.helpdesk","model_crm_helpdesk_report","crm.group_crm_user",1,1,1,1
"access_crm_send_mail","crm.send.mail","model_crm_send_mail","crm.group_crm_user",1,1,1,1
"access_crm_partner2opportunity","crm.partner2opportunity","model_crm_partner2opportunity","crm.group_crm_user",1,1,1,1
"access_crm_lead2opportunity_partner","crm.lead2opportunity.partner","model_crm_lead2opportunity_partner","crm.group_crm_user",1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
9 access_crm_fundraising crm.fundraising model_crm_fundraising crm.group_crm_manager 1 1 1 1
10 access_crm_helpdesk crm.helpdesk model_crm_helpdesk crm.group_crm_manager 1 1 1 1
11 access_crm_meeting crm.meeting model_crm_meeting crm.group_crm_manager 1 1 1 1
access_crm_lead crm.lead model_crm_lead crm.group_crm_manager 1 1 1 1
access_crm_opportunity crm.opportunity model_crm_opportunity crm.group_crm_manager 1 1 1 1
12 access_crm_phonecall crm.phonecall model_crm_phonecall crm.group_crm_manager 1 1 1 1
13 access_crm_case_log crm.case.log model_crm_case_log crm.group_crm_user 1 1 1 1
14 access_crm_case_history crm.case.history model_crm_case_history crm.group_crm_user 1 1 1 1
26 access_crm_case_report_manager crm.case.report manager model_crm_case_report crm.group_crm_manager 1 1 1 1
27 access_crm_claim_report_user crm.claim.report model_crm_claim_report crm.group_crm_user 1 0 0 0
28 access_crm_fundraising_report_user crm.fundraising.report model_crm_fundraising_report crm.group_crm_user 1 0 0 0
access_crm_lead_report_user crm.lead.report model_crm_lead_report crm.group_crm_user 1 0 0 0
29 access_crm_phonecall_report_user crm.phonecall.report model_crm_phonecall_report crm.group_crm_user 1 0 0 0
access_crm_opportunity_report_user crm.opportunity.report model_crm_opportunity_report crm.group_crm_user 1 0 0 0
30 access_report_crm_case_service_dashboard report.crm.case.service.dashboard model_report_crm_case_service_dashboard crm.group_crm_user 1 0 0 0
access_crm_lead2partner crm.lead2partner model_crm_lead2partner crm.group_crm_user 1 1 1 1
access_crm_lead2opportunity crm.lead2opportunity model_crm_lead2opportunity crm.group_crm_user 1 1 1 1
access_crm_opportunity2phonecall crm.opportunity2phonecall model_crm_opportunity2phonecall crm.group_crm_user 1 1 1 1
31 access_crm_phonecall2phonecall crm.phonecall2phonecall model_crm_phonecall2phonecall crm.group_crm_user 1 1 1 1
32 access_crm_phonecall2partner crm.phonecall2partner model_crm_phonecall2partner crm.group_crm_user 1 1 1 1
33 access_crm_phonecall2opportunity crm.phonecall2opportunity model_crm_phonecall2opportunity crm.group_crm_user 1 1 1 1
34 access_report_crm_helpdesk report.crm.helpdesk model_crm_helpdesk_report crm.group_crm_user 1 1 1 1
35 access_crm_send_mail crm.send.mail model_crm_send_mail crm.group_crm_user 1 1 1 1
36 access_crm_partner2opportunity crm.partner2opportunity model_crm_partner2opportunity crm.group_crm_user 1 1 1 1
access_crm_lead2opportunity_partner crm.lead2opportunity.partner model_crm_lead2opportunity_partner crm.group_crm_user 1 1 1 1
-113
View File
@@ -1,113 +0,0 @@
- |
In order to test the CRM in OpenERP,
I will do a customer qualification process that
starts with a fist contact with a customer (a lead), which will be converted to a
business opportunity and a partner.
- |
In order to test the flow, I create a two new users "user_crm" and
I assign the group "salesman".
-
!record {model: res.users, id: res_users_usercrm0}:
company_id: base.main_company
context_lang: en_US
context_section_id: crm.section_sales_department
groups_id:
- crm.group_crm_user
login: user_crm
name: user_crm
password: user_crm
- |
I start by creating a new lead "New Customer" and I provide an address to this
new customer, as well as an email "info@mycustomer.com".
-
!record {model: crm.lead, id: crm_lead_newcustomer0}:
email_from: info@mycustomer.com
name: New Customer
partner_name: Sandip zala
phone: (855) 924-4364
mobile: (333) 715-1450
section_id: crm.section_sales_department
referred: False
title: M.
- |
I check that the lead is in 'draft' state,
-
!assert {model: crm.lead, id: crm_lead_newcustomer0, string: Lead in Draft}:
- state == "draft"
-
I open lead by click on "Open" button,
-
!python {model: crm.lead}: |
self.case_open(cr, uid, [ref("crm_lead_newcustomer0")])
- |
As the lead seems to be a real business opportunity, I will convert it to a
partner
and a business opportunity by clicking on the "Convert" button.
-
!python {model: crm.lead}: |
lead = self.browse(cr, uid, ref('crm_lead_newcustomer0'))
if not lead.partner_id:
self.convert_opportunity(cr, uid, [ref("crm_lead_newcustomer0")], {'active_ids': [ref("crm_lead_newcustomer0")]})
-
|
Now, select "create a new partner" option in this wizard.
-
!record {model: crm.lead2opportunity.partner, id: crm_lead2opportunity_partner_create_0}:
action: 'create'
-
I click on "Continue" button of this wizard.
-
!python {model: crm.lead2opportunity.partner}: |
self.make_partner(cr, uid, [ref("crm_lead2opportunity_partner_create_0")], {'active_ids': [ref("crm_lead_newcustomer0")]})
-
Now, I give value to this wizard field.
-
!record {model: crm.lead2opportunity, id: crm_lead2opportunity_stonage_0}:
name: Sandip zala
planned_revenue: 0.00
probability: 0.00
-
Then, Click on "Create Opportunity" button of this wizard.
-
!python {model: crm.lead2opportunity}: |
self.action_apply(cr, uid, [ref('crm_lead2opportunity_stonage_0')], {'active_id': ref('crm_lead_newcustomer0')})
- |
I can check that a lead and a business opportunity is now assigned to this
lead.
-
# !python {model: crm.lead, id: crm_lead_newcustomer0}:
# - opportunity_id.id != False
- |
I check that the partner associated to this lead as the same country, phone number
and name than the opportunity.
-
!python {model: crm.lead}: |
lead = self.browse(cr, uid, ref("crm_lead_newcustomer0"))
print "lead", lead.partner_name
obj_opportunity = self.pool.get('crm.opportunity')
ids = obj_opportunity.search(cr, uid, [('name', '=', lead.partner_name)])
opportunity = obj_opportunity.browse(cr, uid, ids)[0]
assert lead.partner_name == opportunity.partner_id.name
assert lead.phone == opportunity.phone
-
|
# yaml is also not working smpt server and send new email.
- |
I configure with smtp server.
- |
And I communicate with lead through send New mail to Lead using it email address from user which are loged.
- |
I check that communication history generated when send email to lead.
- |
Then, I add a cc which receive copy of future communication between partner and users by mail.
- |
I Reply to last Email to lead with some document attached.and check that communication history generated or not.
-81
View File
@@ -1,81 +0,0 @@
- |
I start by creating a new Opportunity. And I select partner for opportunity.
I can see that after selecting partner his contact and email is automatically filled.
-
!record {model: crm.opportunity, id: crm_opportunity_abcfuelcounits0}:
email_from: info@balmerinc.be
name: 'ABC FUEL CO 829264 - 10002 units '
partner_address_id: base.res_partner_address_1
partner_id: base.res_partner_9
probability: 1.0
stage_id: crm.stage_oppor1
categ_id: crm.categ_oppor2
section_id: crm.section_sales_department
- |
I check that the opportunity is in 'New' state.
-
!assert {model: crm.opportunity, id: crm_opportunity_abcfuelcounits0}:
- state == "draft"
- |
I open opportunity by click on "Open" button,
-
!python {model: crm.opportunity}: |
self.case_open(cr, uid, [ref("crm_opportunity_abcfuelcounits0")])
- |
I schedule Meeting on this current opportunity by clicking on "schedule
Meeting".
-
!python {model: crm.opportunity}: |
self.action_makeMeeting(cr, uid, [ref("crm_opportunity_abcfuelcounits0")])
- |
I can see that Meeting's calendar view is shown.
then I click on the date on which I want schedule meeting.
I fill proper data for that meeting and save it
-
!record {model: crm.meeting, id: crm_meeting_abcfuelcounits0}:
alarm_id: base_calendar.alarm3
date: '2010-04-16 00:00:00'
date_deadline: '2010-04-16 08:00:00'
duration: 8.0
email_from: info@balmerinc.be
name: 'ABC FUEL CO 829264 - 10002 units '
opportunity_id: 'crm_opportunity_abcfuelcounits0'
partner_address_id: base.res_partner_address_1
partner_id: base.res_partner_9
rrule_type: weekly
section_id: crm.section_sales_department
state: open
- |
In order to schedule a phonecall to the partner
I click on "schedule call" button and select planned date for the call.
-
!record {model: crm.opportunity2phonecall, id: crm_opportunity2phonecall_abcfuelcounits0}:
date: '2010-04-17 11:15:00'
name: 'ABC FUEL CO 829264 - 10002 units '
section_id: crm.section_sales_department
user_id: base.user_demo
- |
schedule phonecall by apply (action_apply)function of opportunity2phoncall wizard
-
!python {model: crm.opportunity2phonecall}: |
self.action_apply(cr, uid, [ref('crm_opportunity2phonecall_abcfuelcounits0')], {'active_ids': [ref("crm_opportunity_abcfuelcounits0")]})
- |
I check that phonecall record is created for that opportunity.
-
!python {model: crm.phonecall}: |
ids = self.search(cr, uid, [('name', '=', 'ABC FUEL CO 829264 - 10002 units')])
assert len(ids)
- |
I can see phonecall record after click on "Schedule call" wizard.
-
!record {model: crm.phonecall, id: crm_phonecall_abcfuelcounits0}:
date: '2010-04-17 11:15:00'
duration: 3.0
name: 'ABC FUEL CO 829264 - 10002 units'
partner_address_id: base.res_partner_address_1
partner_id: base.res_partner_9
section_id: crm.section_sales_department
-4
View File
@@ -21,10 +21,6 @@
import crm_send_email
import crm_email_add_cc
import crm_lead_to_partner
import crm_lead_to_opportunity
import crm_opportunity_to_phonecall
import crm_phonecall_to_phonecall
import crm_phonecall_to_partner
import crm_phonecall_to_opportunity
@@ -1,327 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from mx.DateTime import now
from osv import osv, fields
from tools.translate import _
class crm_lead2opportunity(osv.osv_memory):
_name = 'crm.lead2opportunity'
_description = 'Lead To Opportunity'
def action_cancel(self, cr, uid, ids, context=None):
"""
Closes Lead To Opportunity 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 Lead to Partner's IDs
@param context: A standard dictionary for contextual values
"""
return {'type': 'ir.actions.act_window_close'}
def action_apply(self, cr, uid, ids, context=None):
"""
This converts lead to opportunity and opens Opportunity view
@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 Lead to Opportunity IDs
@param context: A standard dictionary for contextual values
@return : Dictionary value for created Opportunity form
"""
record_id = context and context.get('active_id', False) or False
if not record_id:
return {}
lead_obj = self.pool.get('crm.lead')
opp_obj = self. pool.get('crm.opportunity')
data_obj = self.pool.get('ir.model.data')
history_obj = self.pool.get('crm.case.history')
model_obj = self.pool.get('ir.model')
# Get Opportunity views
result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_opportunities_filter')
res = data_obj.read(cr, uid, result, ['res_id'])
id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_form_view_oppor')
id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_tree_view_oppor')
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
lead = lead_obj.browse(cr, uid, record_id, context=context)
model_ids = model_obj.search(cr, uid, [('model', '=', 'crm.opportunity')])
for this in self.browse(cr, uid, ids, context=context):
new_opportunity_id = opp_obj.create(cr, uid, {
'name': this.name,
'referred': lead.referred,
'planned_revenue': this.planned_revenue,
'probability': this.probability,
'partner_id': lead.partner_id and lead.partner_id.id or False,
'section_id': lead.section_id and lead.section_id.id or False,
'description': lead.description or False,
'date_deadline': lead.date_deadline or False,
'partner_address_id': lead.partner_address_id and lead.partner_address_id.id or False ,
'priority': lead.priority,
'phone': lead.phone,
'email_from': lead.email_from
})
new_opportunity = opp_obj.browse(cr, uid, new_opportunity_id)
vals = {
'partner_id': this.partner_id and this.partner_id.id or False,
}
if not lead.opportunity_id:
vals.update({'opportunity_id' : new_opportunity.id})
model_opportunity_id = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'crm.opportunity')], context=context)[0]
for model in ('crm.case.log', 'crm.case.history'):
log_proxy = self.pool.get(model)
log_ids = log_proxy.search(cr, uid, [('model_id.model', '=', 'crm.lead'),('res_id', '=', lead.id)], context=context)
for log_id in log_ids:
log_proxy.copy(cr, uid, log_id, {'model_id':model_opportunity_id}, context=context)
lead_obj.write(cr, uid, [lead.id], vals)
lead_obj.case_close(cr, uid, [lead.id])
# Copy lead history to opportunity
for his_id in lead.history_line:
history_ids = history_obj.copy(cr, uid, his_id.id, \
{'model_id': model_ids[0], \
'res_id': new_opportunity_id})
#opp_obj.case_open(cr, uid, [new_opportunity_id])
value = {
'name': _('Opportunity'),
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'crm.opportunity',
'res_id': int(new_opportunity_id),
'view_id': False,
'views': [(id2, 'form'), (id3, 'tree'), (False, 'calendar'), (False, 'graph')],
'type': 'ir.actions.act_window',
'search_view_id': res['res_id']
}
return value
_columns = {
'name' : fields.char('Opportunity Summary', size=64, required=True, select=1),
'probability': fields.float('Success Probability'),
'planned_revenue': fields.float('Expected Revenue'),
'partner_id': fields.many2one('res.partner', 'Partner'),
}
def view_init(self, cr, uid, fields, context=None):
"""
This function checks for precondition before wizard executes
@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 fields: List of fields for default value
@param context: A standard dictionary for contextual values
"""
lead_obj = self.pool.get('crm.lead')
for lead in lead_obj.browse(cr, uid, context.get('active_ids', [])):
if lead.state in ['done', 'cancel']:
raise osv.except_osv(_("Warning !"), _("Closed/Cancelled \
Leads Could not convert into Opportunity"))
if lead.state != 'open':
raise osv.except_osv(_('Warning !'), _('Lead should be in \
\'Open\' state before converting to Opportunity.'))
return False
def default_get(self, cr, uid, fields, context=None):
"""
This function gets default values
@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 fields: List of fields for default value
@param context: A standard dictionary for contextual values
@return : default values of fields.
"""
lead_obj = self.pool.get('crm.lead')
rec_ids = context and context.get('active_ids', [])
partner_id = context.get('partner_id', False)
data = context and context.get('active_ids', []) or []
res = super(crm_lead2opportunity, self).default_get(cr, uid, fields, context=context)
for lead in lead_obj.browse(cr, uid, data, context=context):
if 'name' in fields:
res.update({'name': lead.partner_name})
if 'partner_id' in fields:
res.update({'partner_id': partner_id and partner_id[0] or False})
return res
crm_lead2opportunity()
class crm_lead2opportunity_partner(osv.osv_memory):
_name = 'crm.lead2opportunity.partner'
_description = 'Lead To Opportunity Partner'
_inherit = 'crm.lead2partner'
_columns = {
'partner_id': fields.many2one('res.partner', 'Partner'),
'action': fields.selection([('exist', 'Link to an existing partner'), ('create', 'Create a new partner')], 'Action'),
}
def default_get(self, cr, uid, fields, context=None):
"""
This function gets default values
@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 fields: List of fields for default value
@param context: A standard dictionary for contextual values
@return : default values of fields.
"""
lead_obj = self.pool.get('crm.lead')
partner_obj = self.pool.get('res.partner')
contact_obj = self.pool.get('res.partner.address')
rec_ids = context and context.get('active_ids', [])
partner_id = False
data = context and context.get('active_ids', []) or []
res = super(crm_lead2opportunity_partner, self).default_get(cr, uid, fields, context=context)
for lead in lead_obj.browse(cr, uid, data, context=context):
partner_ids = partner_obj.search(cr, uid, [('name', '=', lead.partner_name or lead.name)])
if not partner_ids and lead.email_from:
address_ids = contact_obj.search(cr, uid, [('email', '=', lead.email_from)])
if address_ids:
addresses = contact_obj.browse(cr, uid, address_ids)
partner_ids = addresses and [addresses[0].partner_id.id] or False
partner_id = partner_ids and partner_ids[0] or False
if 'partner_id' in fields:
res.update({'partner_id': partner_id})
if 'action' in fields:
res.update({'action': partner_id and 'exist' or 'create'})
return res
def make_partner(self, cr, uid, ids, context=None):
"""
This function Makes partner based on action.
@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 Lead to Partner's IDs
@param context: A standard dictionary for contextual values
@return : Dictionary value for created Partner form.
"""
if not context:
context = {}
partner_ids = self._create_partner(cr, uid, ids, context)
mod_obj = self.pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'base', 'view_res_partner_filter')
res = mod_obj.read(cr, uid, result, ['res_id'])
value = {}
data_obj = self.pool.get('ir.model.data')
data_id = data_obj._get_id(cr, uid, 'crm', 'view_crm_lead2opportunity_create')
view_id = False
if data_id:
view_id = data_obj.browse(cr, uid, data_id, context=context).res_id
context.update({'partner_id': partner_ids})
value = {
'name': _('Create Opportunity'),
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'crm.lead2opportunity',
'view_id': False,
'context': context,
'views': [(view_id, 'form')],
'type': 'ir.actions.act_window',
'target': 'new',
}
return value
def action_skip(self, cr, uid, ids, context=None):
"""
This skips partner creation
@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 Lead to Opportunity IDs
@param context: A standard dictionary for contextual values
@return : Dictionary value for Opportunity form
"""
value = {}
data_obj = self.pool.get('ir.model.data')
data_id = data_obj._get_id(cr, uid, 'crm', 'view_crm_lead2opportunity_create')
view_id = False
if data_id:
view_id = data_obj.browse(cr, uid, data_id, context=context).res_id
context.update({'partner_id': False})
value = {
'name': _('Create Opportunity'),
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'crm.lead2opportunity',
'view_id': False,
'context': context,
'views': [(view_id, 'form')],
'type': 'ir.actions.act_window',
'target': 'new',
}
return value
def view_init(self, cr, uid, fields, context=None):
"""
This function checks for precondition before wizard executes
@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 fields: List of fields for default value
@param context: A standard dictionary for contextual values
"""
lead_obj = self.pool.get('crm.lead')
for lead in lead_obj.browse(cr, uid, context.get('active_ids', [])):
if lead.state in ['done', 'cancel']:
raise osv.except_osv(_("Warning !"), _("Closed/Cancelled \
Leads Could not convert into Opportunity"))
if lead.state != 'open':
raise osv.except_osv(_('Warning !'), _('Lead should be in \
\'Open\' state before converting to Opportunity.'))
return False
crm_lead2opportunity_partner()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,63 +0,0 @@
<openerp>
<data>
<!-- Lead to Opportunity view -->
<record id="view_crm_lead2opportunity_create" model="ir.ui.view">
<field name="name">crm.lead2opportunity.create</field>
<field name="model">crm.lead2opportunity</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Convert To Opportunity">
<field name="name"/>
<field name="partner_id"/>
<newline/>
<field name="planned_revenue"/>
<field name="probability"/>
<separator colspan="4"/>
<group col="4" colspan="4">
<label string="" colspan="2"/>
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="action_apply" string="Create Opportunity" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<!-- Lead to Opportunity action -->
<record id="action_crm_lead2opportunity" model="ir.actions.act_window">
<field name="name">Create Opportunity</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">crm.lead2opportunity</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record id="view_crm_lead2opportunity_partner" model="ir.ui.view">
<field name="name">crm.lead2opportunity.partner.form</field>
<field name="model">crm.lead2opportunity.partner</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Create a Partner">
<label string="Are you sure you want to create a partner based on this lead ?" colspan="4"/>
<label string="You may have to verify that this partner does not exist already." colspan="4"/>
<newline />
<field name="action"/>
<group attrs="{'invisible':[('action','!=','exist')]}">
<field name="partner_id" attrs="{'required': [('action', '=', 'exist')]}"/>
</group>
<separator string="" colspan="4" />
<group col="4" colspan="4">
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button special="cancel" name="action_skip" string="_Skip" type="object" icon="gtk-goto-last"/>
<button name="make_partner" string="Continue" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
</data>
</openerp>
-216
View File
@@ -1,216 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, fields
from tools.translate import _
class crm_lead2partner(osv.osv_memory):
""" Converts lead to partner """
_name = 'crm.lead2partner'
_description = 'Lead to Partner'
_columns = {
'action': fields.selection([('exist', 'Link to an existing partner'), \
('create', 'Create a new partner')], \
'Action', required=True),
'partner_id': fields.many2one('res.partner', 'Partner')
}
def view_init(self, cr, uid, fields, context=None):
"""
This function checks for precondition before wizard executes
@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 fields: List of fields for default value
@param context: A standard dictionary for contextual values
"""
lead_obj = self.pool.get('crm.lead')
rec_ids = context and context.get('active_ids', [])
for lead in lead_obj.browse(cr, uid, rec_ids, context=context):
if lead.partner_id:
raise osv.except_osv(_('Warning !'),
_('A partner is already defined on this lead.'))
def default_get(self, cr, uid, fields, context=None):
"""
This function gets default values
@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 fields: List of fields for default value
@param context: A standard dictionary for contextual values
@return : default values of fields.
"""
lead_obj = self.pool.get('crm.lead')
partner_obj = self.pool.get('res.partner')
contact_obj = self.pool.get('res.partner.address')
rec_ids = context and context.get('active_ids', [])
partner_id = False
data = context and context.get('active_ids', []) or []
res = super(crm_lead2partner, self).default_get(cr, uid, fields, context=context)
for lead in lead_obj.browse(cr, uid, data, context=context):
partner_ids = partner_obj.search(cr, uid, [('name', '=', lead.partner_name or lead.name)])
if not partner_ids and lead.email_from:
address_ids = contact_obj.search(cr, uid, [('email', '=', lead.email_from)])
if address_ids:
addresses = contact_obj.browse(cr, uid, address_ids)
partner_ids = addresses and [addresses[0].partner_id.id] or False
partner_id = partner_ids and partner_ids[0] or False
if 'partner_id' in fields:
res.update({'partner_id': partner_id})
if 'action' in fields:
res.update({'action': partner_id and 'exist' or 'create'})
return res
def open_create_partner(self, cr, uid, ids, context=None):
"""
This function Opens form of create partner.
@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 Lead to Partner's IDs
@param context: A standard dictionary for contextual values
@return : Dictionary value for next form.
"""
if not context:
context = {}
view_obj = self.pool.get('ir.ui.view')
view_id = view_obj.search(cr, uid, [('model', '=', 'crm.lead2partner'), \
('name', '=', 'crm.lead2partner.view')])
return {
'view_mode': 'form',
'view_type': 'form',
'view_id': view_id or False,
'res_model': 'crm.lead2partner',
'context': context,
'type': 'ir.actions.act_window',
'target': 'new',
}
def _create_partner(self, cr, uid, ids, context=None):
"""
This function Creates partner based on action.
@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 Lead to Partner's IDs
@param context: A standard dictionary for contextual values
@return : Dictionary {}.
"""
if not context:
context = {}
lead_obj = self.pool.get('crm.lead')
partner_obj = self.pool.get('res.partner')
contact_obj = self.pool.get('res.partner.address')
partner_ids = []
partner_id = False
contact_id = False
rec_ids = context and context.get('active_ids', [])
for data in self.browse(cr, uid, ids):
for lead in lead_obj.browse(cr, uid, rec_ids):
if data.action == 'create':
partner_id = partner_obj.create(cr, uid, {
'name': lead.partner_name or lead.name,
'user_id': lead.user_id.id,
'comment': lead.description,
})
function_id = self.pool.get('res.partner.function').search(cr,uid,[('name','=',lead.function_name)])
contact_id = contact_obj.create(cr, uid, {
'partner_id': partner_id,
'name': lead.name,
'phone': lead.phone,
'mobile': lead.mobile,
'email': lead.email_from,
'fax': lead.fax,
'title': lead.title,
'function': function_id and function_id[0] or False,
'street': lead.street,
'street2': lead.street2,
'zip': lead.zip,
'city': lead.city,
'country_id': lead.country_id and lead.country_id.id or False,
'state_id': lead.state_id and lead.state_id.id or False,
})
else:
if data.partner_id:
partner_id = data.partner_id.id
contact_id = partner_obj.address_get(cr, uid, [partner_id])['default']
partner_ids.append(partner_id)
vals = {}
if partner_id:
vals.update({'partner_id': partner_id})
if contact_id:
vals.update({'partner_address_id': contact_id})
lead_obj.write(cr, uid, [lead.id], vals)
return partner_ids
def make_partner(self, cr, uid, ids, context=None):
"""
This function Makes partner based on action.
@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 Lead to Partner's IDs
@param context: A standard dictionary for contextual values
@return : Dictionary value for created Partner form.
"""
if not context:
context = {}
partner_ids = self._create_partner(cr, uid, ids, context)
mod_obj = self.pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'base', 'view_res_partner_filter')
res = mod_obj.read(cr, uid, result, ['res_id'])
value = {
'domain': "[]",
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'res.partner',
'res_id': partner_ids and int(partner_ids[0]) or False,
'view_id': False,
'context': context,
'type': 'ir.actions.act_window',
'search_view_id': res['res_id']
}
return value
crm_lead2partner()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,53 +0,0 @@
<openerp>
<data>
<!-- Lead to partner confirmation form -->
<record id="view_crm_lead2partner_create" model="ir.ui.view">
<field name="name">crm.lead2partner.view.create</field>
<field name="model">crm.lead2partner</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Create a Partner?">
<label string="Are you sure you want to create a partner based on this lead ?" colspan="4"/>
<label string="You may have to verify that this partner does not exist already." colspan="4"/>
<separator string="" colspan="4" />
<group col="4" colspan="4">
<button special="cancel" string="_Cancel" icon="gtk-cancel"/>
<button name="open_create_partner" string="Create _Partner" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<!-- Lead to Partner form view -->
<record id="view_crm_lead2partner" model="ir.ui.view">
<field name="name">crm.lead2partner.view</field>
<field name="model">crm.lead2partner</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Create a Partner">
<field name="action"/>
<group attrs="{'invisible':[('action','!=','exist')]}">
<field name="partner_id" attrs="{'required': [('action', '=', 'exist')]}"/>
</group>
<separator string="" colspan="4" />
<group col="4" colspan="4">
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="make_partner" string="Continue" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<!-- Lead to Partner wizard -->
<act_window id="action_crm_lead2partner"
key2="client_action_multi" name="Create a Partner"
res_model="crm.lead2partner" src_model="crm.lead"
view_id="view_crm_lead2partner_create"
view_mode="form" target="new" view_type="form" />
</data>
</openerp>
@@ -1,139 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, fields
from tools.translate import _
class crm_opportunity2phonecall(osv.osv_memory):
"""Converts Opportunity to Phonecall"""
_name = 'crm.opportunity2phonecall'
_description = 'Opportunity to Phonecall'
_columns = {
'name' : fields.char('Call summary', size=64, required=True, select=1),
'user_id' : fields.many2one('res.users', "Assign To"),
'date': fields.datetime('Date' , required=True),
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
}
def default_get(self, cr, uid, fields, context=None):
"""
This function gets default values
@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 fields: List of fields for default value
@param context: A standard dictionary for contextual values
@return : default values of fields.
"""
opp_obj = self.pool.get('crm.opportunity')
record_ids = context and context.get('active_ids', []) or []
res = super(crm_opportunity2phonecall, self).default_get(cr, uid, fields, context=context)
for opp in opp_obj.browse(cr, uid, record_ids, context=context):
if 'name' in fields:
res.update({'name': opp.name})
if 'user_id' in fields:
res.update({'user_id': opp.user_id and opp.user_id.id or False})
if 'section_id' in fields:
res.update({'section_id': opp.section_id and opp.section_id.id or False})
return res
def action_cancel(self, cr, uid, ids, context=None):
"""
Closes Opportunity to Phonecall 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 Phonecall's IDs
@param context: A standard dictionary for contextual values
"""
return {'type': 'ir.actions.act_window_close'}
def action_apply(self, cr, uid, ids, context=None):
"""
This converts Opportunity to Phonecall and opens Phonecall view
@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 Phonecall IDs
@param context: A standard dictionary for contextual values
@return : Dictionary value for created Opportunity form
"""
value = {}
record_ids = context and context.get('active_ids', []) or []
phonecall_obj = self.pool.get('crm.phonecall')
opp_obj = self.pool.get('crm.opportunity')
mod_obj = self.pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'crm', 'view_crm_case_phonecalls_filter')
res = mod_obj.read(cr, uid, result, ['res_id'])
data_obj = self.pool.get('ir.model.data')
categ_id = mod_obj._get_id(cr, uid, 'crm', 'categ_phone1')
categ_id = data_obj.browse(cr, uid, categ_id, context=context).res_id
# Select the view
id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_phone_tree_view')
id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_phone_form_view')
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):
new_case = phonecall_obj.create(cr, uid, {
'name' : opp.name,
'case_id' : opp.id ,
'user_id' : this.user_id and this.user_id.id or False,
'categ_id' : categ_id,
'description' : opp.description or False,
'date' : this.date,
'section_id' : opp.section_id and opp.section_id.id or False,
'partner_id': opp.partner_id and opp.partner_id.id or False,
'partner_address_id': opp.partner_address_id and opp.partner_address_id.id or False,
'partner_phone' : opp.phone or (opp.partner_address_id and opp.partner_address_id.phone or False),
'partner_mobile' : opp.partner_address_id and opp.partner_address_id.mobile or False,
'priority': opp.priority,
'opp_id': opp.id
}, context=context)
phonecall_obj.case_open(cr, uid, [new_case])
value = {
'name': _('Phone Call'),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'crm.phonecall',
'res_id' : new_case,
'views': [(id3, 'form'), (id2, 'tree'), (False, 'calendar'), (False, 'graph')],
'type': 'ir.actions.act_window',
'search_view_id': res['res_id']
}
return value
crm_opportunity2phonecall()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,41 +0,0 @@
<?xml version="1.0"?>
<openerp>
<data>
<!-- Opportunity to Phonecall view -->
<record model="ir.ui.view" id="opportunity2phonecall_view">
<field name="name">crm.opportunity2phonecall.form</field>
<field name="model">crm.opportunity2phonecall</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Schedule Other Call">
<group colspan="2" >
<field name="name"/>
<field name="date" string="Planned Date"/>
<newline/>
<field name="user_id" />
<field name="section_id"/>
<label string ="" colspan="2"/>
<button name="action_cancel" string="_Cancel"
icon="gtk-cancel" special="cancel" />
<button name="action_apply" type="object"
string="_Schedule Call" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<!-- Opportunity to Phonecall action -->
<record model="ir.actions.act_window" id="opportunity2phonecall_act">
<field name="name">Schedule Call</field>
<field name="res_model">crm.opportunity2phonecall</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="opportunity2phonecall_view"/>
<field name="target">new</field>
</record>
</data>
</openerp>
+2 -1
View File
@@ -76,7 +76,8 @@ class crm_send_new_email(osv.osv_memory):
case = case_pool.browse(cr, uid, res_id)
if context.get('mail', 'new') == 'new':
message_id = case.history_line[0].message_id
if case.history_line:
message_id = case.history_line[0].message_id
else:
hist = hist_obj.browse(cr, uid, res_id)
message_id = hist.message_id