mirror of
https://github.com/SARL-PACIFIC-ERP/odoo-sh-test.git
synced 2025-06-25 09:32:22 +00:00
add: module awesome_dashboard
This commit is contained in:
parent
5ebc65e096
commit
98d33e57ec
3
awesome_dashboard/__init__.py
Normal file
3
awesome_dashboard/__init__.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import controllers
|
30
awesome_dashboard/__manifest__.py
Normal file
30
awesome_dashboard/__manifest__.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
{
|
||||
'name': "Awesome Dashboard",
|
||||
|
||||
'summary': """
|
||||
Starting module for "Discover the JS framework, chapter 2: Build a dashboard"
|
||||
""",
|
||||
|
||||
'description': """
|
||||
Starting module for "Discover the JS framework, chapter 2: Build a dashboard"
|
||||
""",
|
||||
|
||||
'author': "Odoo",
|
||||
'website': "https://www.odoo.com/",
|
||||
'category': 'Tutorials/AwesomeDashboard',
|
||||
'version': '0.1',
|
||||
'application': True,
|
||||
'installable': True,
|
||||
'depends': ['base', 'web', 'mail', 'crm'],
|
||||
|
||||
'data': [
|
||||
'views/views.xml',
|
||||
],
|
||||
'assets': {
|
||||
'web.assets_backend': [
|
||||
'awesome_dashboard/static/src/**/*',
|
||||
],
|
||||
},
|
||||
'license': 'AGPL-3'
|
||||
}
|
3
awesome_dashboard/controllers/__init__.py
Normal file
3
awesome_dashboard/controllers/__init__.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import controllers
|
36
awesome_dashboard/controllers/controllers.py
Normal file
36
awesome_dashboard/controllers/controllers.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
import random
|
||||
|
||||
from odoo import http
|
||||
from odoo.http import request
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class AwesomeDashboard(http.Controller):
|
||||
@http.route('/awesome_dashboard/statistics', type='json', auth='user')
|
||||
def get_statistics(self):
|
||||
"""
|
||||
Returns a dict of statistics about the orders:
|
||||
'average_quantity': the average number of t-shirts by order
|
||||
'average_time': the average time (in hours) elapsed between the
|
||||
moment an order is created, and the moment is it sent
|
||||
'nb_cancelled_orders': the number of cancelled orders, this month
|
||||
'nb_new_orders': the number of new orders, this month
|
||||
'total_amount': the total amount of orders, this month
|
||||
"""
|
||||
|
||||
return {
|
||||
'average_quantity': random.randint(4, 12),
|
||||
'average_time': random.randint(4, 123),
|
||||
'nb_cancelled_orders': random.randint(0, 50),
|
||||
'nb_new_orders': random.randint(10, 200),
|
||||
'orders_by_size': {
|
||||
'm': random.randint(0, 150),
|
||||
's': random.randint(0, 150),
|
||||
'xl': random.randint(0, 150),
|
||||
},
|
||||
'total_amount': random.randint(100, 1000)
|
||||
}
|
||||
|
10
awesome_dashboard/static/src/dashboard.js
Normal file
10
awesome_dashboard/static/src/dashboard.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { Component } from "@odoo/owl";
|
||||
import { registry } from "@web/core/registry";
|
||||
|
||||
class AwesomeDashboard extends Component {
|
||||
static template = "awesome_dashboard.AwesomeDashboard";
|
||||
}
|
||||
|
||||
registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard);
|
8
awesome_dashboard/static/src/dashboard.xml
Normal file
8
awesome_dashboard/static/src/dashboard.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-name="awesome_dashboard.AwesomeDashboard">
|
||||
hello dashboard
|
||||
</t>
|
||||
|
||||
</templates>
|
11
awesome_dashboard/views/views.xml
Normal file
11
awesome_dashboard/views/views.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<odoo>
|
||||
<data>
|
||||
<record model="ir.actions.client" id="dashboard">
|
||||
<field name="name">Dashboard</field>
|
||||
<field name="tag">awesome_dashboard.dashboard</field>
|
||||
</record>
|
||||
|
||||
<menuitem name="Awesome Dashboard" id="awesome_dashboard.menu_root" groups="base.group_user" web_icon="awesome_dashboard,static/description/icon.png"/>
|
||||
<menuitem name="Dashboard" id="awesome_dashboard.dashboard_menu" parent="awesome_dashboard.menu_root" action="awesome_dashboard.dashboard" sequence="1"/>
|
||||
</data>
|
||||
</odoo>
|
Loading…
Reference in a new issue