|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | + |
| 3 | +import logging |
| 4 | +import random |
| 5 | + |
| 6 | +from odoo import http |
| 7 | +from odoo.http import request |
| 8 | + |
| 9 | +logger = logging.getLogger(__name__) |
| 10 | + |
| 11 | +class AwesomeDashboard(http.Controller): |
| 12 | + @http.route('/awesome_dashboard/statistics', type='json', auth='user') |
| 13 | + def get_statistics(self): |
| 14 | + """ |
| 15 | + Returns a dict of statistics about the orders: |
| 16 | + 'average_quantity': the average number of t-shirts by order |
| 17 | + 'average_time': the average time (in hours) elapsed between the |
| 18 | + moment an order is created, and the moment is it sent |
| 19 | + 'nb_cancelled_orders': the number of cancelled orders, this month |
| 20 | + 'nb_new_orders': the number of new orders, this month |
| 21 | + 'total_amount': the total amount of orders, this month |
| 22 | + """ |
| 23 | + |
| 24 | + return { |
| 25 | + 'average_quantity': random.randint(4, 12), |
| 26 | + 'average_time': random.randint(4, 123), |
| 27 | + 'nb_cancelled_orders': random.randint(0, 50), |
| 28 | + 'nb_new_orders': random.randint(10, 200), |
| 29 | + 'orders_by_size': { |
| 30 | + 'm': random.randint(0, 150), |
| 31 | + 's': random.randint(0, 150), |
| 32 | + 'xl': random.randint(0, 150), |
| 33 | + }, |
| 34 | + 'total_amount': random.randint(100, 1000) |
| 35 | + } |
| 36 | + |
0 commit comments