[IMP] crm: salesteams
bzr revid: chm@openerp.com-20130417104302-g4zjti19suenxnky
This commit is contained in:
parent
f6b6035922
commit
f515c23a13
|
@ -44,6 +44,13 @@ AVAILABLE_PRIORITIES = [
|
|||
('5', 'Lowest'),
|
||||
]
|
||||
|
||||
duration_txt = {
|
||||
"monthly": _("this month"),
|
||||
"semesterly": _("this semester"),
|
||||
"semiannually": _("this semi"),
|
||||
"annually": _("this year")
|
||||
}
|
||||
|
||||
class crm_case_channel(osv.osv):
|
||||
_name = "crm.case.channel"
|
||||
_description = "Channels"
|
||||
|
@ -110,6 +117,12 @@ class crm_case_section(osv.osv):
|
|||
def get_full_name(self, cr, uid, ids, field_name, arg, context=None):
|
||||
return dict(self.name_get(cr, uid, ids, context=context))
|
||||
|
||||
def _get_target_duration_txt(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = dict.fromkeys(ids, "")
|
||||
for section in self.browse(cr, uid, ids, context=context):
|
||||
res[section.id] = duration_txt[section.target_duration]
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Sales Team', size=64, required=True, translate=True),
|
||||
'complete_name': fields.function(get_full_name, type='char', size=256, readonly=True, store=True),
|
||||
|
@ -138,6 +151,11 @@ class crm_case_section(osv.osv):
|
|||
'color': fields.integer('Color Index'),
|
||||
'use_leads': fields.boolean('Leads',
|
||||
help="This enables the management of leads in the sales team. Otherwise the sales team manages only opportunities."),
|
||||
'target_duration': fields.selection([("monthly", "Monthly"), ("semesterly", "Semesterly"), ("semiannually", "Semiannually"), ("annually", "Annually")],
|
||||
string='Report duration view', required=True),
|
||||
'target_duration_txt': fields.function(_get_target_duration_txt,
|
||||
string='Duration',
|
||||
type="string", readonly=True),
|
||||
}
|
||||
|
||||
def _get_stage_common(self, cr, uid, context):
|
||||
|
@ -148,6 +166,7 @@ class crm_case_section(osv.osv):
|
|||
'active': 1,
|
||||
'stage_ids': _get_stage_common,
|
||||
'use_leads': True,
|
||||
'target_duration': "monthly",
|
||||
}
|
||||
|
||||
_sql_constraints = [
|
||||
|
|
|
@ -81,6 +81,7 @@
|
|||
<field name="color"/>
|
||||
<field name="open_lead_ids"/>
|
||||
<field name="open_opportunity_ids"/>
|
||||
<field name="target_duration_txt"/>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_global_click oe_kanban_crm_salesteams">
|
||||
|
@ -98,21 +99,15 @@
|
|||
<small><span class="oe_e" style="float: none;">%%</span><t t-raw="record.alias_id.raw_value[1]"/></small>
|
||||
</div>
|
||||
<div class="oe_items_list">
|
||||
<a t-if="record.use_leads.raw_value" name="%(crm_case_form_view_salesteams_lead)d" type="action">
|
||||
<t t-raw="record.open_lead_ids.raw_value.length"/>
|
||||
<t t-if="record.open_lead_ids.raw_value.length >= 2">Leads</t>
|
||||
<t t-if="record.open_lead_ids.raw_value.length < 2">Lead</t></a>
|
||||
<a name="%(crm_case_form_view_salesteams_opportunity)d" type="action">
|
||||
<t t-raw="record.open_opportunity_ids.raw_value.length"/>
|
||||
<t t-if="record.open_opportunity_ids.raw_value.length >= 2">Opportunities</t>
|
||||
<t t-if="record.open_opportunity_ids.raw_value.length < 2">Opportunity</t></a>
|
||||
<div>
|
||||
<a t-if="record.use_leads.raw_value" name="%(crm_case_form_view_salesteams_lead)d" type="action"><t t-raw="record.open_lead_ids.raw_value.length"/><t t-if="record.open_lead_ids.raw_value.length >= 2">Leads</t><t t-if="record.open_lead_ids.raw_value.length < 2">Lead</t></a>
|
||||
<a name="%(crm_case_form_view_salesteams_lead)d" type="action" class="oe_sparkline_bar"><t t-raw="[6,4,7,2]"/></a>
|
||||
</div>
|
||||
<div>
|
||||
<a name="%(crm_case_form_view_salesteams_opportunity)d" type="action"><t t-raw="record.open_opportunity_ids.raw_value.length"/><t t-if="record.open_opportunity_ids.raw_value.length >= 2">Opportunities</t><t t-if="record.open_opportunity_ids.raw_value.length < 2">Opportunity</t></a>
|
||||
<a name="%(crm_case_form_view_salesteams_opportunity)d" type="action" class="oe_sparkline_bar"><t t-raw="[6,4,7,2]"/></a>
|
||||
</div>
|
||||
</div>
|
||||
<!--div class="oe_avatars">
|
||||
<img t-if="record.user_id.raw_value" t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-data-member_id="record.user_id.raw_value"/>
|
||||
<t t-foreach="record.member_ids.raw_value.slice(0,11)" t-as="member">
|
||||
<img t-att-src="kanban_image('res.users', 'image_small', member)" t-att-data-member_id="member"/>
|
||||
</t>
|
||||
</div-->
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
@ -178,6 +173,9 @@
|
|||
<field name="user_id"/>
|
||||
<field name="code"/>
|
||||
</group>
|
||||
<group colspan="4" col="4">
|
||||
<field name="target_duration" widget="radio"/>
|
||||
</group>
|
||||
<group colspan="4" attrs="{'invisible': [('use_leads', '=', False)]}">
|
||||
|
||||
</group>
|
||||
|
|
|
@ -20,11 +20,27 @@
|
|||
}
|
||||
|
||||
.openerp .oe_kanban_view .oe_kanban_crm_salesteams .oe_items_list {
|
||||
position: relative;
|
||||
margin: 10px;
|
||||
}
|
||||
.openerp .oe_kanban_view .oe_kanban_crm_salesteams .oe_items_list a {
|
||||
width: 160px;
|
||||
display: inline-block;
|
||||
.openerp .oe_kanban_view .oe_kanban_crm_salesteams .oe_items_list div {
|
||||
width: 120px;
|
||||
height: 20px;
|
||||
margin: 0;
|
||||
}
|
||||
.openerp .oe_kanban_view .oe_kanban_crm_salesteams .oe_items_list div:nth-child(2n) {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
}
|
||||
.openerp .oe_kanban_view .oe_kanban_crm_salesteams .oe_items_list div:nth-child(2n) a {
|
||||
position: relative;
|
||||
top: -20px;
|
||||
}
|
||||
.openerp .oe_kanban_view .oe_kanban_crm_salesteams .oe_kanban_content > div {
|
||||
clear: both;
|
||||
}
|
||||
.openerp .oe_kanban_view .oe_kanban_crm_salesteams .oe_items_list div a:first-child {
|
||||
width: 80px;
|
||||
}
|
||||
.openerp .oe_kanban_view .oe_kanban_crm_salesteams .oe_items_list a:hover {
|
||||
text-decoration: underline !important;
|
||||
|
@ -44,4 +60,8 @@
|
|||
.openerp .oe_kanban_view .oe_justgage {
|
||||
color: black;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.openerp .oe_kanban_view .oe_sparkline_bar {
|
||||
float: right;
|
||||
}
|
|
@ -32,29 +32,36 @@ openerp.crm = function(openerp) {
|
|||
if ($el.data('action')) {
|
||||
$el.click(function (event) {
|
||||
event.stopPropagation();
|
||||
if (self.view.is_action_enabled('edit') && !$el.find(".oe_justgage_edit").size()) {
|
||||
if (!self.view.is_action_enabled('edit')) {
|
||||
return;
|
||||
}
|
||||
if ($el.find(".oe_justgage_edit").size()) {
|
||||
$el.find(".oe_justgage_edit").remove();
|
||||
} else {
|
||||
var $svg = $el.find('svg');
|
||||
$div = $('<div class="oe_justgage_edit" style="z-index: 1; position: absolute; width: ' + $svg.width() + 'px; top: ' + ($svg.height()/2-5) + 'px;"/>');
|
||||
$input = $('<input style="text-align: center; width: ' + ($svg.width()-40) + 'px; margin: auto;"/>').val($el.data('value'));
|
||||
$div.append($input);
|
||||
$el.prepend($div)
|
||||
$input.focus();
|
||||
$input.keydown(function (event) {
|
||||
event.stopPropagation();
|
||||
if (event.keyCode == 13 || event.keyCode == 9) {
|
||||
if ($input.val() != $el.data('value')) {
|
||||
self.view.dataset.call($el.data('action'), [self.id, $input.val()]).then(function () {
|
||||
self.do_reload();
|
||||
});
|
||||
} else {
|
||||
$div.remove();
|
||||
$input.focus()
|
||||
.keydown(function (event) {
|
||||
event.stopPropagation();
|
||||
if (event.keyCode == 13 || event.keyCode == 9) {
|
||||
if ($input.val() != $el.data('value')) {
|
||||
self.view.dataset.call($el.data('action'), [self.id, $input.val()]).then(function () {
|
||||
self.do_reload();
|
||||
});
|
||||
} else {
|
||||
$div.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
.click(function (event) {event.stopPropagation();});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
setTimeout(function () {self.$(".oe_sparkline_bar").sparkline('html', {type: 'bar', barWidth: 5, zeroColor: '#ff0000'} );}, 0);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
|
@ -48,26 +48,13 @@ class crm_case_section(osv.osv):
|
|||
"annually": 11
|
||||
}
|
||||
for section in self.browse(cr, uid, ids, context=context):
|
||||
when = date.today().replace(day=1) + relativedelta(months=-previous_month[section.target_invoice_duration])
|
||||
when = date.today().replace(day=1) + relativedelta(months=-previous_month[section.target_duration])
|
||||
|
||||
invoice_ids = obj.search(cr, uid, [("section_id", "=", section.id), ('state', 'not in', ['draft', 'cancel']), ('date', '>=', when)], context=context)
|
||||
for invoice in obj.browse(cr, uid, invoice_ids, context=context):
|
||||
res[section.id] += invoice.price_total
|
||||
return res
|
||||
|
||||
def _get_target_invoice_duration_txt(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = dict.fromkeys(ids, "")
|
||||
|
||||
duration_txt = {
|
||||
"monthly": _("this month"),
|
||||
"semesterly": _("this semester"),
|
||||
"semiannually": _("this semi"),
|
||||
"annually": _("this year")
|
||||
}
|
||||
for section in self.browse(cr, uid, ids, context=context):
|
||||
res[section.id] = duration_txt[section.target_invoice_duration]
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'quotation_ids': fields.one2many('sale.order', 'section_id',
|
||||
string='Quotations', readonly=True,
|
||||
|
@ -83,14 +70,6 @@ class crm_case_section(osv.osv):
|
|||
type='integer', readonly=True),
|
||||
'forcasted': fields.integer(string='Total forcasted'),
|
||||
'target_invoice': fields.integer(string='Target Invoice'),
|
||||
'target_invoice_duration': fields.selection([("monthly", "Monthly"), ("semesterly", "Semesterly"), ("semiannually", "Semiannually"), ("annually", "Annually")],
|
||||
string='Report duration view', required=True),
|
||||
'target_invoice_duration_txt': fields.function(_get_target_invoice_duration_txt,
|
||||
string='Duration',
|
||||
type="string", readonly=True),
|
||||
}
|
||||
_defaults = {
|
||||
'target_invoice_duration': "monthly",
|
||||
}
|
||||
|
||||
def action_forcasted(self, cr, uid, id, value, context=None):
|
||||
|
|
|
@ -213,12 +213,9 @@
|
|||
<field name="inherit_id" ref="crm.crm_case_section_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//notebook" position="before">
|
||||
<group col="4">
|
||||
<field name="target_invoice_duration" widget="radio"/>
|
||||
<field name="target_invoice"/>
|
||||
</group>
|
||||
</xpath>
|
||||
<field name="target_duration" position="after">
|
||||
<field name="target_invoice"/>
|
||||
</field>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -236,35 +233,32 @@
|
|||
<field name="sum_duration_invoice"/>
|
||||
<field name="forcasted"/>
|
||||
<field name="target_invoice"/>
|
||||
<field name="target_invoice_duration_txt"/>
|
||||
</xpath>
|
||||
<xpath expr="//div[@class='oe_items_list']" position="inside">
|
||||
<a name="%(action_quotations_salesteams)d" type="action">
|
||||
<t t-raw="record.quotation_ids.raw_value.length"/>
|
||||
<t t-if="record.quotation_ids.raw_value.length >= 2">Quotations</t>
|
||||
<t t-if="record.quotation_ids.raw_value.length < 2">Quotation</t>
|
||||
</a>
|
||||
<a name="%(action_orders_salesteams)d" type="action">
|
||||
<t t-raw="record.sale_order_ids.raw_value.length"/>
|
||||
<t t-if="record.sale_order_ids.raw_value.length >= 2">Sales Orders</t>
|
||||
<t t-if="record.sale_order_ids.raw_value.length < 2">Sales Order</t>
|
||||
</a>
|
||||
<a name="%(action_invoice_salesteams)d" type="action" groups="account.group_account_invoice">
|
||||
<t t-raw="record.invoice_ids.raw_value.length"/>
|
||||
<t t-if="record.invoice_ids.raw_value.length >= 2">Invoices</t>
|
||||
<t t-if="record.invoice_ids.raw_value.length < 2">Invoice</t>
|
||||
</a>
|
||||
<div>
|
||||
<a name="%(action_quotations_salesteams)d" type="action"><t t-raw="record.quotation_ids.raw_value.length"/><t t-if="record.quotation_ids.raw_value.length >= 2">Quotations</t><t t-if="record.quotation_ids.raw_value.length < 2">Quotation</t></a>
|
||||
<a name="%(action_quotations_salesteams)d" type="action" class="oe_sparkline_bar"><t t-raw="[6,4,7,2]"/></a>
|
||||
</div>
|
||||
<div>
|
||||
<a name="%(action_orders_salesteams)d" type="action"><t t-raw="record.sale_order_ids.raw_value.length"/><t t-if="record.sale_order_ids.raw_value.length >= 2">Sales Orders</t><t t-if="record.sale_order_ids.raw_value.length < 2">Sales Order</t>
|
||||
</a>
|
||||
<a name="%(action_orders_salesteams)d" type="action" class="oe_sparkline_bar"><t t-raw="[6,4,7,2]"/></a>
|
||||
</div>
|
||||
<div>
|
||||
<a name="%(action_invoice_salesteams)d" type="action" groups="account.group_account_invoice"><t t-raw="record.invoice_ids.raw_value.length"/><t t-if="record.invoice_ids.raw_value.length >= 2">Invoices</t><t t-if="record.invoice_ids.raw_value.length < 2">Invoice</t></a>
|
||||
<a name="%(action_invoice_salesteams)d" type="action" class="oe_sparkline_bar"><t t-raw="[6,4,7,2]"/></a>
|
||||
</div>
|
||||
</xpath>
|
||||
<xpath expr="//div[@class='oe_items_list']" position="after">
|
||||
<div class="oe_center">
|
||||
<div class="oe_justgage" style="width:160px; height: 120px;"
|
||||
t-att-data-value="record.sum_duration_invoice.raw_value"
|
||||
t-att-data-max="record.target_invoice.raw_value"
|
||||
t-att-data-label="record.target_invoice_duration_txt.raw_value">Invoiced</div>
|
||||
t-att-data-label="record.target_duration_txt.raw_value">Invoiced</div>
|
||||
<div class="oe_justgage" style="width:160px; height: 120px;"
|
||||
t-att-data-value="record.forcasted.raw_value"
|
||||
t-att-data-max="record.target_invoice.raw_value"
|
||||
t-att-data-label="record.target_invoice_duration_txt.raw_value"
|
||||
t-att-data-label="record.target_duration_txt.raw_value"
|
||||
data-action="action_forcasted">Forcasted</div>
|
||||
</div>
|
||||
</xpath>
|
||||
|
|
Loading…
Reference in New Issue