[REF] crm,sale,sales_team,website_crm_score: clean kanban view
This commit is contained in:
@@ -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."),
|
||||
}
|
||||
|
||||
|
||||
@@ -91,8 +91,6 @@
|
||||
<field name="alias_domain"/>
|
||||
<field name="use_leads"/>
|
||||
<field name="use_opportunities"/>
|
||||
<field name="monthly_open_leads"/>
|
||||
<field name="monthly_planned_revenue"/>
|
||||
</xpath>
|
||||
<xpath expr="//h4[@name='name']" position="after">
|
||||
<div class="oe_kanban_alias text-center" t-if="record.use_leads.raw_value and record.alias_name.value and record.alias_domain.value">
|
||||
@@ -103,19 +101,13 @@
|
||||
<div class="col-md-6 oe_margin_top_4" t-if="record.use_leads.raw_value">
|
||||
<div class="row">
|
||||
<a class="col-md-9" name="%(crm_case_form_view_salesteams_lead)d" type="action">Leads</a>
|
||||
<a class="col-md-3" name="%(action_report_crm_lead_salesteam)d" type="action">
|
||||
<field name="monthly_open_leads" widget="sparkline_bar"
|
||||
options="{'height': '20px', 'barWidth': 4, 'barSpacing': 1, 'delayIn': '3000', 'tooltip_suffix': ' Leads'}">Open Leads per Month<br/>Click to see a detailed analysis of leads.</field>
|
||||
</a>
|
||||
<a class="col-md-3" name="%(action_report_crm_lead_salesteam)d" type="action"><i class="fa fa-tags fa-fw"/></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 oe_margin_top_4" t-if="record.use_opportunities.raw_value">
|
||||
<div class="row">
|
||||
<a class="col-md-9" name="%(crm_case_form_view_salesteams_opportunity)d" type="action">Opportunities</a>
|
||||
<a class="col-md-3" name="%(action_report_crm_opportunity_salesteam)d" type="action">
|
||||
<field name="monthly_planned_revenue" widget="sparkline_bar"
|
||||
options="{'height': '20px', 'barWidth': '4', 'barSpacing': '1', 'delayIn': '3000', 'tooltip_suffix': ' (Planned Revenue)'}">Planned Revenue per Month<br/>Click to see a detailed analysis of opportunities.</field>
|
||||
</a>
|
||||
<a class="col-md-3" name="%(action_report_crm_opportunity_salesteam)d" type="action"><i class="fa fa-star fa-fw"/></a>
|
||||
</div>
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
<data>
|
||||
<xpath expr="//field[@name='name']" position="after">
|
||||
<field name="use_quotations"/>
|
||||
<field name="monthly_quoted"/>
|
||||
<field name="monthly_confirmed"/>
|
||||
<field name="monthly_invoiced"/>
|
||||
<field name="invoiced_forecast"/>
|
||||
<field name="invoiced_target"/>
|
||||
@@ -36,31 +34,19 @@
|
||||
<div class="col-md-6 oe_margin_top_4" t-if="record.use_quotations.raw_value">
|
||||
<div class="row">
|
||||
<a class="col-md-9" name="%(action_quotations_salesteams)d" type="action">Quotations</a>
|
||||
<a class="col-md-3" name="%(action_order_report_quotation_salesteam)d" type="action">
|
||||
<field name="monthly_quoted" widget="sparkline_bar" options="{'delayIn': '3000'}">
|
||||
Revenue of created quotations per month.<br/>Click to see a detailed analysis.
|
||||
</field>
|
||||
</a>
|
||||
<a class="col-md-3" name="%(action_order_report_quotation_salesteam)d" type="action"><i class="fa fa-usd fa-fw"/></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 oe_margin_top_4">
|
||||
<div class="row">
|
||||
<a class="col-md-9" name="%(action_orders_salesteams)d" type="action">Sales Orders</a>
|
||||
<a class="col-md-3" name="%(action_order_report_so_salesteam)d" type="action">
|
||||
<field name="monthly_confirmed" widget="sparkline_bar" options="{'delayIn': '3000'}">
|
||||
Revenue of confirmed sales orders per month.<br/>Click to acces the Sales Analysis.
|
||||
</field>
|
||||
</a>
|
||||
<a class="col-md-3" name="%(action_order_report_so_salesteam)d" type="action"><i class="fa fa-strikethrough fa-fw"/></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 oe_margin_top_4" groups="account.group_account_invoice">
|
||||
<div class="row">
|
||||
<a class="col-md-9" name="%(action_invoice_salesteams)d" type="action">Invoices</a>
|
||||
<a class="col-md-3" name="%(action_account_invoice_report_salesteam)d" type="action">
|
||||
<field name="monthly_invoiced" widget="sparkline_bar" options="{'delayIn': '3000'}">
|
||||
Revenue of sent invoices per month.<br/>Click to see a detailed analysis of invoices.
|
||||
</field>
|
||||
</a>
|
||||
<a class="col-md-3" name="%(action_account_invoice_report_salesteam)d" type="action"><i class="fa fa-pencil-square-o fa-fw" /></a>
|
||||
</div>
|
||||
</div>
|
||||
</xpath>
|
||||
@@ -73,7 +59,7 @@
|
||||
</div>
|
||||
</xpath>
|
||||
<xpath expr="//div[@class='oe_clear']" position="after">
|
||||
<div class="text-center" style="color:#bbbbbb;" t-if="!record.invoiced_target.raw_value">
|
||||
<div class="text-center" style="color:#bbbbbb; min-height:132px" t-if="!record.invoiced_target.raw_value">
|
||||
<br/>Define an invoicing target in the sales team settings to see the period's achievement and forecast at a glance.
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
@@ -34,11 +34,6 @@
|
||||
<span name="oe_salesteam_separator"/>
|
||||
</div>
|
||||
<div class="oe_clear"></div>
|
||||
<div class="oe_kanban_salesteams_avatars">
|
||||
<t t-foreach="record.member_ids.raw_value.slice(0,10)" t-as="member">
|
||||
<img class="img-rounded oe_kanban_avatar_smallbox" t-att-src="kanban_image('res.users', 'image_small', member)" t-att-data-member_id="member"/>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
@@ -100,35 +100,6 @@
|
||||
</record>
|
||||
|
||||
<!-- SALESTEAM -->
|
||||
<!-- SalesTeam Kanban View - Lead information added -->
|
||||
<record id="crm_team_salesteams_view_kanban_inherit" model="ir.ui.view">
|
||||
<field name="name">crm.team.kanban.inherit</field>
|
||||
<field name="model">crm.team</field>
|
||||
<field name="inherit_id" ref="sales_team.crm_team_salesteams_view_kanban"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//templates" position="before">
|
||||
<field name="user_ids"/>
|
||||
</xpath>
|
||||
<field name="member_ids" position="after">
|
||||
<field name="team_user_ids"/>
|
||||
</field>
|
||||
<xpath expr="//div[@class='oe_clear']" position="after">
|
||||
<div class="text-center text-muted">
|
||||
Capacity: <b><field name="capacity"/></b> |
|
||||
Lead count: <b><field name="leads_count"/></b> |
|
||||
Assigned: <b><field name="assigned_leads"/></b>
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//div[@class='oe_kanban_salesteams_avatars']" position="replace">
|
||||
<t t-foreach="record.user_ids.raw_value.slice(0,10)" t-as="member">
|
||||
<img t-att-src="kanban_image('res.users', 'image_small', member)" class="img-rounded oe_kanban_avatar_smallbox" />
|
||||
</t>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Graph view of leads via SalesTeam -->
|
||||
<record model="ir.ui.view" id="crm_case_graph_view_leads_sales">
|
||||
|
||||
Reference in New Issue
Block a user