[REM] web_kanban_sparkline: module and dependencies (project, sale, sales_team, stock, mass_mailing)
The module was not used anymore.
This commit is contained in:
@@ -391,35 +391,6 @@ class MassMailing(osv.Model):
|
||||
|
||||
_inherit = ['utm.mixin']
|
||||
|
||||
def __get_bar_values(self, cr, uid, obj, domain, read_fields, value_field, groupby_field, date_begin, context=None):
|
||||
""" Generic method to generate data for bar chart values using SparklineBarWidget.
|
||||
This method performs obj.read_group(cr, uid, domain, read_fields, groupby_field).
|
||||
|
||||
:param obj: the target model (i.e. crm_lead)
|
||||
:param domain: the domain applied to the read_group
|
||||
:param list read_fields: the list of fields to read in the read_group
|
||||
:param str value_field: the field used to compute the value of the bar slice
|
||||
:param str groupby_field: the fields used to group
|
||||
|
||||
:return list section_result: a list of dicts: [
|
||||
{ 'value': (int) bar_column_value,
|
||||
'tootip': (str) bar_column_tooltip,
|
||||
}
|
||||
]
|
||||
"""
|
||||
date_begin = date_begin.date()
|
||||
section_result = [{'value': 0,
|
||||
'tooltip': ustr((date_begin + relativedelta.relativedelta(days=i)).strftime('%d %B %Y')),
|
||||
} for i in range(0, self._period_number)]
|
||||
group_obj = obj.read_group(cr, uid, domain, read_fields, groupby_field, context=context)
|
||||
field = obj._fields.get(groupby_field.split(':')[0])
|
||||
pattern = tools.DEFAULT_SERVER_DATE_FORMAT if field.type == 'date' else tools.DEFAULT_SERVER_DATETIME_FORMAT
|
||||
for group in group_obj:
|
||||
group_begin_date = datetime.strptime(group['__domain'][0][2], pattern).date()
|
||||
timedelta = relativedelta.relativedelta(group_begin_date, date_begin)
|
||||
section_result[timedelta.days] = {'value': group.get(value_field, 0), 'tooltip': group.get(groupby_field)}
|
||||
return section_result
|
||||
|
||||
def _get_statistics(self, cr, uid, ids, name, arg, context=None):
|
||||
""" Compute statistics of the mass mailing """
|
||||
results = {}
|
||||
|
||||
@@ -160,35 +160,6 @@ class project(osv.osv):
|
||||
'context': "{'default_res_model': '%s','default_res_id': %d}" % (self._name, res_id)
|
||||
}
|
||||
|
||||
def __get_bar_values(self, cr, uid, obj, domain, read_fields, value_field, groupby_field, context=None):
|
||||
""" Generic method to generate data for bar chart values using SparklineBarWidget.
|
||||
This method performs obj.read_group(cr, uid, domain, read_fields, groupby_field).
|
||||
|
||||
:param obj: the target model (i.e. crm_lead)
|
||||
:param domain: the domain applied to the read_group
|
||||
:param list read_fields: the list of fields to read in the read_group
|
||||
:param str value_field: the field used to compute the value of the bar slice
|
||||
:param str groupby_field: the fields used to group
|
||||
|
||||
:return list section_result: a list of dicts: [
|
||||
{ 'value': (int) bar_column_value,
|
||||
'tootip': (str) bar_column_tooltip,
|
||||
}
|
||||
]
|
||||
"""
|
||||
month_begin = date.today().replace(day=1)
|
||||
section_result = [{
|
||||
'value': 0,
|
||||
'tooltip': (month_begin + relativedelta.relativedelta(months=-i)).strftime('%B'),
|
||||
} for i in range(self._period_number - 1, -1, -1)]
|
||||
group_obj = obj.read_group(cr, uid, domain, read_fields, groupby_field, context=context)
|
||||
pattern = tools.DEFAULT_SERVER_DATE_FORMAT if obj.fields_get(cr, uid, groupby_field)[groupby_field]['type'] == 'date' else tools.DEFAULT_SERVER_DATETIME_FORMAT
|
||||
for group in group_obj:
|
||||
group_begin_date = datetime.strptime(group['__domain'][0][2], pattern)
|
||||
month_delta = relativedelta.relativedelta(month_begin, group_begin_date)
|
||||
section_result[self._period_number - (month_delta.months + 1)] = {'value': group.get(value_field, 0), 'tooltip': group.get(groupby_field, 0)}
|
||||
return section_result
|
||||
|
||||
# Lambda indirection method to avoid passing a copy of the overridable method when declaring the field
|
||||
_alias_models = lambda self, *args, **kwargs: self._get_alias_models(*args, **kwargs)
|
||||
_visibility_selection = lambda self, *args, **kwargs: self._get_visibility_selection(*args, **kwargs)
|
||||
|
||||
@@ -12,21 +12,6 @@ from openerp.tools.float_utils import float_repr
|
||||
class crm_team(osv.Model):
|
||||
_inherit = 'crm.team'
|
||||
|
||||
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)
|
||||
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:
|
||||
created_domain = [('type', 'in', ['out_invoice', 'out_refund']), ('team_id', '=', id), ('state', 'not in', ['draft', 'cancel']), ('date', '>=', date_begin), ('date', '<=', date_end)]
|
||||
values = self.__get_bar_values(cr, uid, obj, created_domain, ['price_total', 'date'], 'price_total', 'date', context=context)
|
||||
for value in values:
|
||||
value['value'] = float_repr(value.get('value', 0), precision_digits=self.pool['decimal.precision'].precision_get(cr, uid, 'Account'))
|
||||
res[id] = json.dumps(values)
|
||||
return res
|
||||
|
||||
def _get_sales_to_invoice_amount(self, cr, uid, ids, field_name, arg, context=None):
|
||||
obj = self.pool['sale.order']
|
||||
|
||||
@@ -49,9 +34,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_invoiced': fields.function(_get_invoices_data,
|
||||
type='char', readonly=True,
|
||||
string='Rate of sent invoices per duration'),
|
||||
'sales_to_invoice_amount': fields.function(_get_sales_to_invoice_amount,
|
||||
type='integer', readonly=True,
|
||||
string='Amount of sales to invoice'),
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
<data>
|
||||
<xpath expr="//templates" position="before">
|
||||
<field name="use_quotations"/>
|
||||
<field name="monthly_invoiced"/>
|
||||
<field name="invoiced_forecast"/>
|
||||
<field name="invoiced_target"/>
|
||||
<field name="sales_to_invoice_amount"/>
|
||||
|
||||
@@ -34,35 +34,6 @@ class crm_team(osv.Model):
|
||||
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_bar_values(self, cr, uid, obj, domain, read_fields, value_field, groupby_field, context=None):
|
||||
""" Generic method to generate data for bar chart values using SparklineBarWidget.
|
||||
This method performs obj.read_group(cr, uid, domain, read_fields, groupby_field).
|
||||
|
||||
:param obj: the target model (i.e. crm_lead)
|
||||
:param domain: the domain applied to the read_group
|
||||
:param list read_fields: the list of fields to read in the read_group
|
||||
:param str value_field: the field used to compute the value of the bar slice
|
||||
:param str groupby_field: the fields used to group
|
||||
|
||||
:return list team_result: a list of dicts: [
|
||||
{ 'value': (int) bar_column_value,
|
||||
'tootip': (str) bar_column_tooltip,
|
||||
}
|
||||
]
|
||||
"""
|
||||
month_begin = date.today().replace(day=1)
|
||||
team_result = [{
|
||||
'value': 0,
|
||||
'tooltip': tools.ustr((month_begin + relativedelta.relativedelta(months=-i)).strftime('%B %Y')),
|
||||
} for i in range(self._period_number - 1, -1, -1)]
|
||||
group_obj = obj.read_group(cr, uid, domain, read_fields, groupby_field, context=context)
|
||||
pattern = tools.DEFAULT_SERVER_DATE_FORMAT if obj.fields_get(cr, uid, groupby_field)[groupby_field]['type'] == 'date' else tools.DEFAULT_SERVER_DATETIME_FORMAT
|
||||
for group in group_obj:
|
||||
group_begin_date = datetime.strptime(group['__domain'][0][2], pattern)
|
||||
month_delta = relativedelta.relativedelta(month_begin, group_begin_date)
|
||||
team_result[self._period_number - (month_delta.months + 1)] = {'value': group.get(value_field, 0), 'tooltip': group.get(groupby_field, 0)}
|
||||
return team_result
|
||||
|
||||
_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, string="Full Name"),
|
||||
|
||||
@@ -51,7 +51,7 @@ Dashboard / Reports for Warehouse Management will include:
|
||||
* Moves Analysis
|
||||
""",
|
||||
'website': 'https://www.odoo.com/page/warehouse',
|
||||
'depends': ['product', 'procurement', 'board', 'web_kanban_gauge', 'web_kanban_sparkline', 'barcodes'],
|
||||
'depends': ['product', 'procurement', 'board', 'barcodes'],
|
||||
'category': 'Warehouse Management',
|
||||
'sequence': 16,
|
||||
'demo': [
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
'name': 'Sparkline Widget for Kanban',
|
||||
'category': 'Hidden',
|
||||
'description': """
|
||||
This widget allows to display sparklines using jquery.sparkline library.
|
||||
""",
|
||||
'version': '1.0',
|
||||
'depends': ['web_kanban'],
|
||||
'data' : [
|
||||
'views/web_kanban_sparkline.xml',
|
||||
],
|
||||
'qweb': [
|
||||
],
|
||||
'auto_install': False,
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
.. _changelog:
|
||||
|
||||
Changelog
|
||||
=========
|
||||
|
||||
`trunk (saas-2)`
|
||||
----------------
|
||||
|
||||
- Module ``web_kanban_sparkline`` created. It comes from the refactoring of
|
||||
custom kanban widgets used in other modules, now standardized.
|
||||
@@ -1,10 +0,0 @@
|
||||
Sparkline for Kanban module documentation
|
||||
=========================================
|
||||
|
||||
Changelog
|
||||
'''''''''
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
changelog.rst
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,56 +0,0 @@
|
||||
odoo.define('web_kanban_sparkline.widget', function (require) {
|
||||
"use strict";
|
||||
|
||||
var kanban_common = require('web_kanban.common');
|
||||
|
||||
var AbstractField = kanban_common.AbstractField;
|
||||
var fields_registry = kanban_common.registry;
|
||||
|
||||
/**
|
||||
* Kanban widgets: Sparkline
|
||||
*
|
||||
*/
|
||||
|
||||
var SparklineBarWidget = AbstractField.extend({
|
||||
className: "oe_sparkline_bar",
|
||||
start: function() {
|
||||
var self = this;
|
||||
var title = this.$node.html() || this.field.string;
|
||||
setTimeout(function () {
|
||||
var tooltipFormatter = function(sp, options, fields) {
|
||||
var format = $.spformat('<div class="jqsfield">{{offset:offset}} {{formatted_value}}</div>');
|
||||
var result = '';
|
||||
$.each(fields, function(i, field) {
|
||||
field.formatted_value = instance.web.format_value(field.value, { type : 'float' });
|
||||
result += format.render(field, options.get('tooltipValueLookups'), options);
|
||||
})
|
||||
return result;
|
||||
}
|
||||
var field_value = JSON.parse(self.field.value);
|
||||
var value = _.pluck(field_value, 'value');
|
||||
var tooltips = _.pluck(field_value, 'tooltip');
|
||||
var suffix = self.options.tooltip_suffix || "";
|
||||
var tooltipFormat = self.options.type == 'tristate' && '{{offset:offset}}' + suffix || '{{offset:offset}} {{value:value}}' + suffix;
|
||||
var sparkline_options = _.extend({
|
||||
type: 'bar',
|
||||
height: '20px',
|
||||
barWidth: 4,
|
||||
barSpacing: 1,
|
||||
barColor: '#96d854',
|
||||
tooltipFormat: tooltipFormat,
|
||||
tooltipFormatter: self.options.type == 'tristate' ? undefined : tooltipFormatter,
|
||||
chartRangeMin: 0,
|
||||
tooltipValueLookups: {
|
||||
'offset': tooltips
|
||||
}
|
||||
}, self.options);
|
||||
self.$el.sparkline(value, sparkline_options);
|
||||
self.$el.tooltip({delay: {show: self.options.delayIn || 0, hide: 0}, title: function(){return title;}});
|
||||
}, 0);
|
||||
},
|
||||
});
|
||||
|
||||
fields_registry.add("sparkline_bar", SparklineBarWidget);
|
||||
|
||||
|
||||
});
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<template id="assets_backend" name="web_kanban_sparkline assets" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/web_kanban_sparkline/static/lib/jquery.sparkline/jquery.sparkline.js"></script>
|
||||
<script type="text/javascript" src="/web_kanban_sparkline/static/src/js/kanban_sparkline.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user