[ADD] partner assignement + [FIX] assign in the country then closest
bzr revid: tfr@openerp.com-20110310095321-0dv7e4yr3ezul89r
This commit is contained in:
parent
c2531d6426
commit
e70d9106c2
|
@ -36,6 +36,7 @@ based on geolocalization.
|
|||
'wizard/crm_forward_to_partner_view.xml',
|
||||
'crm_lead_view.xml',
|
||||
'report/crm_lead_report_view.xml',
|
||||
'report/crm_partner_report_view.xml',
|
||||
],
|
||||
'test': ['test/test_crm_partner_assign.yml'],
|
||||
'installable': True,
|
||||
|
|
|
@ -142,21 +142,6 @@ class crm_lead(osv.osv):
|
|||
('country', '=', part.country_id.id),
|
||||
], context=context)
|
||||
|
||||
# 3. third way: other countries, small area
|
||||
if not part_ids:
|
||||
part_ids = self.pool.get('res.partner').search(cr, uid, [
|
||||
('partner_weight','>',0),
|
||||
('partner_latitude','>',result[0]-2), ('partner_latitude','<',result[0]+2),
|
||||
('partner_longitude','>',result[1]-1.5), ('partner_longitude','<',result[1]+1.5)
|
||||
], context=context)
|
||||
|
||||
# 4. fourth way: other countries, big area
|
||||
if not part_ids:
|
||||
part_ids = self.pool.get('res.partner').search(cr, uid, [
|
||||
('partner_weight','>',0),
|
||||
('partner_latitude','>',result[0]-4), ('partner_latitude','<',result[0]+4),
|
||||
('partner_longitude','>',result[1]-3), ('partner_longitude','<',result[1]+3)
|
||||
], context=context)
|
||||
|
||||
# 5. fifth way: anywhere in same country
|
||||
if not part_ids:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,9 +15,10 @@
|
|||
# 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/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import crm_lead_report
|
||||
import crm_partner_report
|
||||
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
# -*- 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
|
||||
|
||||
|
||||
class crm_partner_report_assign(osv.osv):
|
||||
""" CRM Lead Report """
|
||||
_name = "crm.partner.report.assign"
|
||||
_auto = False
|
||||
_description = "CRM Partner Report"
|
||||
_columns = {
|
||||
'name': fields.char('Partner name', size=64, required=False, readonly=True),
|
||||
'grade_id':fields.many2one('res.partner.grade', 'Grade', readonly=True),
|
||||
'user_id':fields.many2one('res.users', 'User', readonly=True),
|
||||
'country_id':fields.many2one('res.country', 'Country', readonly=True),
|
||||
'section_id':fields.many2one('crm.case.section', 'Sales Team', readonly=True),
|
||||
'nbr': fields.integer('# of Partner', readonly=True),
|
||||
'opp': fields.integer('# of Opportunity', 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_partner_report_assign')
|
||||
cr.execute("""
|
||||
CREATE OR REPLACE VIEW crm_partner_report_assign AS (
|
||||
SELECT
|
||||
p.id,
|
||||
p.name,
|
||||
a.country_id,
|
||||
p.grade_id,
|
||||
p.user_id,
|
||||
p.section_id,
|
||||
1 as nbr,
|
||||
(SELECT count(id) FROM crm_lead WHERE partner_assigned_id=p.id) AS opp
|
||||
FROM
|
||||
res_partner p
|
||||
left join res_partner_address a on (p.id=a.partner_id)
|
||||
)""")
|
||||
|
||||
crm_partner_report_assign()
|
|
@ -0,0 +1,69 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Opportunity tree view -->
|
||||
<record id="view_report_crm_partner_assign_filter" model="ir.ui.view">
|
||||
<field name="name">crm.partner.report.assign.select</field>
|
||||
<field name="model">crm.partner.report.assign</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Partner assigned Analysis">
|
||||
<group col="20" colspan="8">
|
||||
<field name="country_id" />
|
||||
<field name="grade_id"/>
|
||||
<field name="user_id"/>
|
||||
<field name="section_id"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="1" string="Group By...">
|
||||
<filter string="Salesman" name="user" icon="terp-personal"
|
||||
domain="[]" context="{'group_by':'user_id'}" />
|
||||
<filter string="Country" icon="terp-go-home" name="group_country" context="{'group_by':'country_id'}" />
|
||||
<separator orientation="vertical" />
|
||||
<filter string="Section" icon="terp-personal+"
|
||||
domain="[]"
|
||||
context="{'group_by':'section_id'}" />
|
||||
<filter string="Grade" name="group_grade" icon="terp-stock_symbol-selection"
|
||||
domain="[]" context="{'group_by':'grade_id'}" />
|
||||
<separator orientation="vertical" />
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Crm Lead Assign report Graph View -->
|
||||
|
||||
<record id="view_report_crm_partner_assign_tree" model="ir.ui.view">
|
||||
<field name="name">crm.partner.assign.report.tree</field>
|
||||
<field name="model">crm.partner.report.assign</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Opportunities Assignment Analysis">
|
||||
<field name="name" invisible="1"/>
|
||||
<field name="country_id" invisible="1"/>
|
||||
<field name="grade_id" invisible="1"/>
|
||||
<field name="section_id" invisible="1" groups="base.group_extended"/>
|
||||
<field name="user_id" invisible="1"/>
|
||||
<field name="nbr" string="#Partner" sum="#Partner"/>
|
||||
<field name="opp"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Leads by user and section Action -->
|
||||
|
||||
<record id="action_report_crm_partner_assign" model="ir.actions.act_window">
|
||||
<field name="name">Partner Assignment Analysis</field>
|
||||
<field name="res_model">crm.partner.report.assign</field>
|
||||
<field name="context">{'search_default_group_country': 1, 'search_default_group_grade': 1, 'group_by_no_leaf':1,'group_by':[]}</field>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="domain">[('grade_id', '!=', False)]</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_report_crm_partner_assign_tree"
|
||||
groups="base.group_extended"
|
||||
parent="base.next_id_64" action="action_report_crm_partner_assign" sequence="5"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue