[IMP] point_of_sale: removing comments, console.logs, and debug globals

bzr revid: fva@openerp.com-20120710101515-0jla27j85xcg87nm
This commit is contained in:
Frédéric van der Essen 2012-07-10 12:15:15 +02:00
parent 841a25b231
commit dd2384325b
6 changed files with 43 additions and 50 deletions

View File

@ -83,6 +83,9 @@
}
.point-of-sale .pos-right-align input {
text-align: right;
border: 1px solid #cecbcb;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
}
/* ********* The black header bar ********* */

View File

@ -1,7 +1,7 @@
function openerp_pos_devices(instance,module){ //module is instance.point_of_sale
window.debug_devices = new (instance.web.Class.extend({
var debug_devices = new (instance.web.Class.extend({
active: false,
payment_status: 'waiting_for_payment',
weight: 0,
@ -17,6 +17,8 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
delay_payment: function(){ this.activate(); this.payment_status = 'waiting_for_payment'; },
}))();
//window.debug_devices = debug_devices;
// this object interfaces with the local proxy to communicate to the various hardware devices
// connected to the Point of Sale. As the communication only goes from the POS to the proxy,
// methods are used both to signal an event, and to fetch information.
@ -36,14 +38,14 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
this.connection.setup(url);
},
message : function(name,params,callback){
var success_callback = function(result){}; //console.log('PROXY SUCCESS:'+name+': ',result); }
var error_callback = function(result){}; // console.log('PROXY ERROR:'+name+': ',result); }
//console.log('PROXY: '+name);
if(debug_devices.active){
message : function(name,params,success_callback, error_callback){
success_callback = success_callback || function(){};
error_callback = error_callback || function(){};
if(debug_devices && debug_devices.active){
console.log('PROXY:',name,params);
}else{
this.connection.rpc('/pos/'+name, params || {}, callback || success_callback, error_callback);
this.connection.rpc('/pos/'+name, params || {}, success_callback, error_callback);
}
},
@ -70,7 +72,9 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
//the client is starting to weight
weighting_start: function(){
this.weight = 0;
debug_devices.weigth = 0;
if(debug_devices){
debug_devices.weigth = 0;
}
this.weighting = true;
this.message('weighting_start');
},
@ -80,12 +84,11 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
// and a weighting_end()
weighting_read_kg: function(){
var self = this;
if(debug_devices.active){
if(debug_devices && debug_devices.active){
return debug_devices.weight;
}else{
this.message('weighting_read_kg',{},function(weight){
if(self.weighting){
console.log('PROXY SUCCESSFULLY READ WEIGHT:',weight);
self.weight = weight;
}
});
@ -106,7 +109,9 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
payment_request: function(price, method, info){
this.paying = true;
this.payment_status = 'waiting_for_payment';
debug_devices.payment_status = 'waiting_for_payment';
if(debug_devices){
debug_devices.payment_status = 'waiting_for_payment';
}
this.message('payment_request',{'price':price,'method':method,'info':info});
},
@ -394,10 +399,9 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
if (codeNumbers.length == 13) {
//We have found what seems to be a valid codebar
var parse_result = self.parse_ean(codeNumbers.join(''));
console.log('BARCODE:',parse_result);
if (parse_result.type === 'error') { //most likely a checksum error, raise warning
console.log('ERROR: barcode checksum error:',parse_result);
console.error('ERROR: barcode checksum error:',parse_result);
}else if(parse_result.type in {'unit':'', 'weight':'', 'price':''}){ //ean is associated to a product
if(self.action_callback['product']){
self.action_callback['product'](parse_result);

View File

@ -90,10 +90,10 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
'currency': {symbol: '$', position: 'after'},
'shop': null,
'company': null,
'user': null,
'user_list': null,
'cashier': null,
'client': null,
'user': null, // the user that loaded the pos
'user_list': null, // list of all users
'cashier': null, // the logged cashier, if different from user
'client': null, // the logged client
'orders': new module.OrderCollection(),
//this is the product list as seen by the product list widgets, it will change based on the category filters
@ -110,7 +110,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
'selectedOrder': undefined,
});
this.get('orders').bind('remove', _.bind( this.on_removed_order, this ) );
this.get('orders').bind('remove', function(){ self.on_removed_order(); });
// We fetch the backend data on the server asynchronously
@ -118,7 +118,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
.pipe(function(users){
var user = users[0];
self.set('user',user);
console.log('USER_DONE');
return fetch('res.company',
[
@ -135,12 +134,10 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
}).pipe(function(companies){
var company = companies[0];
self.set('company',company);
console.log('COMPANY_DONE');
return fetch('res.currency',['symbol','position'],[['id','=',company.currency_id[0]]]);
}).pipe(function (currencies){
self.set('currency',currencies[0]);
console.log('CURRENCY_DONE');
});
var cat_def = fetch('pos.category', ['id','name', 'parent_id', 'child_id', 'category_image_small'])
@ -154,7 +151,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
[['pos_categ_id','!=', false]]
).then(function(result){
self.set({'product_list': result});
console.log('PRODUCTS_DONE');
});
var uom_def = fetch( //unit of measure
@ -168,16 +164,14 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
units_by_id[result[i].id] = result[i];
}
self.set({'units_by_id':units_by_id});
console.log('UOM_DONE');
});
var user_def = fetch(
var users_def = fetch(
'res.users',
['name','ean13'],
[['ean13', '!=', false]]
).then(function(result){
self.set({'user_list':result});
console.log('USERS_DONE');
});
@ -197,13 +191,11 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
for(var i = 0; i < product_list.length; i++){
product_list[i].pos_category = cat_by_id[product_list[i].pos_categ_id[0]];
}
console.log('PROD_PROCESS_DONE');
});
var tax_def = fetch('account.tax', ['amount','price_include','type'])
.then(function(result){
self.set({'taxes': result});
console.log('TAX_DONE');
});
var session_def = fetch( // loading the PoS Session.
@ -227,7 +219,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
['name','journal_ids','shop_id','journal_id',
'iface_self_checkout', 'iface_websql', 'iface_led', 'iface_cashdrawer',
'iface_payment_terminal', 'iface_electronic_scale', 'iface_barscan', 'iface_vkeyboard',
'iface_print_via_proxy','state','sequence_id','session_ids'],
'iface_print_via_proxy','iface_cashdrawer','state','sequence_id','session_ids'],
[['id','=', pos_session.config_id[0]]]
).pipe(function(result){
var pos_config = result[0]
@ -239,12 +231,11 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
self.use_websql = pos_config.iface_websql || false;
self.use_barcode_scanner = pos_config.iface_barscan || false;
self.use_selfcheckout = pos_config.iface_self_checkout || false;
console.log('POS_CONFIG_DONE');
self.use_cashbox = pos_config.iface_cashdrawer || false;
return shop_def = fetch('sale.shop',[], [['id','=',pos_config.shop_id[0]]])
}).pipe(function(shops){
self.set('shop',shops[0]);
console.log('SHOP_DONE');
});
var bank_def = fetch(
@ -253,7 +244,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
[['state','=','open'],['pos_session_id', '=', pos_session.id]]
).then(function(result){
self.set({'bank_statements':result});
console.log('BANK_DEF_DONE');
});
var journal_def = fetch(
@ -262,7 +252,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
[['user_id','=',pos_session.user_id[0]]]
).then(function(result){
self.set({'journals':result});
console.log('JOURNALS_DONE');
});
// associate the bank statements with their journals.
@ -278,7 +267,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
}
}
}
console.log('BANK_PROCESS_DONE');
});
session_data_def = $.when(pos_config_def,bank_def,journal_def,bank_process_def);
@ -290,12 +278,11 @@ 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.
$.when(cat_def, prod_def, user_def, uom_def, session_def, tax_def, prod_process_def, user_def, this.flush())
$.when(cat_def, prod_def, user_def, users_def, uom_def, session_def, tax_def, prod_process_def, user_def, this.flush())
.then(function(){
//self.build_tree();
self.build_categories();
self.set({'cashRegisters' : new module.CashRegisterCollection(self.get('bank_statements'))});
self.log_loaded_data();
//self.log_loaded_data();
self.ready.resolve();
},function(){
//we failed to load some backend data, or the backend was badly configured.
@ -635,6 +622,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
product_id: this.get_product().get('id'),
};
},
//used to create a json of the ticket, to be sent to the printer
export_for_printing: function(){
return {
quantity: this.get_quantity(),
@ -734,6 +722,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
amount: this.get_amount()
};
},
//exports as JSON for receipt printing
export_for_printing: function(){
return {
amount: this.get_amount(),
@ -832,7 +821,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
},
// the order also stores the screen status, as the PoS supports
// different active screens per order. This method is used to
// store the screen status, and is used by
// store the screen status.
set_screen_data: function(key,value){
if(arguments.length === 2){
this.screen_data[key] = value;
@ -846,6 +835,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
get_screen_data: function(key){
return this.screen_data[key];
},
// exports a JSON for receipt printing
export_for_printing: function(){
var orderlines = [];
this.get('orderLines').each(function(orderline){

View File

@ -154,9 +154,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
},
close_button_action: function(){
console.log("Close!");
this.pos_widget.try_close();
//TODO
},
barcode_product_screen: 'products', //if defined, this screen will be loaded when a product is scanned
@ -353,7 +351,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
var self = this;
self.pos.proxy.weighting_start();
console.log('Active product:',self.pos_widget.screen_selector.get_current_screen_param('product'));
this.intervalID = setInterval(function(){
var weight = self.pos.proxy.weighting_read_kg();
@ -436,7 +433,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
},
get_product_name: function(){
var product = this.get_product();
console.log('PRoduct?',product);
return (product ? product.get('name') : undefined) || 'Unnamed Product';
},
get_product_price: function(){
@ -566,6 +562,9 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
this.product_categories_widget.reset_category();
this.pos_widget.order_widget.set_numpad_state(this.pos_widget.numpad.state);
if(this.pos.use_virtual_keyboard){
this.pos_widget.onscreen_keyboard.connect();
}
},
close: function(){
@ -648,6 +647,10 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
this._super();
var self = this;
if(this.pos.use_cashbox){
this.pos.proxy.open_cashbox();
}
this.set_numpad_state(this.pos_widget.numpad.state);
this.back_button = this.pos_widget.action_bar.add_new_button({
@ -678,8 +681,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
var self = this;
var currentOrder = this.pos.get('selectedOrder');
console.log('RECEIPT:',currentOrder.export_for_printing());
this.validate_button.$element.attr('disabled','disabled'); //FIXME is the css actually using this attr ?
this.pos.push_order(currentOrder.exportAsJSON())

View File

@ -76,6 +76,7 @@ function openerp_pos_scrollbar(instance, module){ //module is instance.point_of_
self.page_down();
}
});
// FIXME: use the event bus to handle window resize events
$(window).unbind('resize',this.resize_handler);
$(window).bind('resize',this.resize_handler);

View File

@ -68,7 +68,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
this.$element.click(function(){
if (self.pos.get('selectedOrder').get('screen') === 'receipt'){ //TODO Why ?
console.log('TODO should not get there...?');
console.warn('TODO should not get there...?');
return;
}
self.pos.get('selectedOrder').addPaymentLine(self.cashRegister);
@ -410,12 +410,10 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
$(button).appendTo(this.$('.category-list')).click(function(event){
var id = category.id;
console.log('Clicked category:',category);
var cat = self.pos.categories_by_id[id];
self.set_category(cat);
self.renderElement();
self.search_and_categories(cat);
console.log('coucou');
});
});
// breadcrumb click actions
@ -618,8 +616,6 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
this._super(arguments[0],{});
this.pos = new module.PosModel(this.session);
window.pos = this.pos;
window.pos_widget = this;
this.pos_widget = this; //So that pos_widget's childs have pos_widget set automatically
this.numpad_visible = true;
@ -763,8 +759,6 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
});
this.screen_selector.set_default_screen();
window.screen_selector = this.screen_selector; //DEBUG
this.pos.barcode_reader.connect();
},