From 35ace3321daafd6bd45fcff5d3d00f8b31995dca Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Tue, 27 Jan 2015 15:39:58 +0100 Subject: [PATCH] [REF] crm,sale,sales_team,website_crm_score: clean kanban view --- addons/crm/sales_team.py | 36 ------------------------ addons/crm/sales_team_view.xml | 12 ++------ addons/sale/sales_team.py | 22 --------------- addons/sale/sales_team_view.xml | 22 +++------------ addons/sales_team/sales_team.xml | 5 ---- addons/website_crm_score/views/sales.xml | 29 ------------------- 6 files changed, 6 insertions(+), 120 deletions(-) diff --git a/addons/crm/sales_team.py b/addons/crm/sales_team.py index 71f32a8544d..69907b2b4a0 100644 --- a/addons/crm/sales_team.py +++ b/addons/crm/sales_team.py @@ -1,11 +1,5 @@ # -*- coding: utf-8 -*- -import calendar -from datetime import date -from dateutil import relativedelta -import json - -from openerp import tools from openerp.osv import fields, osv @@ -13,42 +7,12 @@ class crm_team(osv.Model): _inherit = 'crm.team' _inherits = {'mail.alias': 'alias_id'} - def _get_opportunities_data(self, cr, uid, ids, field_name, arg, context=None): - """ Get opportunities-related data for salesteam kanban view - monthly_open_leads: number of open lead during the last months - monthly_planned_revenue: planned revenu of opportunities during the last months - """ - obj = self.pool.get('crm.lead') - res = dict.fromkeys(ids, False) - month_begin = date.today().replace(day=1) - date_begin = month_begin - relativedelta.relativedelta(months=self._period_number - 1) - date_end = month_begin.replace(day=calendar.monthrange(month_begin.year, month_begin.month)[1]) - lead_pre_domain = [('create_date', '>=', date_begin.strftime(tools.DEFAULT_SERVER_DATE_FORMAT)), - ('create_date', '<=', date_end.strftime(tools.DEFAULT_SERVER_DATE_FORMAT)), - ('type', '=', 'lead')] - opp_pre_domain = [('date_deadline', '>=', date_begin.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)), - ('date_deadline', '<=', date_end.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)), - ('type', '=', 'opportunity')] - for id in ids: - res[id] = dict() - lead_domain = lead_pre_domain + [('team_id', '=', id)] - opp_domain = opp_pre_domain + [('team_id', '=', id)] - res[id]['monthly_open_leads'] = json.dumps(self.__get_bar_values(cr, uid, obj, lead_domain, ['create_date'], 'create_date_count', 'create_date', context=context)) - res[id]['monthly_planned_revenue'] = json.dumps(self.__get_bar_values(cr, uid, obj, opp_domain, ['planned_revenue', 'date_deadline'], 'planned_revenue', 'date_deadline', context=context)) - return res - _columns = { 'resource_calendar_id': fields.many2one('resource.calendar', "Working Time", help="Used to compute open days"), 'stage_ids': fields.many2many('crm.stage', 'crm_team_stage_rel', 'team_id', 'stage_id', 'Stages'), 'use_leads': fields.boolean('Leads', help="The first contact you get with a potential customer is a lead you qualify before converting it into a real business opportunity. Check this box to manage leads in this sales team."), 'use_opportunities': fields.boolean('Opportunities', help="Check this box to manage opportunities in this sales team."), - 'monthly_open_leads': fields.function(_get_opportunities_data, - type="char", readonly=True, multi='_get_opportunities_data', - string='Open Leads per Month'), - 'monthly_planned_revenue': fields.function(_get_opportunities_data, - type="char", readonly=True, multi='_get_opportunities_data', - string='Planned Revenue per Month'), 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="restrict", required=True, help="The email address associated with this team. New emails received will automatically create new leads assigned to the team."), } diff --git a/addons/crm/sales_team_view.xml b/addons/crm/sales_team_view.xml index efbc0214842..64ea92a4055 100644 --- a/addons/crm/sales_team_view.xml +++ b/addons/crm/sales_team_view.xml @@ -91,8 +91,6 @@ - -
@@ -103,19 +101,13 @@ diff --git a/addons/sale/sales_team.py b/addons/sale/sales_team.py index 4f5c29acad5..7e071b03c62 100644 --- a/addons/sale/sales_team.py +++ b/addons/sale/sales_team.py @@ -12,22 +12,6 @@ from openerp.tools.float_utils import float_repr class crm_team(osv.Model): _inherit = 'crm.team' - def _get_sale_orders_data(self, cr, uid, ids, field_name, arg, context=None): - obj = self.pool['sale.order'] - month_begin = date.today().replace(day=1) - date_begin = (month_begin - relativedelta.relativedelta(months=self._period_number - 1)).strftime(tools.DEFAULT_SERVER_DATE_FORMAT) - date_end = month_begin.replace(day=calendar.monthrange(month_begin.year, month_begin.month)[1]).strftime(tools.DEFAULT_SERVER_DATE_FORMAT) - - res = {} - for id in ids: - res[id] = {} - created_domain = [('team_id', '=', id), ('state', '=', 'draft'), ('date_order', '>=', date_begin), ('date_order', '<=', date_end)] - validated_domain = [('team_id', '=', id), ('state', 'not in', ['draft', 'sent', 'cancel']), ('date_order', '>=', date_begin), ('date_order', '<=', date_end)] - res[id]['monthly_quoted'] = json.dumps(self.__get_bar_values(cr, uid, obj, created_domain, ['amount_total', 'date_order'], 'amount_total', 'date_order', context=context)) - res[id]['monthly_confirmed'] = json.dumps(self.__get_bar_values(cr, uid, obj, validated_domain, ['amount_total', 'date_order'], 'amount_total', 'date_order', context=context)) - - return res - def _get_invoices_data(self, cr, uid, ids, field_name, arg, context=None): obj = self.pool['account.invoice.report'] month_begin = date.today().replace(day=1) @@ -52,12 +36,6 @@ class crm_team(osv.Model): 'invoiced_target': fields.integer(string='Invoice Target', help="Target of invoice revenue for the current month. This is the amount the sales \n" "team estimates to be able to invoice this month."), - 'monthly_quoted': fields.function(_get_sale_orders_data, - type='char', readonly=True, multi='_get_sale_orders_data', - string='Rate of created quotation per duration'), - 'monthly_confirmed': fields.function(_get_sale_orders_data, - type='char', readonly=True, multi='_get_sale_orders_data', - string='Rate of validate sales orders per duration'), 'monthly_invoiced': fields.function(_get_invoices_data, type='char', readonly=True, string='Rate of sent invoices per duration'), diff --git a/addons/sale/sales_team_view.xml b/addons/sale/sales_team_view.xml index a44b4ad169e..6dfb23ccdb6 100644 --- a/addons/sale/sales_team_view.xml +++ b/addons/sale/sales_team_view.xml @@ -26,8 +26,6 @@ - - @@ -36,31 +34,19 @@ @@ -73,7 +59,7 @@
-
+

Define an invoicing target in the sales team settings to see the period's achievement and forecast at a glance.
diff --git a/addons/sales_team/sales_team.xml b/addons/sales_team/sales_team.xml index 185fe755d2f..3ea69c61a2e 100644 --- a/addons/sales_team/sales_team.xml +++ b/addons/sales_team/sales_team.xml @@ -34,11 +34,6 @@
-
- - - -
diff --git a/addons/website_crm_score/views/sales.xml b/addons/website_crm_score/views/sales.xml index bf59e7e4b62..565c71501b9 100644 --- a/addons/website_crm_score/views/sales.xml +++ b/addons/website_crm_score/views/sales.xml @@ -100,35 +100,6 @@ - - - crm.team.kanban.inherit - crm.team - - - - - - - - - - -
- Capacity: | - Lead count: | - Assigned: -
-
- - - - - - -
-
-