1 # -*- coding: utf-8 -*-
13 from openerp import http
14 from openerp.http import request
15 from openerp.addons.web.controllers.main import manifest_list, module_boot, html_template
17 _logger = logging.getLogger(__name__)
19 class Proxy(http.Controller):
22 self.scale_weight = 0.0
25 def connected_usb_devices(self,devices):
27 for device in devices:
28 if usb.core.find(idVendor=device['vendor'], idProduct=device['product']) != None:
29 connected.append(device)
32 @http.route('/hw_proxy/test_connection', type='json', auth='admin')
33 def test_connection(self):
34 _logger.info('Received Connection Test from the Point of Sale');
36 @http.route('/hw_proxy/scan_item_success', type='json', auth='admin')
37 def scan_item_success(self, ean):
39 A product has been scanned with success
41 print 'scan_item_success: ' + str(ean)
43 @http.route('/hw_proxy/scan_item_error_unrecognized', type='json', auth='admin')
44 def scan_item_error_unrecognized(self, ean):
46 A product has been scanned without success
48 print 'scan_item_error_unrecognized: ' + str(ean)
50 @http.route('/hw_proxy/help_needed', type='json', auth='admin')
51 def help_needed(self):
53 The user wants an help (ex: light is on)
57 @http.route('/hw_proxy/help_canceled', type='json', auth='admin')
58 def help_canceled(self):
60 The user stops the help request
64 @http.route('/hw_proxy/weighting_start', type='json', auth='admin')
65 def weighting_start(self):
66 if self.scale == 'closed':
67 print "Opening (Fake) Connection to Scale..."
69 self.scale_weight = 0.0
71 print "... Scale Open."
73 print "WARNING: Scale already Connected !!!"
75 @http.route('/hw_proxy/weighting_read_kg', type='json', auth='admin')
76 def weighting_read_kg(self):
77 if self.scale == 'open':
78 print "Reading Scale..."
80 self.scale_weight += 0.01
82 return self.scale_weight
84 print "WARNING: Reading closed scale !!!"
87 @http.route('/hw_proxy/weighting_end', type='json', auth='admin')
88 def weighting_end(self):
89 if self.scale == 'open':
90 print "Closing Connection to Scale ..."
92 self.scale_weight = 0.0
94 print "... Scale Closed."
96 print "WARNING: Scale already Closed !!!"
98 @http.route('/hw_proxy/payment_request', type='json', auth='admin')
99 def payment_request(self, price):
101 The PoS will activate the method payment
103 print "payment_request: price:"+str(price)
106 @http.route('/hw_proxy/payment_status', type='json', auth='admin')
107 def payment_status(self):
108 print "payment_status"
109 return { 'status':'waiting' }
111 @http.route('/hw_proxy/payment_cancel', type='json', auth='admin')
112 def payment_cancel(self):
113 print "payment_cancel"
115 @http.route('/hw_proxy/transaction_start', type='json', auth='admin')
116 def transaction_start(self):
117 print 'transaction_start'
119 @http.route('/hw_proxy/transaction_end', type='json', auth='admin')
120 def transaction_end(self):
121 print 'transaction_end'
123 @http.route('/hw_proxy/cashier_mode_activated', type='json', auth='admin')
124 def cashier_mode_activated(self):
125 print 'cashier_mode_activated'
127 @http.route('/hw_proxy/cashier_mode_deactivated', type='json', auth='admin')
128 def cashier_mode_deactivated(self):
129 print 'cashier_mode_deactivated'
131 @http.route('/hw_proxy/open_cashbox', type='json', auth='admin')
132 def open_cashbox(self):
135 @http.route('/hw_proxy/print_receipt', type='json', auth='admin')
136 def print_receipt(self, receipt):
137 print 'print_receipt' + str(receipt)
139 @http.route('/hw_proxy/is_scanner_connected', type='json', auth='admin')
140 def print_receipt(self, receipt):
141 print 'is_scanner_connected?'
144 @http.route('/hw_proxy/scanner', type='json', auth='admin')
145 def print_receipt(self, receipt):
150 @http.route('/hw_proxy/log', type='json', auth='admin')
151 def log(self, arguments):
152 _logger.info(' '.join(str(v) for v in arguments))
154 @http.route('/hw_proxy/print_pdf_invoice', type='json', auth='admin')
155 def print_pdf_invoice(self, pdfinvoice):
156 print 'print_pdf_invoice' + str(pdfinvoice)