-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathcontrollers.py
36 lines (30 loc) · 1.25 KB
/
controllers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- 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)
}