diff options
| author | Christophe Simonis <chs@odoo.com> | 2015-07-22 16:17:54 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2015-07-22 16:17:54 +0200 |
| commit | 2cf91d16a5f844a2a3d5d22c025c180a6615bab8 (patch) | |
| tree | a7bc3974a9c349ae1575fd3b10bbb25d9b74b9ab /addons/barcodes/static/src | |
| parent | d74e0c3e9d9cd80bf532ba90f7c634ff55881b51 (diff) | |
| parent | 63e92cbc9621813a276e340b7d961cbd8f8b97c4 (diff) | |
[MERGE] forward port of branch saas-6 up to 63e92cb
Diffstat (limited to 'addons/barcodes/static/src')
| -rw-r--r-- | addons/barcodes/static/src/js/barcode_parser.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/addons/barcodes/static/src/js/barcode_parser.js b/addons/barcodes/static/src/js/barcode_parser.js index 00462f36a51..1f804a40fea 100644 --- a/addons/barcodes/static/src/js/barcode_parser.js +++ b/addons/barcodes/static/src/js/barcode_parser.js @@ -118,7 +118,7 @@ var BarcodeParser = Class.extend({ // - value: the numerical value encoded in the barcode (0 if no value encoded) // - base_code: the barcode in which numerical content is replaced by 0's // - match: boolean - match_pattern: function (barcode, pattern){ + match_pattern: function (barcode, pattern, encoding){ var match = { value: 0, base_code: barcode, @@ -156,6 +156,16 @@ var BarcodeParser = Class.extend({ .replace("\{", "{") .replace("\}","}") .replace("\.","."); + + var base_code = match.base_code.split('') + if (encoding === 'ean13') { + base_code[12] = '' + this.ean_checksum(match.base_code); + } else if (encoding === 'ean8') { + base_code[7] = '' + this.ean8_checksum(match.base_code); + } else if (encoding === 'upca') { + base_code[11] = '' + this.ean_checksum('0' + match.base_code); + } + match.base_code = base_code.join('') } if (base_pattern[0] !== '^') { @@ -208,7 +218,7 @@ var BarcodeParser = Class.extend({ continue; } - var match = this.match_pattern(cur_barcode,rules[i].pattern); + var match = this.match_pattern(cur_barcode, rules[i].pattern, rule.encoding); if (match.match) { if(rules[i].type === 'alias') { barcode = rules[i].alias; |
