diff options
| author | Christophe Simonis <chs@odoo.com> | 2015-05-11 15:12:24 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2015-05-11 15:12:24 +0200 |
| commit | 0da722aa6a3a5b2ea8a9f740ea2ccc5ed2260b0a (patch) | |
| tree | 9005a0ab8df9df374dda2d3cb4c8564bc73a023c /addons/hw_scale | |
| parent | d756bab4d1d89af414b80523124b463252f31159 (diff) | |
| parent | bff6dffbb424a9ab458ae8fc2044f0b52490c36b (diff) | |
[MERGE] forward port of branch 8.0 up to bff6dff
Diffstat (limited to 'addons/hw_scale')
| -rw-r--r-- | addons/hw_scale/__openerp__.py | 1 | ||||
| -rw-r--r-- | addons/hw_scale/controllers/main.py | 20 |
2 files changed, 14 insertions, 7 deletions
diff --git a/addons/hw_scale/__openerp__.py b/addons/hw_scale/__openerp__.py index 6c83a854730..387a7e618d9 100644 --- a/addons/hw_scale/__openerp__.py +++ b/addons/hw_scale/__openerp__.py @@ -37,6 +37,7 @@ such as the Mettler Toledo Ariva. """, 'author': 'OpenERP SA', 'depends': ['hw_proxy'], + 'external_dependencies': {'python': ['serial']}, 'test': [ ], 'installable': True, diff --git a/addons/hw_scale/controllers/main.py b/addons/hw_scale/controllers/main.py index 531f2739f55..44a031f5566 100644 --- a/addons/hw_scale/controllers/main.py +++ b/addons/hw_scale/controllers/main.py @@ -178,28 +178,34 @@ class Scale(Thread): if not self.device: time.sleep(5) -s = Scale() - -hw_proxy.drivers['scale'] = s +scale_thread = None +if serial: + scale_thread = Scale() + hw_proxy.drivers['scale'] = scale_thread class ScaleDriver(hw_proxy.Proxy): @http.route('/hw_proxy/scale_read/', type='json', auth='none', cors='*') def scale_read(self): - return {'weight':s.get_weight(), 'unit':'kg', 'info':s.get_weight_info()} + if scale_thread: + return {'weight': scale_thread.get_weight(), 'unit':'kg', 'info': scale_thread.get_weight_info()} + return None @http.route('/hw_proxy/scale_zero/', type='json', auth='none', cors='*') def scale_zero(self): - s.set_zero() + if scale_thread: + scale_thread.set_zero() return True @http.route('/hw_proxy/scale_tare/', type='json', auth='none', cors='*') def scale_tare(self): - s.set_tare() + if scale_thread: + scale_thread.set_tare() return True @http.route('/hw_proxy/scale_clear_tare/', type='json', auth='none', cors='*') def scale_clear_tare(self): - s.clear_tare() + if scale_thread: + scale_thread.clear_tare() return True |
