diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 7b6fe02afa8..8c573740076 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -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 = [ diff --git a/addons/crm/crm_case_section_view.xml b/addons/crm/crm_case_section_view.xml index 1c812b23685..44f45f2f94a 100644 --- a/addons/crm/crm_case_section_view.xml +++ b/addons/crm/crm_case_section_view.xml @@ -81,6 +81,7 @@ + @@ -98,21 +99,15 @@ %% - - - Leads - Lead - - - Opportunities - Opportunity + + LeadsLead + + + + OpportunitiesOpportunity + + - @@ -178,6 +173,9 @@ + + + diff --git a/addons/crm/static/src/css/crm.css b/addons/crm/static/src/css/crm.css index d5705e01f27..a64dd76b5fb 100644 --- a/addons/crm/static/src/css/crm.css +++ b/addons/crm/static/src/css/crm.css @@ -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; } \ No newline at end of file diff --git a/addons/crm/static/src/js/crm_case_section.js b/addons/crm/static/src/js/crm_case_section.js index 58e42b71542..4e69bf8fc6e 100644 --- a/addons/crm/static/src/js/crm_case_section.js +++ b/addons/crm/static/src/js/crm_case_section.js @@ -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 = $(''); $input = $('').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); }); } }, diff --git a/addons/sale_crm/sale_crm.py b/addons/sale_crm/sale_crm.py index dc3be897c35..433df31a669 100644 --- a/addons/sale_crm/sale_crm.py +++ b/addons/sale_crm/sale_crm.py @@ -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): diff --git a/addons/sale_crm/sale_crm_view.xml b/addons/sale_crm/sale_crm_view.xml index 6ba3886cb1b..7cabe1c13ec 100644 --- a/addons/sale_crm/sale_crm_view.xml +++ b/addons/sale_crm/sale_crm_view.xml @@ -213,12 +213,9 @@ - - - - - - + + + @@ -236,35 +233,32 @@ - - - - Quotations - Quotation - - - - Sales Orders - Sales Order - - - - Invoices - Invoice - + + QuotationsQuotation + + + + Sales OrdersSales Order + + + + + InvoicesInvoice + + Invoiced + t-att-data-label="record.target_duration_txt.raw_value">Invoiced Forcasted