1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
21 from osv import fields,osv
25 class crm_partner_report_assign(osv.osv):
26 """ CRM Lead Report """
27 _name = "crm.partner.report.assign"
29 _description = "CRM Partner Report"
31 'name': fields.char('Partner name', size=64, required=False, readonly=True),
32 'grade_id':fields.many2one('res.partner.grade', 'Grade', readonly=True),
33 'user_id':fields.many2one('res.users', 'User', readonly=True),
34 'country_id':fields.many2one('res.country', 'Country', readonly=True),
35 'section_id':fields.many2one('crm.case.section', 'Sales Team', readonly=True),
36 'nbr': fields.integer('# of Partner', readonly=True),
37 'opp': fields.integer('# of Opportunity', readonly=True),
44 @param cr: the current row, from the database cursor
46 tools.drop_view_if_exists(cr, 'crm_partner_report_assign')
48 CREATE OR REPLACE VIEW crm_partner_report_assign AS (
52 (SELECT country_id FROM res_partner_address a WHERE a.partner_id=p.id AND country_id is not null limit 1) as country_id,
57 (SELECT count(id) FROM crm_lead WHERE partner_assigned_id=p.id) AS opp
63 crm_partner_report_assign()