[IMP] point_of_sale, hw_scale: various small fixes and improvements for the scale module

bzr revid: fva@openerp.com-20140425122220-q7rw1dve8bgs25as
This commit is contained in:
Frédéric van der Essen 2014-04-25 14:22:20 +02:00
parent f3da22c067
commit 3f0a8e8931
5 changed files with 18 additions and 16 deletions

View File

@ -59,12 +59,11 @@ class Scale(Thread):
def get_device(self):
try:
devices = [ device for device in listdir(self.input_dir)]
scales = [ device for device in devices if ('mettler' in device.lower()) or ('toledo' in device.lower()) ]
devices = [ device for device in listdir(self.input_dir)]
scales = [ device for device in devices if ('mettler' in device.lower()) or ('toledo' in device.lower()) ]
if len(scales) > 0:
print join(self.input_dir,scales[0])
self.set_status('connected','Connected to '+scales[0])
# s = serial.Serial("/dev/serial/by-id/usb-METTLER_TOLEDO_15_kg_DI_Firmware_CKOR_F_Ser_CDC-if00",baudrate=9600,bytesize=serial.SEVENBITS,parity=serial.PARITY_EVEN)
return serial.Serial(join(self.input_dir,scales[0]),
baudrate = 9600,
bytesize = serial.SEVENBITS,
@ -97,7 +96,7 @@ class Scale(Thread):
if self.device:
try:
self.device.write('W')
time.sleep(0.2)
time.sleep(0.1)
answer = []
while True:
@ -119,6 +118,7 @@ class Scale(Thread):
self.weight_info.append('over_capacity')
if stat & 1 << 2:
self.weight_info.append('negative')
self.weight = 0.0
if stat & 1 << 3:
self.weight_info.append('outside_zero_capture_range')
if stat & 1 << 4:

View File

@ -739,12 +739,10 @@
</field>
<group string="Features" >
<group>
<field name="iface_cashdrawer" />
<field name="iface_vkeyboard" />
<field name="iface_invoicing" />
<field name="iface_electronic_scale" />
</group>
<group>
<field name="iface_vkeyboard" />
<field name="iface_big_scrollbars" />
</group>
</group>
@ -752,6 +750,8 @@
<field name="proxy_ip" />
<field name="iface_print_via_proxy" />
<field name="iface_scan_via_proxy" />
<field name="iface_electronic_scale" />
<field name="iface_cashdrawer" />
</group>
<group string="Receipt" >
<field name="receipt_header" placeholder="A custom receipt header message"/>

View File

@ -394,7 +394,7 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
console.log(weight)
ret.resolve(self.use_debug_weight ? self.debug_weight : weight);
}, function(){ //failed to read weight
ret.resolve(self.use_debug_weight ? self.debug_weight : {weight:0.0, info:'ok'});
ret.resolve(self.use_debug_weight ? self.debug_weight : {weight:0.0, unit:'Kg', info:'ok'});
});
return ret;
},

View File

@ -693,7 +693,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
'open_cashbox',
'print_receipt',
'print_pdf_invoice',
'weighting_read_kg',
'scale_read',
'payment_status',
],
minimized: false,
@ -811,12 +811,6 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
self.pos.proxy.add_notification('transaction_end',function(){
self.$('.status.transaction').removeClass('on');
});
self.pos.proxy.add_notification('weighting_start',function(){
self.$('.status.weighting').addClass('on');
});
self.pos.proxy.add_notification('weighting_end',function(){
self.$('.status.weighting').removeClass('on');
});
},
});
@ -876,6 +870,14 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
msg += _t('Printer');
}
}
if( this.pos.config.iface_electronic_scale ){
var scale = status.drivers.scale ? status.drivers.scale.status : false;
if( scale != 'connected' && scale != 'connecting' ){
warning = true;
msg = msg ? msg + ' & ' : msg;
msg += _t('Scale');
}
}
msg = msg ? msg + ' ' + _t('Offline') : msg;
this.set_status(warning ? 'warning' : 'connected', msg);
}else{

View File

@ -692,7 +692,7 @@
<li class="event open_cashbox">Open Cashbox</li>
<li class="event print_receipt">Print Receipt</li>
<li class="event print_pdf_invoice">Print Invoice</li>
<li class="event weighting_read_kg">Read Weighting Scale</li>
<li class="event scale_read">Read Weighting Scale</li>
</ul>
</div>
</div>