a340b5f6262d366dea12fce1f738da7fbcdb2cc6
[odoo/odoo.git] / addons / point_of_sale / controllers / main.py
1 # -*- coding: utf-8 -*-
2 import logging
3 import simplejson
4 import os
5 import openerp
6 import time
7 import random
8
9 from openerp import http
10 from openerp.http import request
11 from openerp.addons.web.controllers.main import manifest_list, module_boot, html_template
12
13 _logger = logging.getLogger(__name__)
14
15 html_template = """<!DOCTYPE html>
16 <html>
17     <head>
18         <title>OpenERP POS</title>
19
20         <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
21         <meta http-equiv="content-type" content="text/html, charset=utf-8" />
22
23         <meta name="viewport" content=" width=1024, user-scalable=no">
24         <meta name="apple-mobile-web-app-capable" content="yes">
25         <meta name="mobile-web-app-capable" content="yes">
26
27         <link rel="shortcut icon"    sizes="196x196" href="/point_of_sale/static/src/img/touch-icon-196.png">
28         <link rel="shortcut icon"    sizes="128x128" href="/point_of_sale/static/src/img/touch-icon-128.png">
29         <link rel="apple-touch-icon"                 href="/point_of_sale/static/src/img/touch-icon-iphone.png">
30         <link rel="apple-touch-icon" sizes="76x76"   href="/point_of_sale/static/src/img/touch-icon-ipad.png">
31         <link rel="apple-touch-icon" sizes="120x120" href="/point_of_sale/static/src/img/touch-icon-iphone-retina.png">
32         <link rel="apple-touch-icon" sizes="152x152" href="/point_of_sale/static/src/img/touch-icon-ipad-retina.png">
33
34         <link rel="shortcut icon" href="/web/static/src/img/favicon.ico" type="image/x-icon"/>
35         <link rel="stylesheet" href="/point_of_sale/static/src/fonts/lato/stylesheet.css" /> 
36         <link rel="stylesheet" href="/point_of_sale/static/src/fonts/font-awesome-4.0.3/css/font-awesome.min.css" /> 
37         <link rel="stylesheet" href="/point_of_sale/static/src/css/pos.css" />
38         <link rel="stylesheet" href="/point_of_sale/static/src/css/keyboard.css" />
39         %(js)s
40         <script type="text/javascript">
41             $(function() {
42                 var s = new openerp.init(%(modules)s);
43                 %(init)s
44             });
45         </script>
46     </head>
47     <body>
48         <!--[if lte IE 8]>
49         <script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script>
50         <script>CFInstall.check({mode: "overlay"});</script>
51         <![endif]-->
52     </body>
53 </html>
54 """
55
56 class PosController(http.Controller):
57
58     @http.route('/pos/web', type='http', auth='none')
59     def a(self, debug=False, **k):
60
61
62         js_list = manifest_list('js',db=request.db, debug=debug)
63         css_list =   manifest_list('css',db=request.db, debug=debug)
64         
65         print css_list
66         print js_list
67
68         js = "\n".join('<script type="text/javascript" src="%s"></script>' % i for i in js_list)
69         #css = "\n".join('<link rel="stylesheet" href="%s">' % i for i in css_list)
70         r = html_template % {
71             'js': js,
72          #   'css': css,
73             'modules': simplejson.dumps(module_boot(request.db)),
74             'init': """
75                      var wc = new s.web.WebClient();
76                      wc.show_application = function(){
77                          wc.action_manager.do_action("pos.ui");
78                      };
79                      wc.show_login = function(){
80                          window.location.href = '/';
81                      }
82                      wc.appendTo($(document.body));
83                      """
84         }
85         return r