[MERGE] back port of branch trunk up to revid 8924 fva@openerp.com-20130924094515-j605mg8lozzli3u2

bzr revid: chs@openerp.com-20130924110701-a5h94knbm279d1m0
This commit is contained in:
Christophe Simonis 2013-09-24 13:07:01 +02:00
commit 38a2ca7f3f
2 changed files with 77 additions and 52 deletions

View File

@ -8,14 +8,14 @@ msgstr ""
"Project-Id-Version: openobject-addons\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2012-12-21 17:05+0000\n"
"PO-Revision-Date: 2013-03-21 19:22+0000\n"
"Last-Translator: Liuming <gumdam20@me.com>\n"
"PO-Revision-Date: 2013-09-24 02:46+0000\n"
"Last-Translator: DWXXX <Unknown>\n"
"Language-Team: Chinese (Simplified) <zh_CN@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2013-09-12 06:40+0000\n"
"X-Generator: Launchpad (build 16761)\n"
"X-Launchpad-Export-Date: 2013-09-24 05:55+0000\n"
"X-Generator: Launchpad (build 16771)\n"
#. module: account_test
#: view:accounting.assert.test:0
@ -106,7 +106,7 @@ msgstr ""
#. module: account_test
#: view:accounting.assert.test:0
msgid "Description"
msgstr ""
msgstr "描述"
#. module: account_test
#: model:accounting.assert.test,desc:account_test.account_test_06_1
@ -123,13 +123,13 @@ msgstr ""
#: model:ir.actions.report.xml,name:account_test.account_assert_test_report
#: model:ir.ui.menu,name:account_test.menu_action_license
msgid "Accounting Tests"
msgstr ""
msgstr "帐户测试"
#. module: account_test
#: code:addons/account_test/report/account_test_report.py:74
#, python-format
msgid "The test was passed successfully"
msgstr ""
msgstr "测试通过"
#. module: account_test
#: field:accounting.assert.test,active:0
@ -155,7 +155,7 @@ msgstr ""
#. module: account_test
#: field:accounting.assert.test,code_exec:0
msgid "Python code"
msgstr ""
msgstr "Python代码"
#. module: account_test
#: model:accounting.assert.test,desc:account_test.account_test_07
@ -209,7 +209,7 @@ msgstr ""
#. module: account_test
#: view:accounting.assert.test:0
msgid "Python Code"
msgstr ""
msgstr "Python代码"
#. module: account_test
#: model:ir.actions.act_window,help:account_test.action_accounting_assert

View File

@ -450,7 +450,7 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
// it will check its validity then return an object containing various
// information about the ean.
// most importantly :
// - ean : the ean
// - code : the ean
// - type : the type of the ean:
// 'price' | 'weight' | 'unit' | 'cashier' | 'client' | 'discount' | 'error'
//
@ -460,13 +460,16 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
// - unit : if the encoded value has a unit, it will be put there.
// not to be confused with the 'unit' type, which represent an unit of a
// unique product
// - base_code : the ean code with all the encoding parts set to zero; the one put on
// the product in the backend
parse_ean: function(ean){
var parse_result = {
type:'unknown', //
encoding: 'ean13',
type:'unknown',
prefix:'',
ean:ean,
base_ean: ean,
code:ean,
base_code: ean,
id:'',
value: 0,
unit: 'none',
@ -487,13 +490,13 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
parse_result.type = 'error';
} else if( match_prefix(this.price_prefix_set,'price')){
parse_result.id = ean.substring(0,7);
parse_result.base_ean = this.sanitize_ean(ean.substring(0,7));
parse_result.base_code = this.sanitize_ean(ean.substring(0,7));
parse_result.value = Number(ean.substring(7,12))/100.0;
parse_result.unit = 'euro';
} else if( match_prefix(this.weight_prefix_set,'weight')){
parse_result.id = ean.substring(0,7);
parse_result.value = Number(ean.substring(7,12))/1000.0;
parse_result.base_ean = this.sanitize_ean(ean.substring(0,7));
parse_result.base_code = this.sanitize_ean(ean.substring(0,7));
parse_result.unit = 'Kg';
} else if( match_prefix(this.client_prefix_set,'client')){
parse_result.id = ean.substring(0,7);
@ -502,7 +505,7 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
parse_result.id = ean.substring(0,7);
} else if( match_prefix(this.discount_prefix_set,'discount')){
parse_result.id = ean.substring(0,7);
parse_result.base_ean = this.sanitize_ean(ean.substring(0,7));
parse_result.base_code = this.sanitize_ean(ean.substring(0,7));
parse_result.value = Number(ean.substring(7,12))/100.0;
parse_result.unit = '%';
} else {
@ -512,9 +515,18 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
}
return parse_result;
},
on_ean: function(ean){
var parse_result = this.parse_ean(ean);
scan: function(type,code){
if (type === 'ean13'){
var parse_result = this.parse_ean(code);
}else if(type === 'reference'){
var parse_result = {
encoding: 'reference',
type: 'unit',
code: code,
prefix: '',
};
}
if (parse_result.type === 'error') { //most likely a checksum error, raise warning
console.warn('WARNING: barcode checksum error:',parse_result);
@ -522,7 +534,6 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
if(this.action_callback['product']){
this.action_callback['product'](parse_result);
}
//this.trigger("codebar",parse_result );
}else{
if(this.action_callback[parse_result.type]){
this.action_callback[parse_result.type](parse_result);
@ -530,49 +541,63 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
}
},
on_reference: function(code){
if(this.action_callback['reference']){
this.action_callback['reference'](code);
}
},
// starts catching keyboard events and tries to interpret codebar
// calling the callbacks when needed.
connect: function(){
var self = this;
var codeNumbers = [];
var timeStamp = 0;
var lastTimeStamp = 0;
var code = "";
var timeStamp = 0;
var onlynumbers = true;
var timeout = null;
// The barcode readers acts as a keyboard, we catch all keyup events and try to find a
// barcode sequence in the typed keys, then act accordingly.
$('body').delegate('','keypress', function (e){
//console.log('keyup:'+String.fromCharCode(e.keyCode)+' '+e.keyCode,e);
//We only care about numbers
if (e.keyCode >= 48 && e.keyCode < 58){
this.handler = function(e){
// The barcode reader sends keystrokes with a specific interval.
// We look if the typed keys fit in the interval.
if (codeNumbers.length === 0) {
timeStamp = new Date().getTime();
} else {
if (lastTimeStamp + 30 < new Date().getTime()) {
// not a barcode reader
codeNumbers = [];
timeStamp = new Date().getTime();
}
}
codeNumbers.push(e.keyCode - 48);
lastTimeStamp = new Date().getTime();
if (codeNumbers.length === 13) {
//We have found what seems to be a valid codebar
self.on_ean(codeNumbers.join(''));
codeNumbers = [];
}
} else {
// NaN
codeNumbers = [];
if(e.which === 13){ //ignore returns
return;
}
});
if(timeStamp + 50 < new Date().getTime()){
code = "";
onlynumbers = true;
}
timeStamp = new Date().getTime();
clearTimeout(timeout);
if( e.which < 48 || e.which >= 58 ){ // not a number
onlynumbers = false;
}
code += String.fromCharCode(e.which);
// we wait for a while after the last input to be sure that we are not mistakingly
// returning a code which is a prefix of a bigger one :
// Internal Ref 5449 vs EAN13 5449000...
timeout = setTimeout(function(){
if(code.length === 13 && onlynumbers){
self.scan('ean13',code);
}else if(code.length >= 3 && self.pos.db.get_product_by_reference(code)){
self.scan('reference',code);
}
code = "";
onlynumbers = true;
},100);
};
$('body').on('keypress', this.handler);
},
// stops catching keyboard events
disconnect: function(){
$('body').undelegate('', 'keyup')
$('body').off('keypress', this.handler)
},
});