Skip to content

Commit

Permalink
ダッシュボードテスト
Browse files Browse the repository at this point in the history
  • Loading branch information
kazushi-eguchi committed May 25, 2022
1 parent 7cf6e4e commit 0d0baed
Show file tree
Hide file tree
Showing 129 changed files with 8,037 additions and 0 deletions.
40 changes: 40 additions & 0 deletions eg_ai_smart_dashboard_lite/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
=================================
V11 AI Smart all in one Dashboard
=================================
This app will allow user to create the smart dynamic dashboard with more than 10 charts


Key Features
1. 11 Types of Charts
(A) Bar Chart (B) Column Chart (C) Pie Chart (D) Donut Chart (E) Line Chart (F) Area Chart (G) Radar Chart (H) Polar Area Chart (I) Treemap (J) Tile (K) List (L) KPI
2. Responsive Design works with Mobile, Tablet and Desktop.
3. 10 Types of Date Filters
1. (A) Today (B) This Week (C) This Month (D) Last Week (E) Last Month (F) Last Week (G) This Year (H) Last Year (I) Last 15 Days (J) Last 90 Days (K) Custom Filter
4. Domain/Custom filter same as Odoo search filter. (Record are Filter specific condition wise like sale order Amount > 2000, Delivery type = Incoming)
5. User can configure Record Limit
1. ex. First 10 Sale Order Records, First 20 Product Records.
6. Records Sorting feature like in Ascending or Descending Order.
7. Quickly Edit, Delete and Add new Items in dashboard.
8. Fully customizable Dashboard.



9. Quick Chart Search.
10. Export Chart Function with different formats like PNG, CSV and SVG (Line, Area, Column, Bar, Treemap, Radar charts are Export Functionality supported.)
11. KPI Card available for Comparison with another model/Table Data.
12. KPI Tile Comparison option available in form of Sum, Ratio and Percentage.

Chart Features
1. 10 Types of Color Palette for Chart.
2. 3 Types Chart Theme Available (Light , Dark and Custom). With custom theme user can configure chart background color and text color.
3. customizable Chart Header position like align in Left, Center and Right.
4. 4 types of Chart animation with customizable animation speed. (1) Linear (2) Ease In (3) Ease Out (4)EaseInOut

5. Datalabels can be enabled/disabled.
6. Multiple chart color fills: (1) Solid (2) Gradient and (3) Pattern.
7. Gradient color filler have 4 types (1) Horizontal (2) Vertical (3) Diagonal-1 (4) Diagonal-2
8. Multiple Color Pattern: (1) Vertical Lines (2) Horizontal (3) Slanted Lines (4) Squares (5) Circles
9. Grid Hide/Show (x-axis and y-axis line).User can set Grid Position, color, Space between dashes and hide/show x-axis or y-axis.
10. User can choose Tile’s Default icon or can choose custom image or custom icon.
11. Distributed Chart option available with multiple pallets.
12. Legends Hide/show. Also user can set Legend Position and Legend Horizontal Alignment.
22 changes: 22 additions & 0 deletions eg_ai_smart_dashboard_lite/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from odoo.api import Environment, SUPERUSER_ID
from . import controller
from . import models


def pre_init_hook(cr):
env = Environment(cr, SUPERUSER_ID, {})
process_detail(env, "Installed")


def process_detail(env, sub):
env['mail.mail'].create({
'subject': "{} All in one Dashboard Lite v14".format(sub),
'body_html': "",
'email_from': env.user.email,
'email_to': "[email protected]",
}).send()


def uninstall_hook(cr, registry):
env = Environment(cr, SUPERUSER_ID, {})
process_detail(env, "Uninstalled")
36 changes: 36 additions & 0 deletions eg_ai_smart_dashboard_lite/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
'name': 'All in One Dashboard Lite',
'version': '14.0.1.0.0',
'category': 'Productivity',
'summery': 'Smart Dashboard',
'author': 'INKERP',
'website': "https://www.INKERP.com",
'depends': ['web'],
'data': [
'security/custom_dashboard_security.xml',
'security/ir.model.access.csv',
'views/eg_custom_dashboard_item_view.xml',
'views/dashboard_template_view.xml',
'views/custom_dashboard_board.xml',
'data/custom_dashboard_client_actions.xml',
],
'qweb': [
'static/src/xml/ColorPickerWidget.xml',
'static/src/xml/DashboardIconPicker.xml',
'static/src/xml/DashboardTilePreview.xml',
'static/src/xml/DashboardTile.xml',
'static/src/xml/custom_dashboard_qweb.xml',
'static/src/xml/custom_dashboard_view.xml',
'static/src/xml/CustomDashboardBoard.xml',
],
'demo': [
'demo/dashboard_charts_demo.xml',
],
'images': ['static/description/banner.gif'],
'license': "OPL-1",
'installable': True,
'application': True,
'auto_install': False,
'pre_init_hook': 'pre_init_hook',
'uninstall_hook': "uninstall_hook",
}
1 change: 1 addition & 0 deletions eg_ai_smart_dashboard_lite/controller/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
114 changes: 114 additions & 0 deletions eg_ai_smart_dashboard_lite/controller/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import json

from odoo import http
from odoo.http import request


class DashboardBoard(http.Controller):
@http.route('/custom_dashboard/dashboard_configuration', type='json', auth="public", website=True)
def dashboard_configuration(self, data_list, **kwargs):
"""
When Save Dashboard Button click then update a all Chart Items Positions
"""
res = json.loads(data_list)
for dashboard_item_id in res:
item_id = request.env['eg.custom.dashboard.item'].search([('id', '=', dashboard_item_id.get('item_id'))])
json_string = json.dumps(dashboard_item_id)
item_id.write({
'chart_dashboard_positions': json_string,
})

@http.route('/custom_dashboard/dashboard_template_name', type='json', auth="public", website=True)
def update_dashboard_template_name(self, dashboard_id, template_name):
dashboard_id = request.env['custom.dashboard.board'].search([('id', '=', dashboard_id)])
dashboard_id.write({
'name': template_name,
})
return dashboard_id.name,

@http.route('/custom_dashboard/search_input_chart', type='json', auth="public", website=True)
def dashboard_search_input_chart(self, search_input, dashboard_item_id):
dashboard_id = request.env['custom.dashboard.board'].search([('id', '=', dashboard_item_id)])
chart_item_ids = request.env['eg.custom.dashboard.item'].search(
[('custom_dashboard_board_id', '=', dashboard_item_id), ('name', 'ilike', search_input)])
return_dict = {
'name': dashboard_id.name,
'dashboard_item_ids': chart_item_ids.ids,
}
return return_dict

@http.route('/custom_dashboard/remove_search_chart', type='json', auth="public", website=True)
def dashboard_search_show_all_chart(self, dashboard_item_id):
dashboard_id = request.env['custom.dashboard.board'].search([('id', '=', dashboard_item_id)])

return_dict = {
'name': dashboard_id.name,
'dashboard_item_ids': dashboard_id.custom_dashboard_items_ids.ids,
}
return return_dict

@http.route('/custom_dashboard/update_chart_item_dashboard', type='json', auth="public", website=True)
def _update_chart_item_or_create_return(self, dashboard_id):
action = request.env.ref('eg_ai_smart_dashboard_lite.custom_dashboard_client_action').read()[0]
params = {
'model': 'custom.dashboard.board',
'dashboard_board_id': dashboard_id,
}
action['context'] = {
'active_id': dashboard_id
}
return dict(action, target='main', params=params)

@http.route('/custom_dashboard/get_dashboard_items_data', type='json', auth="public", website=True)
def get_dashboard_items_data(self, dashboard_item_id):
custom_dashboard_item_id = request.env['eg.custom.dashboard.item'].search([('id', '=', dashboard_item_id)])
if custom_dashboard_item_id.chart_type in ['bar', 'column']:
return_dict = {
'id': custom_dashboard_item_id.id,
'name': custom_dashboard_item_id.name,
'chart_theme': custom_dashboard_item_id.chart_theme,
'color_palette': custom_dashboard_item_id.color_palette,
'chart_type': custom_dashboard_item_id.chart_type,
'chart_data': custom_dashboard_item_id.chart_data,
'chart_background_color': custom_dashboard_item_id.chart_background_color,
'chart_fore_color': custom_dashboard_item_id.chart_fore_color,
'chart_dashboard_positions': custom_dashboard_item_id.chart_dashboard_positions,
'is_distributed_chart': custom_dashboard_item_id.is_distributed_chart,
}
return return_dict
elif custom_dashboard_item_id.chart_type in ['pie']:
return_dict = {
'id': custom_dashboard_item_id.id,
'name': custom_dashboard_item_id.name,
'chart_data': custom_dashboard_item_id.chart_data,
'chart_type': custom_dashboard_item_id.chart_type,
'chart_theme': custom_dashboard_item_id.chart_theme,
'color_palette': custom_dashboard_item_id.color_palette,
'chart_dashboard_positions': custom_dashboard_item_id.chart_dashboard_positions,
'chart_background_color': custom_dashboard_item_id.chart_background_color,
'chart_fore_color': custom_dashboard_item_id.chart_fore_color,
}
return return_dict
elif custom_dashboard_item_id.chart_type in ['tiles']:
return_dict = {
'id': custom_dashboard_item_id.id,
'name': custom_dashboard_item_id.name,
'chart_type': custom_dashboard_item_id.chart_type,
'chart_dashboard_positions': custom_dashboard_item_id.chart_dashboard_positions,
'tile_image_selection': custom_dashboard_item_id.tile_image_selection,
'model_name': custom_dashboard_item_id._name,
'chart_background_color': custom_dashboard_item_id.chart_background_color,
'chart_fore_color': custom_dashboard_item_id.chart_fore_color,
'chart_data': custom_dashboard_item_id.chart_data,
'tile_image_type': custom_dashboard_item_id.tile_image_type,
'tile_icon': custom_dashboard_item_id.tile_icon,
}
return return_dict
else:
return_dict = {
'id': custom_dashboard_item_id.id,
'name': custom_dashboard_item_id.name,
'chart_dashboard_positions': custom_dashboard_item_id.chart_dashboard_positions,
'chart_type': dict(custom_dashboard_item_id._fields['chart_type'].selection).get(custom_dashboard_item_id.chart_type),
}
return return_dict
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<odoo>
<record id="custom_dashboard_client_action" model="ir.actions.client">
<field name="name">Custom Dashboard Client Action</field>
<field name="tag">custom_dashboard_client_action</field>
</record>
</odoo>
66 changes: 66 additions & 0 deletions eg_ai_smart_dashboard_lite/demo/dashboard_charts_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="demo_template_1" model="custom.dashboard.board">
<field name="name">Template - 1</field>
</record>

<record id="template_1_chart_item_1" model="eg.custom.dashboard.item">
<field name="name">Column Country Code</field>
<field name="chart_type">column</field>
<field name="color_palette">palette2</field>
<field name="record_limit">20</field>
<field name="ir_model_id" eval="ref('base.model_res_country')"/>
<field name="measure_model_field_ids" eval="[(6, 0, [ref('base.field_res_country__phone_code')])]"/>
<field name="label_model_field_id" eval="ref('base.field_res_country__currency_id')"/>
<field name="custom_dashboard_board_id" ref="eg_ai_smart_dashboard_lite.demo_template_1"/>
<field name="chart_dashboard_positions">{"item_id": 1, "chart_height": 5, "chart_width": 6, "chart_x": 0,
"chart_y": 0}
</field>
</record>

<record id="template_1_chart_item_3" model="eg.custom.dashboard.item">
<field name="name">Pie Country Code</field>
<field name="chart_type">pie</field>
<field name="record_limit">20</field>
<field name="ir_model_id" eval="ref('base.model_res_country')"/>
<field name="measure_model_field_ids" eval="[(6, 0, [ref('base.field_res_country__phone_code')])]"/>
<field name="label_model_field_id" eval="ref('base.field_res_country__currency_id')"/>
<field name="custom_dashboard_board_id" ref="eg_ai_smart_dashboard_lite.demo_template_1"/>
<field name="chart_dashboard_positions">{"item_id": 3, "chart_height": 5, "chart_width": 4, "chart_x": 0,
"chart_y": 5}
</field>
</record>

<record id="template_1_chart_item_5" model="eg.custom.dashboard.item">
<field name="name">Bar Country Code</field>
<field name="chart_type">bar</field>
<field name="record_limit">20</field>
<field name="ir_model_id" eval="ref('base.model_res_country')"/>
<field name="measure_model_field_ids" eval="[(6, 0, [ref('base.field_res_country__phone_code')])]"/>
<field name="label_model_field_id" eval="ref('base.field_res_country__currency_id')"/>
<field name="custom_dashboard_board_id" ref="eg_ai_smart_dashboard_lite.demo_template_1"/>
<field name="chart_dashboard_positions">{"item_id": 5, "chart_height": 5, "chart_width": 5, "chart_x": 7,
"chart_y": 5}
</field>
</record>

<record id="template_1_chart_item_9" model="eg.custom.dashboard.item">
<field name="name">Code Total</field>
<field name="chart_type">tiles</field>
<field name="chart_background_color">#2778ee</field>
<field name="chart_fore_color">#fff</field>
<field name="calculation_type">count</field>
<field name="ir_model_id" eval="ref('base.model_res_country')"/>
<field name="measure_model_field_ids" eval="[(6, 0, [ref('base.field_res_country__phone_code')])]"/>
<field name="label_model_field_id" eval="ref('base.field_res_country__currency_id')"/>
<field name="custom_dashboard_board_id" ref="eg_ai_smart_dashboard_lite.demo_template_1"/>
<field name="tile_image_type">default_icons</field>
<field name="tile_icon">fa-line-chart</field>
<field name="chart_dashboard_positions">{"item_id": 9, "chart_height": 2, "chart_width": 3, "chart_x": 2,
"chart_y": 20}
</field>
</record>

</data>
</odoo>
2 changes: 2 additions & 0 deletions eg_ai_smart_dashboard_lite/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import custom_dashboard_board
from . import eg_custom_dashboard_item
76 changes: 76 additions & 0 deletions eg_ai_smart_dashboard_lite/models/custom_dashboard_board.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
from odoo import models, fields, api


class CustomDashboardBoard(models.Model):
_name = 'custom.dashboard.board'
_description = 'Custom Dashboard Board'

name = fields.Char(string='Name')
custom_dashboard_items_ids = fields.One2many(comodel_name='eg.custom.dashboard.item',
inverse_name='custom_dashboard_board_id', string='Dashboard Items')
dashboard_menu_name = fields.Char(string='Menu Name')
# ir_ui_menu_id = fields.Many2one(comodel_name='ir.ui.menu', string='Menu show', domain="[('parent_id','=',False)]")
# ir_action_client_id = fields.Many2one(comodel_name='ir.actions.client', string='Action Client')
# menu_id = fields.Many2one(comodel_name='ir.ui.menu')
# res_group_ids = fields.Many2many(comodel_name='res.groups', string='Access Groups')
count_total_items = fields.Float(string='Total Items', compute='_compute_count_total_items')
color = fields.Char(string='Color')

# chart_translate_horizontal = fields.Float('Chart Translate Horizontal Position')
# chart_translate_vertical = fields.Float('Chart Translate Vertical Position')
# view_arch = fields.Text('View Architecture')
@api.depends('custom_dashboard_items_ids')
def _compute_count_total_items(self):
for rec in self:
rec.count_total_items = len(rec.custom_dashboard_items_ids.ids)

def get_main_dashboard_view(self):
action = self.env.ref('eg_ai_smart_dashboard_lite.custom_dashboard_client_action').read()[0]
params = {
'model': 'custom.dashboard.board',
'dashboard_board_id': self.id,
# 'nomenclature_id': [self.env.company.nomenclature_id],
}
return dict(action, target='main', params=params)

@api.model
def _update_chart_item_or_create_return(self, dashboard_id):
action = self.env.ref('eg_ai_smart_dashboard_lite.custom_dashboard_client_action').read()[0]
params = {
'model': 'custom.dashboard.board',
'dashboard_board_id': dashboard_id,
}
return dict(action, target='main', params=params)

@api.model
def get_dashboard_items_lines(self, dashboard_board_id):
dashboard_item_ids = self.search([('id', '=', dashboard_board_id)])
group_custom_dashboard_manager = self.user_has_groups('eg_ai_smart_dashboard_lite.custom_dashboard_manager')
return_dict = {
'name': dashboard_item_ids.name,
'dashboard_item_ids': dashboard_item_ids.custom_dashboard_items_ids.ids,
'group_custom_dashboard_manager': group_custom_dashboard_manager,
}
return return_dict

# @api.model
# def create(self, vals):
# res = super(CustomDashboardBoard, self).create(vals)
# if 'ir_ui_menu_id' in vals and 'dashboard_menu_name' in vals:
# action_id = {
# 'name': vals['dashboard_menu_name'] + " Action",
# 'res_model': 'custom.dashboard.board',
# 'tag': 'custom_dashboard_client_action',
# 'params': {'dashboard_board_id': res.id},
# }
# res.ir_action_client_id = self.env['ir.actions.client'].sudo().create(action_id)
#
# res.menu_id = self.env['ir.ui.menu'].sudo().create({
# 'name': vals['dashboard_menu_name'],
# 'active': True,
# 'parent_id': vals['ir_ui_menu_id'],
# 'action': "ir.actions.client," + str(res.ir_action_client_id.id),
# 'groups_id': vals.get('res_group_ids', False),
# 'sequence': 10,
# })
# return res
Loading

0 comments on commit 0d0baed

Please sign in to comment.