mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[IMP] kpi_dasboard_bokeh: black, isort, prettier
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
"version": "12.0.1.0.0",
|
"version": "12.0.1.0.0",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"author": "Creu Blanca,Odoo Community Association (OCA)",
|
"author": "Creu Blanca,Odoo Community Association (OCA)",
|
||||||
"website": "https://github.com/OCA/reporting-engine ",
|
"website": "https://github.com/OCA/reporting-engine",
|
||||||
"depends": ["web_widget_bokeh_chart", "kpi_dashboard"],
|
"depends": ["web_widget_bokeh_chart", "kpi_dashboard"],
|
||||||
"data": ["views/webclient_templates.xml"],
|
"data": ["views/webclient_templates.xml"],
|
||||||
"qweb": ["static/src/xml/dashboard.xml"],
|
"qweb": ["static/src/xml/dashboard.xml"],
|
||||||
|
|||||||
@@ -13,13 +13,12 @@ result = {"bokeh": "%s%s" % (div, script)}
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<function model="kpi.kpi" name="compute"
|
<function model="kpi.kpi" name="compute" eval="[[ref('widget_bokeh')]]" />
|
||||||
eval="[[ref('widget_bokeh')]]"/>
|
|
||||||
|
|
||||||
<record id="dashboard_widget_bokeh" model="kpi.dashboard.item">
|
<record id="dashboard_widget_bokeh" model="kpi.dashboard.item">
|
||||||
<field name="name">Bokeh</field>
|
<field name="name">Bokeh</field>
|
||||||
<field name="dashboard_id" ref="kpi_dashboard.demo_dashboard"/>
|
<field name="dashboard_id" ref="kpi_dashboard.demo_dashboard" />
|
||||||
<field name="kpi_id" ref="widget_bokeh"/>
|
<field name="kpi_id" ref="widget_bokeh" />
|
||||||
<field name="column">2</field>
|
<field name="column">2</field>
|
||||||
<field name="row">10</field>
|
<field name="row">10</field>
|
||||||
<field name="size_y">4</field>
|
<field name="size_y">4</field>
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
# 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).
|
||||||
from odoo import fields, models
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
from bokeh.embed import components
|
||||||
from bokeh.plotting import figure
|
from bokeh.plotting import figure
|
||||||
from bokeh.themes import Theme
|
from bokeh.themes import Theme
|
||||||
from bokeh.embed import components
|
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
_logger.error(e)
|
_logger.error(e)
|
||||||
|
|
||||||
@@ -20,31 +21,36 @@ class KpiKpi(models.Model):
|
|||||||
widget = fields.Selection(selection_add=[("bokeh", "Bokeh")])
|
widget = fields.Selection(selection_add=[("bokeh", "Bokeh")])
|
||||||
|
|
||||||
def _get_bokeh_theme(self):
|
def _get_bokeh_theme(self):
|
||||||
return Theme(json={
|
return Theme(
|
||||||
"attrs": {
|
json={
|
||||||
"Figure": {
|
"attrs": {
|
||||||
"background_fill_alpha": 0,
|
"Figure": {
|
||||||
"border_fill_alpha": 0,
|
"background_fill_alpha": 0,
|
||||||
"outline_line_alpha": 0,
|
"border_fill_alpha": 0,
|
||||||
},
|
"outline_line_alpha": 0,
|
||||||
"Legend": {
|
},
|
||||||
"border_line_alpha": 0,
|
"Legend": {
|
||||||
"background_fill_alpha": 0,
|
"border_line_alpha": 0,
|
||||||
},
|
"background_fill_alpha": 0,
|
||||||
"ColorBar": {
|
},
|
||||||
"bar_line_alpha": 0,
|
"ColorBar": {
|
||||||
"background_fill_alpha": 0,
|
"bar_line_alpha": 0,
|
||||||
},
|
"background_fill_alpha": 0,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
|
|
||||||
def _get_code_input_dict(self):
|
def _get_code_input_dict(self):
|
||||||
res = super()._get_code_input_dict()
|
res = super()._get_code_input_dict()
|
||||||
if self.widget == 'bokeh':
|
if self.widget == "bokeh":
|
||||||
res.update({
|
res.update(
|
||||||
'figure': figure,
|
{
|
||||||
'components': components,
|
"figure": figure,
|
||||||
'simple_components': lambda r: components(
|
"components": components,
|
||||||
r, theme=self._get_bokeh_theme())
|
"simple_components": lambda r: components(
|
||||||
})
|
r, theme=self._get_bokeh_theme()
|
||||||
|
),
|
||||||
|
}
|
||||||
|
)
|
||||||
return res
|
return res
|
||||||
|
|||||||
@@ -1,20 +1,19 @@
|
|||||||
odoo.define('kpi_dashboard.BokehWidget', function (require) {
|
odoo.define("kpi_dashboard.BokehWidget", function (require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var AbstractWidget = require('kpi_dashboard.AbstractWidget');
|
var AbstractWidget = require("kpi_dashboard.AbstractWidget");
|
||||||
var registry = require('kpi_dashboard.widget_registry');
|
var registry = require("kpi_dashboard.widget_registry");
|
||||||
|
|
||||||
|
|
||||||
var BokehWidget = AbstractWidget.extend({
|
var BokehWidget = AbstractWidget.extend({
|
||||||
template: 'kpi_dashboard.bokeh',
|
template: "kpi_dashboard.bokeh",
|
||||||
fillWidget: function (values) {
|
fillWidget: function (values) {
|
||||||
var val = values.value.bokeh;
|
var val = values.value.bokeh;
|
||||||
var widget = this.$el.find('[data-bind="value"]');
|
var widget = this.$el.find('[data-bind="value"]');
|
||||||
widget.css('height', this.widget_size_y - 90);
|
widget.css("height", this.widget_size_y - 90);
|
||||||
widget.html(val);
|
widget.html(val);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
registry.add('bokeh', BokehWidget);
|
registry.add("bokeh", BokehWidget);
|
||||||
return BokehWidget;
|
return BokehWidget;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<t t-name="kpi_dashboard.bokeh" t-extend="kpi_dashboard.base_widget">
|
<t t-name="kpi_dashboard.bokeh" t-extend="kpi_dashboard.base_widget">
|
||||||
<t t-jquery="h1" t-operation="after">
|
<t t-jquery="h1" t-operation="after">
|
||||||
<div data-bind="value"/>
|
<div data-bind="value" />
|
||||||
</t>
|
</t>
|
||||||
</t>
|
</t>
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<template id="assets_backend"
|
<template
|
||||||
name="Backend Assets (used in backend interface)"
|
id="assets_backend"
|
||||||
inherit_id="web.assets_backend">
|
name="Backend Assets (used in backend interface)"
|
||||||
|
inherit_id="web.assets_backend"
|
||||||
|
>
|
||||||
<xpath expr="." position="inside">
|
<xpath expr="." position="inside">
|
||||||
<script type="text/javascript" src="/kpi_dashboard_bokeh/static/src/js/bokeh_widget.js"/>
|
<script
|
||||||
|
type="text/javascript"
|
||||||
|
src="/kpi_dashboard_bokeh/static/src/js/bokeh_widget.js"
|
||||||
|
/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
1
setup/kpi_dashboard_bokeh/odoo/addons/kpi_dashboard_bokeh
Symbolic link
1
setup/kpi_dashboard_bokeh/odoo/addons/kpi_dashboard_bokeh
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../../../kpi_dashboard_bokeh
|
||||||
6
setup/kpi_dashboard_bokeh/setup.py
Normal file
6
setup/kpi_dashboard_bokeh/setup.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user