Enric Tobella
4 years ago
26 changed files with 955 additions and 845 deletions
-
45kpi_dashboard/demo/demo_dashboard.xml
-
87kpi_dashboard/models/kpi_dashboard.py
-
148kpi_dashboard/models/kpi_kpi.py
-
4kpi_dashboard/security/security.xml
-
81kpi_dashboard/static/src/js/dashboard_controller.js
-
16kpi_dashboard/static/src/js/dashboard_model.js
-
79kpi_dashboard/static/src/js/dashboard_renderer.js
-
32kpi_dashboard/static/src/js/dashboard_view.js
-
65kpi_dashboard/static/src/js/field_widget.js
-
70kpi_dashboard/static/src/js/widget/abstract_widget.js
-
10kpi_dashboard/static/src/js/widget/counter_widget.js
-
67kpi_dashboard/static/src/js/widget/graph_widget.js
-
51kpi_dashboard/static/src/js/widget/integer_widget.js
-
27kpi_dashboard/static/src/js/widget/meter_widget.js
-
15kpi_dashboard/static/src/js/widget/number_widget.js
-
11kpi_dashboard/static/src/js/widget/text_widget.js
-
4kpi_dashboard/static/src/js/widget_registry.js
-
34kpi_dashboard/static/src/scss/kpi_dashboard.scss
-
29kpi_dashboard/static/src/xml/dashboard.xml
-
82kpi_dashboard/templates/assets.xml
-
24kpi_dashboard/tests/test_formula.py
-
176kpi_dashboard/tests/test_kpi_dashboard.py
-
63kpi_dashboard/views/kpi_dashboard.xml
-
120kpi_dashboard/views/kpi_kpi.xml
-
7kpi_dashboard/views/kpi_menu.xml
-
15kpi_dashboard/wizards/kpi_dashboard_menu.xml
@ -1,23 +1,21 @@ |
|||||
odoo.define('kpi_dashboard.DashboardModel', function (require) { |
|
||||
|
odoo.define("kpi_dashboard.DashboardModel", function(require) { |
||||
"use strict"; |
"use strict"; |
||||
|
|
||||
var BasicModel = require('web.BasicModel'); |
|
||||
|
var BasicModel = require("web.BasicModel"); |
||||
|
|
||||
var DashboardModel = BasicModel.extend({ |
var DashboardModel = BasicModel.extend({ |
||||
_fetchRecord: function(record, options) { |
_fetchRecord: function(record, options) { |
||||
return this._rpc({ |
return this._rpc({ |
||||
model: record.model, |
model: record.model, |
||||
method: 'read_dashboard', |
|
||||
|
method: "read_dashboard", |
||||
args: [[record.res_id]], |
args: [[record.res_id]], |
||||
context: _.extend({}, record.getContext(), {bin_size: true}), |
context: _.extend({}, record.getContext(), {bin_size: true}), |
||||
}) |
|
||||
.then(function (result) { |
|
||||
|
}).then(function(result) { |
||||
record.specialData = result; |
record.specialData = result; |
||||
return result |
|
||||
}) |
|
||||
} |
|
||||
|
return result; |
||||
|
}); |
||||
|
}, |
||||
}); |
}); |
||||
|
|
||||
return DashboardModel; |
return DashboardModel; |
||||
|
|
||||
}); |
}); |
@ -1,14 +1,14 @@ |
|||||
odoo.define('kpi_dashboard.CounterWidget', function (require) { |
|
||||
|
odoo.define("kpi_dashboard.CounterWidget", function(require) { |
||||
"use strict"; |
"use strict"; |
||||
|
|
||||
var IntegerWidget = require('kpi_dashboard.IntegerWidget'); |
|
||||
var registry = require('kpi_dashboard.widget_registry'); |
|
||||
var field_utils = require('web.field_utils'); |
|
||||
|
var IntegerWidget = require("kpi_dashboard.IntegerWidget"); |
||||
|
var registry = require("kpi_dashboard.widget_registry"); |
||||
|
var field_utils = require("web.field_utils"); |
||||
|
|
||||
var CounterWidget = IntegerWidget.extend({ |
var CounterWidget = IntegerWidget.extend({ |
||||
shortList: [], |
shortList: [], |
||||
}); |
}); |
||||
|
|
||||
registry.add('counter', CounterWidget); |
|
||||
|
registry.add("counter", CounterWidget); |
||||
return CounterWidget; |
return CounterWidget; |
||||
}); |
}); |
@ -1,39 +1,34 @@ |
|||||
odoo.define('kpi_dashboard.MeterWidget', function (require) { |
|
||||
|
odoo.define("kpi_dashboard.MeterWidget", function(require) { |
||||
"use strict"; |
"use strict"; |
||||
|
|
||||
var AbstractWidget = require('kpi_dashboard.AbstractWidget'); |
|
||||
var registry = require('kpi_dashboard.widget_registry'); |
|
||||
|
|
||||
|
var AbstractWidget = require("kpi_dashboard.AbstractWidget"); |
||||
|
var registry = require("kpi_dashboard.widget_registry"); |
||||
|
|
||||
var MeterWidget = AbstractWidget.extend({ |
var MeterWidget = AbstractWidget.extend({ |
||||
template: 'kpi_dashboard.meter', |
|
||||
jsLibs: [ |
|
||||
'/kpi_dashboard/static/lib/gauge/GaugeMeter.js', |
|
||||
], |
|
||||
|
template: "kpi_dashboard.meter", |
||||
|
jsLibs: ["/kpi_dashboard/static/lib/gauge/GaugeMeter.js"], |
||||
fillWidget: function(values) { |
fillWidget: function(values) { |
||||
var input = this.$el.find('[data-bind="value"]'); |
var input = this.$el.find('[data-bind="value"]'); |
||||
var options = this._getMeterOptions(values); |
var options = this._getMeterOptions(values); |
||||
var margin = (this.widget_dimension_x - options.size) / 2; |
var margin = (this.widget_dimension_x - options.size) / 2; |
||||
input.gaugeMeter(options); |
input.gaugeMeter(options); |
||||
input.parent().css('padding-left', margin); |
|
||||
|
input.parent().css("padding-left", margin); |
||||
}, |
}, |
||||
_getMeterOptions: function(values) { |
_getMeterOptions: function(values) { |
||||
var size = Math.min( |
|
||||
this.widget_size_x, |
|
||||
this.widget_size_y - 40) - 10; |
|
||||
|
var size = Math.min(this.widget_size_x, this.widget_size_y - 40) - 10; |
||||
return { |
return { |
||||
percent: values.value.value, |
percent: values.value.value, |
||||
style: 'Arch', |
|
||||
|
style: "Arch", |
||||
width: 10, |
width: 10, |
||||
size: size, |
size: size, |
||||
prepend: values.prefix !== undefined ? values.prefix : '', |
|
||||
append: values.suffix !== undefined ? values.suffix : '', |
|
||||
|
prepend: values.prefix !== undefined ? values.prefix : "", |
||||
|
append: values.suffix !== undefined ? values.suffix : "", |
||||
color: values.font_color, |
color: values.font_color, |
||||
animate_text_colors: true, |
animate_text_colors: true, |
||||
}; |
}; |
||||
}, |
}, |
||||
}); |
}); |
||||
|
|
||||
registry.add('meter', MeterWidget); |
|
||||
|
registry.add("meter", MeterWidget); |
||||
return MeterWidget; |
return MeterWidget; |
||||
}); |
}); |
@ -1,21 +1,22 @@ |
|||||
odoo.define('kpi_dashboard.NumberWidget', function (require) { |
|
||||
|
odoo.define("kpi_dashboard.NumberWidget", function(require) { |
||||
"use strict"; |
"use strict"; |
||||
|
|
||||
var IntegerWidget = require('kpi_dashboard.IntegerWidget'); |
|
||||
var registry = require('kpi_dashboard.widget_registry'); |
|
||||
var field_utils = require('web.field_utils'); |
|
||||
|
var IntegerWidget = require("kpi_dashboard.IntegerWidget"); |
||||
|
var registry = require("kpi_dashboard.widget_registry"); |
||||
|
var field_utils = require("web.field_utils"); |
||||
|
|
||||
var NumberWidget = IntegerWidget.extend({ |
var NumberWidget = IntegerWidget.extend({ |
||||
digits: [3, 1], |
digits: [3, 1], |
||||
shortNumber: function(num) { |
shortNumber: function(num) { |
||||
if (Math.abs(num) < 10) { |
if (Math.abs(num) < 10) { |
||||
return field_utils.format.float(num, false, { |
return field_utils.format.float(num, false, { |
||||
digits: [3, 2]}); |
|
||||
|
digits: [3, 2], |
||||
|
}); |
||||
} |
} |
||||
return this._super.apply(this, arguments) |
|
||||
|
return this._super.apply(this, arguments); |
||||
}, |
}, |
||||
}); |
}); |
||||
|
|
||||
registry.add('number', NumberWidget); |
|
||||
|
registry.add("number", NumberWidget); |
||||
return NumberWidget; |
return NumberWidget; |
||||
}); |
}); |
@ -1,17 +1,16 @@ |
|||||
odoo.define('kpi_dashboard.TextWidget', function (require) { |
|
||||
|
odoo.define("kpi_dashboard.TextWidget", function(require) { |
||||
"use strict"; |
"use strict"; |
||||
|
|
||||
var AbstractWidget = require('kpi_dashboard.AbstractWidget'); |
|
||||
var registry = require('kpi_dashboard.widget_registry'); |
|
||||
|
|
||||
|
var AbstractWidget = require("kpi_dashboard.AbstractWidget"); |
||||
|
var registry = require("kpi_dashboard.widget_registry"); |
||||
|
|
||||
var TextWidget = AbstractWidget.extend({ |
var TextWidget = AbstractWidget.extend({ |
||||
template: 'kpi_dashboard.base_text', |
|
||||
|
template: "kpi_dashboard.base_text", |
||||
fillWidget: function() { |
fillWidget: function() { |
||||
return; |
return; |
||||
}, |
}, |
||||
}); |
}); |
||||
|
|
||||
registry.add('base_text', TextWidget); |
|
||||
|
registry.add("base_text", TextWidget); |
||||
return TextWidget; |
return TextWidget; |
||||
}); |
}); |
@ -1,7 +1,7 @@ |
|||||
odoo.define('kpi_dashboard.widget_registry', function (require) { |
|
||||
|
odoo.define("kpi_dashboard.widget_registry", function(require) { |
||||
"use strict"; |
"use strict"; |
||||
|
|
||||
var Registry = require('web.Registry'); |
|
||||
|
var Registry = require("web.Registry"); |
||||
|
|
||||
return new Registry(); |
return new Registry(); |
||||
}); |
}); |
@ -1,28 +1,68 @@ |
|||||
<?xml version="1.0" encoding="utf-8" ?> |
<?xml version="1.0" encoding="utf-8" ?> |
||||
<odoo> |
<odoo> |
||||
|
|
||||
<template id="assets_backend" |
|
||||
|
<template |
||||
|
id="assets_backend" |
||||
name="Backend Assets (used in backend interface)" |
name="Backend Assets (used in backend interface)" |
||||
inherit_id="web.assets_backend"> |
|
||||
|
inherit_id="web.assets_backend" |
||||
|
> |
||||
<xpath expr="." position="inside"> |
<xpath expr="." position="inside"> |
||||
|
|
||||
<script type="text/javascript" src="/kpi_dashboard/static/src/js/widget_registry.js"/> |
|
||||
<script type="text/javascript" src="/kpi_dashboard/static/src/js/widget/abstract_widget.js"/> |
|
||||
|
|
||||
<script type="text/javascript" src="/kpi_dashboard/static/src/js/dashboard_renderer.js"/> |
|
||||
<script type="text/javascript" src="/kpi_dashboard/static/src/js/dashboard_model.js"/> |
|
||||
<script type="text/javascript" src="/kpi_dashboard/static/src/js/dashboard_controller.js"/> |
|
||||
<script type="text/javascript" src="/kpi_dashboard/static/src/js/dashboard_view.js"/> |
|
||||
|
|
||||
<script type="text/javascript" src="/kpi_dashboard/static/src/js/widget/integer_widget.js"/> |
|
||||
<script type="text/javascript" src="/kpi_dashboard/static/src/js/widget/number_widget.js"/> |
|
||||
<script type="text/javascript" src="/kpi_dashboard/static/src/js/widget/counter_widget.js"/> |
|
||||
<script type="text/javascript" src="/kpi_dashboard/static/src/js/widget/meter_widget.js"/> |
|
||||
<script type="text/javascript" src="/kpi_dashboard/static/src/js/widget/graph_widget.js"/> |
|
||||
<script type="text/javascript" src="/kpi_dashboard/static/src/js/widget/text_widget.js"/> |
|
||||
<script type="text/javascript" src="/kpi_dashboard/static/src/js/field_widget.js"/> |
|
||||
|
|
||||
<link rel="stylesheet" type="text/scss" href="/kpi_dashboard/static/src/scss/kpi_dashboard.scss"/> |
|
||||
|
<script |
||||
|
type="text/javascript" |
||||
|
src="/kpi_dashboard/static/src/js/widget_registry.js" |
||||
|
/> |
||||
|
<script |
||||
|
type="text/javascript" |
||||
|
src="/kpi_dashboard/static/src/js/widget/abstract_widget.js" |
||||
|
/> |
||||
|
<script |
||||
|
type="text/javascript" |
||||
|
src="/kpi_dashboard/static/src/js/dashboard_renderer.js" |
||||
|
/> |
||||
|
<script |
||||
|
type="text/javascript" |
||||
|
src="/kpi_dashboard/static/src/js/dashboard_model.js" |
||||
|
/> |
||||
|
<script |
||||
|
type="text/javascript" |
||||
|
src="/kpi_dashboard/static/src/js/dashboard_controller.js" |
||||
|
/> |
||||
|
<script |
||||
|
type="text/javascript" |
||||
|
src="/kpi_dashboard/static/src/js/dashboard_view.js" |
||||
|
/> |
||||
|
<script |
||||
|
type="text/javascript" |
||||
|
src="/kpi_dashboard/static/src/js/widget/integer_widget.js" |
||||
|
/> |
||||
|
<script |
||||
|
type="text/javascript" |
||||
|
src="/kpi_dashboard/static/src/js/widget/number_widget.js" |
||||
|
/> |
||||
|
<script |
||||
|
type="text/javascript" |
||||
|
src="/kpi_dashboard/static/src/js/widget/counter_widget.js" |
||||
|
/> |
||||
|
<script |
||||
|
type="text/javascript" |
||||
|
src="/kpi_dashboard/static/src/js/widget/meter_widget.js" |
||||
|
/> |
||||
|
<script |
||||
|
type="text/javascript" |
||||
|
src="/kpi_dashboard/static/src/js/widget/graph_widget.js" |
||||
|
/> |
||||
|
<script |
||||
|
type="text/javascript" |
||||
|
src="/kpi_dashboard/static/src/js/widget/text_widget.js" |
||||
|
/> |
||||
|
<script |
||||
|
type="text/javascript" |
||||
|
src="/kpi_dashboard/static/src/js/field_widget.js" |
||||
|
/> |
||||
|
<link |
||||
|
rel="stylesheet" |
||||
|
type="text/scss" |
||||
|
href="/kpi_dashboard/static/src/scss/kpi_dashboard.scss" |
||||
|
/> |
||||
</xpath> |
</xpath> |
||||
</template> |
</template> |
||||
</odoo> |
</odoo> |
@ -1,12 +1,13 @@ |
|||||
<?xml version="1.0" encoding="utf-8" ?> |
<?xml version="1.0" encoding="utf-8" ?> |
||||
<!-- Copyright 2020 Creu Blanca |
<!-- Copyright 2020 Creu Blanca |
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> |
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> |
||||
|
|
||||
<odoo> |
<odoo> |
||||
<!-- CONFIGURATION --> |
<!-- CONFIGURATION --> |
||||
<menuitem id="menu_configuration_kpi_dashboards" |
|
||||
|
<menuitem |
||||
|
id="menu_configuration_kpi_dashboards" |
||||
name="KPI Dashboards" |
name="KPI Dashboards" |
||||
parent="base.menu_reporting_config" |
parent="base.menu_reporting_config" |
||||
groups="kpi_dashboard.group_kpi_dashboard_manager" |
groups="kpi_dashboard.group_kpi_dashboard_manager" |
||||
sequence="10"/> |
|
||||
|
sequence="10" |
||||
|
/> |
||||
</odoo> |
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue