diff --git a/pos_barcode_tare/__openerp__.py b/pos_barcode_tare/__openerp__.py
index 36841678..578341f4 100644
--- a/pos_barcode_tare/__openerp__.py
+++ b/pos_barcode_tare/__openerp__.py
@@ -12,8 +12,9 @@
'license': 'AGPL-3',
'depends': ['point_of_sale'],
'data': [
+ 'pos_barcode_tare.xml',
'views/pos_config_view.xml',
- 'views/pos_barcode_tare.xml',
+ 'data/barcode_rule.xml',
],
'qweb': [
'static/src/xml/pos_barcode_tare.xml',
diff --git a/pos_barcode_tare/data/barcode_rule.xml b/pos_barcode_tare/data/barcode_rule.xml
new file mode 100644
index 00000000..a8ecb861
--- /dev/null
+++ b/pos_barcode_tare/data/barcode_rule.xml
@@ -0,0 +1,12 @@
+
+
+
+
+ Tare
+
+ 81
+ tare
+ ean13
+ 0700000{NNDDD}
+
+
diff --git a/pos_barcode_tare/views/pos_barcode_tare.xml b/pos_barcode_tare/pos_barcode_tare.xml
similarity index 100%
rename from pos_barcode_tare/views/pos_barcode_tare.xml
rename to pos_barcode_tare/pos_barcode_tare.xml
diff --git a/pos_barcode_tare/static/src/js/pos_barcode_tare.js b/pos_barcode_tare/static/src/js/pos_barcode_tare.js
index d2b676ed..2424fe87 100644
--- a/pos_barcode_tare/static/src/js/pos_barcode_tare.js
+++ b/pos_barcode_tare/static/src/js/pos_barcode_tare.js
@@ -180,18 +180,6 @@ odoo.define('pos_barcode_tare.screens', function (require) {
}
return this.weight_in_kg;
},
- ean13_checksum: function (s) {
- var result = 0;
- for (var counter = s.length-1; counter >=0; counter--) {
- var counterCheckSum = counter % 2;
- counterCheckSum *= 2;
- counterCheckSum += 1;
- result += parseInt(s.charAt(counter), 10) * counterCheckSum;
- }
- var checksum = 10;
- checksum -= result % 10;
- return checksum % 10;
- },
barcode_data: function (weight) {
// We use EAN13 barcode, it looks like 07 00000 12345 x. First there
// is the prefix, here 07, that is used to decide which type of
@@ -207,13 +195,15 @@ odoo.define('pos_barcode_tare.screens', function (require) {
var weight_with_padding = '0'.repeat(padding_size) + weight_in_gram;
var padded_weight = weight_with_padding.substr(
weight_with_padding.length - padding_size);
- // Builds the barcode data (ie. all but the checksum).
- var barcode_data = this.weight_barcode_prefix
- .concat(void_product_id, padded_weight);
- // Compute checksum and concat with barcode data to get the actual
- // barcode.
- var checksum = this.ean13_checksum(barcode_data);
- return barcode_data.concat(checksum);
+ // Builds the barcode using a placeholder checksum.
+ var barcode = this.weight_barcode_prefix
+ .concat(void_product_id, padded_weight)
+ .concat(0);
+ // Compute checksum
+ var barcode_parser = this.pos.barcode_reader.barcode_parser;
+ var checksum = barcode_parser.ean_checksum(barcode);
+ // Replace checksum placeholder by the actual checksum.
+ return barcode.substr(0, 12).concat(checksum);
},
get_barcode_data: function () {
return this.barcode_data(this.get_weight());
diff --git a/pos_barcode_tare/views/pos_config_view.xml b/pos_barcode_tare/views/pos_config_view.xml
index cbfb762b..ffce7377 100644
--- a/pos_barcode_tare/views/pos_config_view.xml
+++ b/pos_barcode_tare/views/pos_config_view.xml
@@ -1,6 +1,6 @@
-
+
pos.config
@@ -13,13 +13,4 @@
-
-
- Tare
-
- 81
- tare
- ean13
- 0700000{NNDDD}
-