margin-top: 0px;
padding-top: 7px;
}
+.point-of-sale .step-screen p{
+ font-size: 18px;
+}
.point-of-sale .pos-step-container {
display: inline-block;
function openerp_pos_devices(module, instance){ //module is instance.point_of_sale
+ var QWeb = instance.web.qweb;
+
window.debug_devices = new (instance.web.Class.extend({
payment_status: 'waiting_for_payment',
weight: 0,
},
// called when the client logs in or starts to scan product
- transation_start: function(){
+ transaction_start: function(){
console.log('PROXY: transaction start');
},
init: function(attributes){
this.pos = attributes.pos;
- this.action_callbacks = {
+ this.action_callback = {
'product': undefined,
'cashier': undefined,
'client': undefined,
'discount': undefined,
};
+ this.price_prefix_set = attributes.price_prefix_set || {'02':'', '22':'', '24':'', '26':'', '28':''};
+ this.weight_prefix_set = attributes.weight_prefix_set || {'21':'','23':'','27':'','29':'','25':''};
+ this.client_prefix_set = attributes.weight_prefix_set || {'42':''};
+ this.cashier_prefix_set = attributes.weight_prefix_set || {'43':''};
+ this.discount_prefix_set = attributes.weight_prefix_set || {'44':''};
},
// when an ean is scanned and parsed, the callback corresponding
set_action_callbacks: function(callbacks){
for(action in callbacks){
- this.action_callbacks[action] = callbacks[action];
+ this.action_callback[action] = callbacks[action];
}
},
//remove all action callbacks
reset_action_callbacks: function(){
- for(action in this.action_callbacks){
- this.action_callbacks[action] = undefined;
+ for(action in this.action_callback){
+ this.action_callback[action] = undefined;
}
},
// ean must be a string
check_ean: function(ean){
var code = ean.split('');
+ for(var i = 0; i < code.length; i++){
+ code[i] = Number(code[i]);
+ }
var st1 = code.slice();
var st2 = st1.slice(0,st1.length-1).reverse();
// some EAN13 barcodes have a length of 12, as they start by 0
if(!this.check_ean(ean)){
parse_result.type = 'error';
- }else if (prefix2 in {'02':'', '22':'', '24':'', '26':'', '28':''}){
+ }else if (prefix2 in this.price_prefix_set){
parse_result.type = 'price';
parse_result.prefix = prefix2;
parse_result.id = ean.substring(0,7);
parse_result.value = Number(ean.substring(7,12))/100.0;
parse_result.unit = 'euro';
- } else if (prefix2 in {'21':'','23':'','27':'','29':'','25':''}) {
+ } else if (prefix2 in this.price_prefix_set){
parse_result.type = 'weight';
parse_result.prefix = prefix2;
- prase_result.id = ean.substring(0,7);
+ parse_result.id = ean.substring(0,7);
parse_result.value = Number(ean.substring(7,12))/1000.0;
parse_result.unit = 'Kg';
+ }else if (prefix2 in this.client_prefix_set){
+ parse_result.type = 'client';
+ parse_result.prefix = prefix2;
+ parse_result.id = ean.substring(0,7);
+ }else if (prefix2 in this.cashier_prefix_set){
+ parse_result.type = 'cashier';
+ parse_result.prefix = prefix2;
+ parse_result.id = ean.substring(0,7);
+ }else if (prefix2 in this.discount_prefix_set){
+ parse_result.type = 'discount';
+ parse_result.prefix = prefix2;
+ parse_result.id = ean.substring(0,7);
+ parse_result.value = Number(ean.substring(7,12))/100.0;
+ parse_result.unit = '%';
}else{
parse_result.type = 'unit';
parse_result.prefix = '';
var scannedProductModel = undefined;
var parse_result = this.parse_ean(ean);
+ console.log('getting products:',ean,parse_result,allProducts);
+
if (parse_result.type === 'price') {
var itemCode = parse_result.id;
var scannedPackaging = _.detect(allPackages, function(pack) { return pack.ean !== undefined && pack.ean.substring(0,7) === itemCode;});
// a default callback for the 'product' action. It will select the product
// corresponding to the ean and add it to the current order.
scan_product_callback: function(parse_result){
+ var self = this;
var selectedOrder = self.pos.get('selectedOrder');
var scannedProductModel = self.get_product_by_ean(parse_result.ean);
if (scannedProductModel === undefined) {
};
if(parse_result.type in {'unit':'', 'weight':'', 'price':''}){ //ean is associated to a product
+ console.log('calling product callback');
if(this.action_callback['product']){
+ console.log('found product callback');
this.action_callback['product'](parse_result);
}
}else{
+ console.log('calling callback:',parse_result.type);
if(this.action_callback[parse_result.type]){
+ console.log('found product callback');
this.action_callback[parse_result.type](parse_result);
}
}
-
},
// starts catching keyboard events and tries to interpret codebar
lastTimeStamp = new Date().getTime();
if (codeNumbers.length == 13) {
//We have found what seems to be a valid codebar
- var parse_result = this.parse_ean(codeNumbers.join(''));
+ 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
$(QWeb.render('pos-scan-warning')).dialog({
title: "Warning",
});
}else if(parse_result.type in {'unit':'', 'weight':'', 'price':''}){ //ean is associated to a product
- if(this.action_callback['product']){
- this.action_callback['product'](parse_result);
+ console.log('calling product callback');
+ if(self.action_callback['product']){
+ console.log('found product callback');
+ self.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);
+ console.log('calling callback:',parse_result.type);
+ if(self.action_callback[parse_result.type]){
+ console.log('found callback');
+ self.action_callback[parse_result.type](parse_result);
}
}
existing = (this.get('orderLines')).get(product.id);
if (existing != null) {
if(existing.get('weighted')){
- console.log('TODO VERIFY THIS');
existing.incrementWeight(product.attributes.weight);
}else{
existing.incrementQuantity();
this.current_popup = null;
- this.default_mode = options.default_mode || 'client';
- this.current_mode = this.default_mode;
+ this.current_mode = options.default_mode || 'client';
this.current_screen = this.current_mode === 'client' ?
this.current_client_screen:
}
},
load_saved_screen: function(){
- console.log('load_saved_screen');
this.close_popup();
- if(true || this.selected_order != this.pos.get('selectedOrder')){
- var selectedOrder = this.pos.get('selectedOrder');
-
- var user_mode = this.current_mode; //selectedOrder.get('user_mode');
- console.log('user mode:',user_mode);
-
- if(user_mode === 'client'){
- this.current_mode = 'client';
- this.set_current_screen(selectedOrder.get('client_screen') || this.default_client_screen);
- }else if(user_mode === 'cashier'){
- this.current_mode = 'cashier';
- console.log('default_cashier_screen:',this.default_cashier_screen);
- this.set_current_screen(selectedOrder.get('cashier_screen') || this.default_cashier_screen);
- }else{
- this.current_mode = this.default_mode;
- selectedOrder.set({ user_mode: this.current_mode });
- if(this.current_mode === 'client'){
- this.set_current_screen(this.default_client_screen);
- }else{
- this.set_current_screen(this.default_cashier_screen);
- }
- }
- this.selected_order = selectedOrder;
- // var screen = this.pos.get('selectedOrder').get('screen') || this.default_screen;
- // this.selected_order = this.pos.get('selectedOrder');
- // this.set_current_screen(screen);
+
+ var selectedOrder = this.pos.get('selectedOrder');
+
+ if(this.current_mode === 'client'){
+ this.set_current_screen(selectedOrder.get('client_screen') || this.default_client_screen);
+ }else if(this.current_mode === 'cashier'){
+ console.log('default_cashier_screen:',this.default_cashier_screen);
+ this.set_current_screen(selectedOrder.get('cashier_screen') || this.default_cashier_screen);
}
+ this.selected_order = selectedOrder;
},
set_user_mode: function(user_mode){
- console.log('set user mode:',user_mode);
if(user_mode !== this.current_mode){
this.close_popup();
this.current_mode = user_mode;
- this.pos.get('selectedOrder').set({ user_mode : this.current_mode });
this.load_saved_screen();
}
},
+ get_user_mode: function(){
+ return this.current_mode;
+ },
set_current_screen: function(screen_name){
var screen = this.screen_set[screen_name];
selectedOrder.set({'cashier_screen': screen_name});
}
- // console.log('Set Current Screen: '+screen_name+' :',screen,'old:',this.current_screen, 'mode:',this.current_mode);
if(screen && screen !== this.current_screen){
if(this.current_screen){
this.current_screen.hide();
{
label: 'back',
icon: '/point_of_sale/static/src/img/icons/png48/go-previous.png',
- click: function(){ //TODO Go to ask for weighting screen
+ click: function(){
clearInterval(this.intervalID);
self.pos.proxy.weighting_end();
self.pos.screen_selector.set_current_screen('scan');
show: function(){
this._super();
var self = this;
-
- this.pos_widget.set_numpad_visible(false);
- this.pos_widget.set_leftpane_visible(true);
- this.pos_widget.set_cashier_controls_visible(false);
- this.pos_widget.action_bar.set_total_visible(true);
- this.pos_widget.action_bar.set_help_visible(true,function(){self.pos.screen_selector.show_popup('help');});
- this.pos_widget.action_bar.set_logout_visible(false);
-
- this.pos_widget.orderView.setNumpadState(this.pos_widget.numpadView.state);
- this.pos_widget.action_bar.add_new_button(
- {
- label: 'back',
- icon: '/point_of_sale/static/src/img/icons/png48/go-previous.png',
- click: function(){
- self.pos.screen_selector.set_current_screen('scan');
+ if(this.pos.screen_selector.get_user_mode() === 'client'){
+ this.pos_widget.set_numpad_visible(false);
+ this.pos_widget.set_leftpane_visible(true);
+ this.pos_widget.set_cashier_controls_visible(false);
+ this.pos_widget.action_bar.set_total_visible(true);
+ this.pos_widget.action_bar.set_help_visible(true,function(){self.pos.screen_selector.show_popup('help');});
+ this.pos_widget.action_bar.set_logout_visible(false);
+
+ this.pos_widget.orderView.setNumpadState(this.pos_widget.numpadView.state);
+ this.pos_widget.action_bar.add_new_button(
+ {
+ label: 'back',
+ icon: '/point_of_sale/static/src/img/icons/png48/go-previous.png',
+ click: function(){
+ self.pos.screen_selector.set_current_screen('scan');
+ }
}
- }
- );
- this.pos.barcode_reader.set_action_callbacks({
- 'cashier': function(ean){
- //TODO 'switch to cashier mode'
- self.proxy.cashier_mode_activated();
- },
- });
+ );
+ this.pos.barcode_reader.set_action_callbacks({
+ 'cashier': function(ean){
+ self.proxy.cashier_mode_activated();
+ },
+ });
+ this.product_list_widget.set_next_screen('scan');
+ }else{ // user_mode === 'cashier'
+ this.pos_widget.set_numpad_visible(true);
+ this.pos_widget.set_leftpane_visible(true);
+ this.pos_widget.set_cashier_controls_visible(true);
+ this.pos_widget.action_bar.set_total_visible(true);
+ this.pos_widget.action_bar.set_help_visible(false);
+
+ this.pos_widget.orderView.setNumpadState(this.pos_widget.numpadView.state);
+ this.pos_widget.action_bar.add_new_button(
+ {
+ label: 'back',
+ icon: '/point_of_sale/static/src/img/icons/png48/go-previous.png',
+ click: function(){
+ self.pos.screen_selector.set_current_screen('products');
+ }
+ }
+ );
+ this.product_list_widget.set_next_screen('undefined');
+ }
this.pos.proxy.weighting_start();
this.last_weight = this.product_list_widget.weight;
this.intervalID = setInterval(function(){
var weight = self.pos.proxy.weighting_read_kg();
if(weight != self.last_weight){
- self.product_list_widget.setWeight(weight);
+ self.product_list_widget.set_weight(weight);
self.last_weight = weight;
}
},500);
clearInterval(this.intervalID);
this.pos.proxy.weighting_end();
},
-
});
module.ClientPaymentScreenWidget = module.ScreenWidget.extend({
},
});
},
+ hide: function(){
+ this._super();
+ clearInterval(this.intervalID);
+ },
});
module.WelcomeScreenWidget = module.ScreenWidget.extend({
);
this.pos.barcode_reader.set_action_callbacks({
'product': function(ean){
- self.proxy.transaction_start();
+ console.log('product!');
+ self.pos.proxy.transaction_start();
self.pos.barcode_reader.scan_product_callback(ean);
self.pos.screen_selector.set_current_screen('products');
},
'cashier': function(ean){
//TODO 'switch to cashier mode'
- self.proxy.cashier_mode_activated();
+ self.pos.proxy.cashier_mode_activated();
self.pos.screen_selector.set_current_screen('products');
},
'client': function(ean){
- self.proxy.transaction_start();
+ self.pos.proxy.transaction_start();
//TODO 'log the client'
self.pos.screen_selector.show_popup('receipt');
},
{
label: 'weight',
icon: '/point_of_sale/static/src/img/icons/png48/scale.png',
- click: function(){ //TODO Go to ask for weighting screen
+ click: function(){
+ self.pos.screen_selector.set_current_screen('scale_product');
}
}
);
}
},
'cashier': function(ean){
- //TODO 'switch to cashier mode'
self.proxy.cashier_mode_activated();
},
'discount': function(ean){
this.model = options.model;
this.pos = options.pos;
this.model.attributes.weight = options.weight || undefined;
+ this.next_screen = options.next_screen || undefined;
},
addToOrder: function(event) {
/* Preserve the category URL */
event.preventDefault();
return (this.pos.get('selectedOrder')).addProduct(this.model);
},
- setWeight: function(weight){
+ set_weight: function(weight){
this.model.attributes.weight = weight;
this.renderElement();
},
+ set_next_screen: function(screen){
+ this.next_screen = screen;
+ },
renderElement: function() {
+ var self = this;
this.$element.addClass("product");
this.$element.html(this.template_fct(this.model.toJSON()));
- $("a", this.$element).click(_.bind(this.addToOrder, this));
- return this;
+ $("a", this.$element).click(function(e){
+ self.addToOrder(e);
+ if(self.next_screen){
+ self.pos.screen_selector.set_current_screen(self.next_screen); //FIXME There ought to be a better way to do this ...
+ }
+ });
},
});
this.pos.get('products').bind('reset', this.renderElement, this);
this.product_list = [];
this.weight = options.weight;
+ this.next_screen = options.next_screen || false;
+ },
+ set_weight: function(weight){
+ for(var i = 0; i < this.product_list.length; i++){
+ this.product_list[i].set_weight(weight);
+ }
},
- setWeight: function(weight){
+ set_next_screen: function(screen){
for(var i = 0; i < this.product_list.length; i++){
- this.product_list[i].setWeight(weight);
+ this.product_list[i].set_next_screen(screen);
}
},
renderElement: function() {
if(visible){
$('#numpad').show();
$('#paypad').show();
+ $('#current-order').css({'bottom':'271px'});
}else{
$('#numpad').hide();
$('#paypad').hide();
+ $('#current-order').css({'bottom':'0px'});
}
}
},
<t t-name="WelcomeScreenWidget">
<div class="welcome-screen step-screen">
<header><h2>Welcome</h2></header>
- <p> please scan an item or your member card </p>
+ <img src="/point_of_sale/static/src/img/scan.png" />
+ <p> Please scan an item or your member card </p>
</div>
</t>
<t t-name="ScanProductScreenWidget">
<div class="scan-product-screen step-screen">
- <header><h2>Scan your item</h2></header>
- <p>Please scan an item</p>
+ <header><h2>Please scan an item</h2></header>
+ <img src="/point_of_sale/static/src/img/scan.png" />
</div>
</t>
<t t-name="ClientPaymentScreenWidget">
<div class="scan-product-screen step-screen">
<header><h2>Payment</h2></header>
+ <img src="/point_of_sale/static/src/img/bancontact.png" />
<p>Please insert your card in the reader and follow the instructions to complete
your purchase</p>
</div>
<t t-name="ScaleInviteScreenWidget">
<div class="scale-invite-screen step-screen">
<header><h2>Please put your product on the scale</h2></header>
- <p></p>
+ <img src="/point_of_sale/static/src/img/scale.png" />
</div>
</t>