add: module awesome_dashboard

This commit is contained in:
Matt Marcha 2024-09-20 09:25:47 -10:00
parent 5ebc65e096
commit 98d33e57ec
7 changed files with 101 additions and 0 deletions

View file

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import controllers

View 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'
}

View file

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import controllers

View 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)
}

View 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);

View 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>

View 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>