diff --git a/addons/barcodes/__openerp__.py b/addons/barcodes/__openerp__.py
index 53a4773b65f..c4a74f38037 100644
--- a/addons/barcodes/__openerp__.py
+++ b/addons/barcodes/__openerp__.py
@@ -21,7 +21,7 @@
{
- 'name': 'Advanced Barcodes',
+ 'name': 'Barcodes',
'version': '1.0',
'category': '',
'sequence': 6,
diff --git a/addons/barcodes/barcodes.py b/addons/barcodes/barcodes.py
index ab0e7bac6ab..4f192403501 100644
--- a/addons/barcodes/barcodes.py
+++ b/addons/barcodes/barcodes.py
@@ -33,7 +33,6 @@ class barcode_nomenclature(osv.osv):
_name = 'barcode.nomenclature'
_columns = {
'name': fields.char('Nomenclature Name', size=32, required=True, help='An internal identification of the barcode nomenclature'),
- #'convert_to_ean13': fields.boolean('Convert to EAN-13',help='Numerical Barcodes shorter than EAN-13 will be automatically converted to EAN-13'),
'rule_ids': fields.one2many('barcode.rule','barcode_nomenclature_id','Rules', help='The list of barcode rules'),
}
@@ -166,15 +165,15 @@ class barcode_rule(models.Model):
'name': fields.char('Rule Name', size=32, required=True, help='An internal identification for this barcode nomenclature rule'),
'barcode_nomenclature_id': fields.many2one('barcode.nomenclature','Barcode Nomenclature'),
'sequence': fields.integer('Sequence', help='Used to order rules such that rules with a smaller sequence match first'),
- #'encoding': fields.selection([('any','Any'),('ean13','EAN-13'),('ean8','EAN-8'),('codabar','Codabar'),('upca','UPC-A'),('upce','UPC-E')],'Encoding',help='This rule will apply only if the barcode is encoded with the specified encoding'),
'encoding': fields.selection([('any','Any'),('ean13','EAN-13')],'Encoding',required=True,help='This rule will apply only if the barcode is encoded with the specified encoding'),
'type': fields.selection([('alias','Alias'),('product','Unit Product')],'Type', required=True),
'pattern': fields.char('Barcode Pattern', size=32, help="The barcode matching pattern"),
- 'alias': fields.char('Alias',size=32,help='The matched pattern will alias to this barcode'),
+ 'alias': fields.char('Alias',size=32,help='The matched pattern will alias to this barcode',required=True),
}
_defaults = {
'type': 'product',
'pattern': '*',
'encoding': 'any',
+ 'alias': "0",
}
diff --git a/addons/barcodes/barcodes_view.xml b/addons/barcodes/barcodes_view.xml
index efc940475de..e799ab43563 100644
--- a/addons/barcodes/barcodes_view.xml
+++ b/addons/barcodes/barcodes_view.xml
@@ -58,8 +58,8 @@
-
-
+
+
diff --git a/addons/barcodes/static/src/js/barcode_parser.js b/addons/barcodes/static/src/js/barcode_parser.js
index e3b9ae3fd4e..8a8c2ff5399 100644
--- a/addons/barcodes/static/src/js/barcode_parser.js
+++ b/addons/barcodes/static/src/js/barcode_parser.js
@@ -1,10 +1,18 @@
-function openerp_barcode_parser(instance,module){
+openerp.barcodes = function(instance) {
+ "use strict";
+
+ instance.barcodes = {};
+ var module = instance.barcodes;
module.BarcodeParser = instance.web.Class.extend({
init: function(attributes) {
var self = this;
this.nomenclature_id = attributes.nomenclature_id;
- this.load_server_data();
+ this.loaded = this.load_server_data();
+ },
+
+ is_loaded: function() {
+ return self.loaded;
},
models: [
diff --git a/addons/barcodes/static/src/js/main.js b/addons/barcodes/static/src/js/main.js
deleted file mode 100644
index 69e702ebe74..00000000000
--- a/addons/barcodes/static/src/js/main.js
+++ /dev/null
@@ -1,9 +0,0 @@
-
-openerp.barcodes = function(instance) {
- "use strict";
-
- instance.barcode_parser = {};
- var module = instance.barcode_parser;
-
- openerp_barcode_parser(instance,module); // import barcodes.js
-};
diff --git a/addons/barcodes/views/templates.xml b/addons/barcodes/views/templates.xml
index 965eab7e221..9e255e57290 100644
--- a/addons/barcodes/views/templates.xml
+++ b/addons/barcodes/views/templates.xml
@@ -7,7 +7,6 @@
-
diff --git a/addons/point_of_sale/static/src/js/db.js b/addons/point_of_sale/static/src/js/db.js
index 2711dbcf9f9..84473626b01 100644
--- a/addons/point_of_sale/static/src/js/db.js
+++ b/addons/point_of_sale/static/src/js/db.js
@@ -24,7 +24,6 @@ function openerp_pos_db(instance, module){
this.product_by_id = {};
this.product_by_barcode = {};
this.product_by_category_id = {};
- //this.product_by_reference = {};
this.partner_sorted = [];
this.partner_by_id = {};
@@ -212,9 +211,6 @@ function openerp_pos_db(instance, module){
if(product.barcode){
this.product_by_barcode[product.barcode] = product;
}
- /*if(product.default_code){
- this.product_by_reference[product.default_code] = product;
- }*/
}
},
add_packagings: function(packagings){
@@ -359,15 +355,12 @@ function openerp_pos_db(instance, module){
if(this.product_by_barcode[barcode]){
return this.product_by_barcode[barcode];
}
- var pack = this.packagings_by_barcode<[barcode];
+ var pack = this.packagings_by_barcode[barcode];
if(pack){
return this.product_by_id[pack.product_tmpl_id[0]];
}
return undefined;
},
- /*get_product_by_reference: function(ref){
- return this.product_by_reference[ref];
- },*/
get_product_by_category: function(category_id){
var product_ids = this.product_by_category_id[category_id];
var list = [];
diff --git a/addons/point_of_sale/static/src/js/devices.js b/addons/point_of_sale/static/src/js/devices.js
index 7ca14d16be1..4e2cce1c0e9 100644
--- a/addons/point_of_sale/static/src/js/devices.js
+++ b/addons/point_of_sale/static/src/js/devices.js
@@ -508,22 +508,21 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
},
scan: function(code){
- if(this.barcode_parser) {
- var parsed_result = this.barcode_parser.parse_barcode(code);
- }
- else{
- console.error("Barcode Parser not yet initialized!");
- }
+ var parsed_result = this.barcode_parser.parse_barcode(code);
+
if(parsed_result.type in {'product':'', 'weight':'', 'price':''}){ //barcode is associated to a product
if(this.action_callback['product']){
this.action_callback['product'](parsed_result);
}
}
- else{
+ else if (parsed_result.type in {'cashier':'', 'client':''}){
if(this.action_callback[parsed_result.type]){
this.action_callback[parsed_result.type](parsed_result);
}
}
+ else{
+ this.action_callback['error'](parsed_result);
+ }
},
// starts catching keyboard events and tries to interpret codebar
diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js
index 39415f5fd99..b88f82faa20 100644
--- a/addons/point_of_sale/static/src/js/models.js
+++ b/addons/point_of_sale/static/src/js/models.js
@@ -3,7 +3,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
var QWeb = instance.web.qweb;
var _t = instance.web._t;
- var barcode_parser_module = instance.barcode_parser;
+ var barcode_parser_module = instance.barcodes;
var round_di = instance.web.round_decimals;
var round_pr = instance.web.round_precision
@@ -80,9 +80,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
// when all the data has loaded, we compute some stuff, and declare the Pos ready to be used.
this.ready = this.load_server_data()
.then(function(){
- var barcode_parser = new barcode_parser_module.BarcodeParser({'nomenclature_id': self.config.barcode_nomenclature_id});
- self.barcode_reader.set_barcode_parser(barcode_parser);
-
if(self.config.use_proxy){
return self.connect_to_proxy();
}
@@ -368,7 +365,14 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
return logo_loaded;
},
- },
+ }, {
+ label: 'barcodes',
+ loaded: function(self) {
+ var barcode_parser = new barcode_parser_module.BarcodeParser({'nomenclature_id': self.config.barcode_nomenclature_id});
+ self.barcode_reader.set_barcode_parser(barcode_parser);
+ return barcode_parser.is_loaded();
+ },
+ }
],
// loads all the needed data on the sever. returns a deferred indicating when all the data has loaded.
@@ -695,11 +699,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
scan_product: function(parsed_code){
var self = this;
var selectedOrder = this.get_order();
- //if(parsed_code.encoding === 'barcode'){
- var product = this.db.get_product_by_barcode(parsed_code.base_code);
- /*}else if(parsed_code.encoding === 'reference'){
- var product = this.db.get_product_by_reference(parsed_code.code);
- }*/
+ var product = this.db.get_product_by_barcode(parsed_code.base_code);
if(!product){
return false;
diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js
index 9d3b99631e7..831bdf3b9e3 100644
--- a/addons/point_of_sale/static/src/js/screens.js
+++ b/addons/point_of_sale/static/src/js/screens.js
@@ -212,11 +212,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
last_orderline.set_discount(code.value)
}
},
- // What happens when an alias barcode is scanned, but the barcode referenced
- // in the alias finds no match : shows an error popup.
- barcode_alias_action: function(code){
- this.pos_widget.screen_selector.show_popup('error-alias-barcode',code);
- },
// What happens when an invalid barcode is scanned : shows an error popup.
barcode_error_action: function(code){
this.pos_widget.screen_selector.show_popup('error-barcode',code.code);
@@ -243,7 +238,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
'product': self.barcode_product_action ? function(code){ self.barcode_product_action(code); } : undefined ,
'client' : self.barcode_client_action ? function(code){ self.barcode_client_action(code); } : undefined ,
'discount': self.barcode_discount_action ? function(code){ self.barcode_discount_action(code); } : undefined,
- 'alias': self.barcode_alias_action ? function(code){ self.barcode_alias_action(code); } : undefined,
'error' : self.barcode_error_action ? function(code){ self.barcode_error_action(code); } : undefined,
});
},
@@ -351,15 +345,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
template:'ErrorTracebackPopupWidget',
});
- module.ErrorAliasBarcodePopupWidget = module.ErrorPopupWidget.extend({
- template:'ErrorAliasBarcodePopupWidget',
- show: function(barcode){
- this.barcode = barcode.code;
- this.alias = barcode.base_code;
- this._super();
- },
- });
-
module.ErrorBarcodePopupWidget = module.ErrorPopupWidget.extend({
template:'ErrorBarcodePopupWidget',
show: function(barcode){
diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js
index f47ebb57518..ae469060b3a 100644
--- a/addons/point_of_sale/static/src/js/widgets.js
+++ b/addons/point_of_sale/static/src/js/widgets.js
@@ -1025,9 +1025,6 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
this.error_barcode_popup = new module.ErrorBarcodePopupWidget(this, {});
this.error_barcode_popup.appendTo(this.$el);
- this.error_alias_barcode_popup = new module.ErrorAliasBarcodePopupWidget(this, {});
- this.error_alias_barcode_popup.appendTo(this.$el);
-
this.error_traceback_popup = new module.ErrorTracebackPopupWidget(this,{});
this.error_traceback_popup.appendTo(this.$el);
@@ -1118,7 +1115,6 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
popup_set:{
'error': this.error_popup,
'error-barcode': this.error_barcode_popup,
- 'error-alias-barcode': this.error_alias_barcode_popup,
'error-traceback': this.error_traceback_popup,
'textinput': this.textinput_popup,
'textarea': this.textarea_popup,
diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml
index 898c56b4e8d..146b8a1a9ae 100644
--- a/addons/point_of_sale/static/src/xml/pos.xml
+++ b/addons/point_of_sale/static/src/xml/pos.xml
@@ -912,26 +912,6 @@
-
-
-
-
-
-