[FIX] point_of_sale: various fixes for the client mode on the pos
bzr revid: fva@openerp.com-20120712170013-ea6u23wunncmslgz
This commit is contained in:
parent
35b08fb1fc
commit
6587e7fe99
|
@ -69,14 +69,14 @@ class PointOfSaleController(openerpweb.Controller):
|
|||
print "payment_request: price:"+str(price)+" method:"+str(method)+" info:"+str(info)
|
||||
return
|
||||
|
||||
#@openerpweb.jsonrequest
|
||||
@openerpweb.jsonrequest
|
||||
def is_payment_accepted(self, request):
|
||||
print "is_payment_accepted"
|
||||
return
|
||||
return 'waiting_for_payment'
|
||||
|
||||
#@openerpweb.jsonrequest
|
||||
def payment_cancelled(self, request):
|
||||
print "payment_cancelled"
|
||||
@openerpweb.jsonrequest
|
||||
def payment_canceled(self, request):
|
||||
print "payment_canceled"
|
||||
return
|
||||
|
||||
@openerpweb.jsonrequest
|
||||
|
|
|
@ -257,8 +257,9 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
|
|||
if(arguments.length == 2){
|
||||
this.action_callback[action] = callback;
|
||||
}else{
|
||||
for(action in arguments[0]){
|
||||
this.set_action_callback(action,arguments[0][action]);
|
||||
var actions = arguments[0];
|
||||
for(action in actions){
|
||||
this.set_action_callback(action,actions[action]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -44,7 +44,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
}
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
var fetch = function(model, fields, domain, ctx){
|
||||
|
@ -93,7 +92,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
'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
|
||||
|
@ -750,6 +748,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
orderLines: new module.OrderlineCollection(),
|
||||
paymentLines: new module.PaymentlineCollection(),
|
||||
name: "Order " + this.generateUniqueId(),
|
||||
client: null,
|
||||
});
|
||||
this.pos = attributes.pos;
|
||||
this.selected_orderline = undefined;
|
||||
|
@ -759,18 +758,22 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
generateUniqueId: function() {
|
||||
return new Date().getTime();
|
||||
},
|
||||
addProduct: function(product,quantity){
|
||||
addProduct: function(product, options){
|
||||
options = options || {};
|
||||
var attr = product.toJSON();
|
||||
attr.pos = this.pos;
|
||||
attr.order = this;
|
||||
var line = new module.Orderline({}, {pos: this.pos, order: this, product: product});
|
||||
|
||||
if(quantity !== undefined){
|
||||
line.set_quantity(quantity);
|
||||
if(options.quantity !== undefined){
|
||||
line.set_quantity(options.quantity);
|
||||
}
|
||||
if(options.price !== undefined){
|
||||
line.set_list_price(options.price);
|
||||
}
|
||||
|
||||
var last_orderline = this.getLastOrderline();
|
||||
if( last_orderline && last_orderline.can_be_merged_with(line) ){
|
||||
if( last_orderline && last_orderline.can_be_merged_with(line) && options.merge !== false){
|
||||
last_orderline.merge(line);
|
||||
}else{
|
||||
this.get('orderLines').add(line);
|
||||
|
@ -821,6 +824,13 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
getDueLeft: function() {
|
||||
return this.getTotal() - this.getPaidTotal();
|
||||
},
|
||||
// the client related to the current order.
|
||||
set_client: function(client){
|
||||
this.set('client',client);
|
||||
},
|
||||
get_client: function(){
|
||||
return this.get('client');
|
||||
},
|
||||
// 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.
|
||||
|
@ -848,7 +858,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
this.get('paymentLines').each(function(paymentline){
|
||||
paymentlines.push(paymentline.export_for_printing());
|
||||
});
|
||||
var client = this.pos.get('client');
|
||||
var client = this.get('client');
|
||||
var cashier = this.pos.get('cashier') || this.pos.get('user');
|
||||
var company = this.pos.get('company');
|
||||
var shop = this.pos.get('shop');
|
||||
|
|
|
@ -75,9 +75,9 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
var selectedOrder = this.pos.get('selectedOrder');
|
||||
|
||||
if(this.current_mode === 'client'){
|
||||
this.set_current_screen(selectedOrder.get_screen_data('client_screen') || this.default_client_screen);
|
||||
this.set_current_screen(selectedOrder.get_screen_data('client_screen') || this.default_client_screen,null,'refresh');
|
||||
}else if(this.current_mode === 'cashier'){
|
||||
this.set_current_screen(selectedOrder.get_screen_data('cashier_screen') || this.default_cashier_screen);
|
||||
this.set_current_screen(selectedOrder.get_screen_data('cashier_screen') || this.default_cashier_screen,null,'refresh');
|
||||
}
|
||||
this.selected_order = selectedOrder;
|
||||
},
|
||||
|
@ -91,8 +91,11 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
get_user_mode: function(){
|
||||
return this.current_mode;
|
||||
},
|
||||
set_current_screen: function(screen_name,params){
|
||||
set_current_screen: function(screen_name,params,refresh){
|
||||
var screen = this.screen_set[screen_name];
|
||||
if(!screen){
|
||||
console.error("ERROR: set_current_screen("+screen_name+") : screen not found");
|
||||
}
|
||||
|
||||
this.close_popup();
|
||||
var selectedOrder = this.pos.get('selectedOrder');
|
||||
|
@ -108,7 +111,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
}
|
||||
}
|
||||
|
||||
if(screen && screen !== this.current_screen){
|
||||
if(screen && (refresh || screen !== this.current_screen)){
|
||||
if(this.current_screen){
|
||||
this.current_screen.close();
|
||||
this.current_screen.hide();
|
||||
|
@ -183,7 +186,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
barcode_cashier_action: function(ean){
|
||||
var users = this.pos.get('user_list');
|
||||
for(var i = 0, len = users.length; i < len; i++){
|
||||
if(users[i].ean === ean.ean){
|
||||
if(users[i].ean13 === ean.ean){
|
||||
this.pos.set('cashier',users[i]);
|
||||
this.pos_widget.username.refresh();
|
||||
this.pos.proxy.cashier_mode_activated();
|
||||
|
@ -201,8 +204,8 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
barcode_client_action: function(ean){
|
||||
var users = this.pos.get('user_list');
|
||||
for(var i = 0, len = users.length; i < len; i++){
|
||||
if(users[i].ean === ean.ean){
|
||||
this.pos.set('client',users[i]);
|
||||
if(users[i].ean13 === ean.ean){
|
||||
this.pos.get('selectedOrder').set_client(users[i]);
|
||||
this.pos_widget.username.refresh();
|
||||
return true;
|
||||
}
|
||||
|
@ -429,7 +432,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
},
|
||||
order_product: function(){
|
||||
var weight = this.pos.proxy.weighting_read_kg();
|
||||
this.pos.get('selectedOrder').addProduct(this.get_product(),weight);
|
||||
this.pos.get('selectedOrder').addProduct(this.get_product(),{ quantity:weight });
|
||||
},
|
||||
get_product_name: function(){
|
||||
var product = this.get_product();
|
||||
|
@ -498,7 +501,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
click: function(){ //TODO Go to ask for weighting screen
|
||||
clearInterval(this.intervalID);
|
||||
self.pos.proxy.payment_canceled();
|
||||
self.pos_widget.screen_selector.set_current_screen('scan');
|
||||
self.pos_widget.screen_selector.set_current_screen('products');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -514,21 +517,15 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
|
||||
show_numpad: false,
|
||||
show_leftpane: false,
|
||||
|
||||
barcode_client_action: function(ean){
|
||||
this._super(ean);
|
||||
this.pos_widget.screen_selector.set_current_screen('products');
|
||||
},
|
||||
|
||||
show: function(){
|
||||
this._super();
|
||||
var self = this;
|
||||
|
||||
if(this.pos.use_scale){
|
||||
//FIXME
|
||||
this.pos_widget.action_bar.add_new_button({
|
||||
label: 'weight',
|
||||
icon: '/point_of_sale/static/src/img/icons/png48/scale.png',
|
||||
click: function(){
|
||||
self.pos_widget.screen_selector.set_current_screen('scale_invite');
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -565,6 +562,16 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
if(this.pos.use_virtual_keyboard){
|
||||
this.pos_widget.onscreen_keyboard.connect();
|
||||
}
|
||||
|
||||
if(this.pos_widget.screen_selector.current_mode === 'client'){
|
||||
this.pos_widget.action_bar.add_new_button({
|
||||
label: 'pay',
|
||||
icon: '/point_of_sale/static/src/img/icons/png48/go-next.png',
|
||||
click: function(){
|
||||
self.pos_widget.screen_selector.set_current_screen('client_payment');
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
close: function(){
|
||||
|
|
|
@ -112,6 +112,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
template:'OrderWidget',
|
||||
init: function(parent, options) {
|
||||
this._super(parent,options);
|
||||
this.compact = false;
|
||||
this.set_numpad_state(options.numpadState);
|
||||
this.pos.bind('change:selectedOrder', this.change_selected_order, this);
|
||||
this.bind_orderline_events();
|
||||
|
@ -163,6 +164,11 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
renderElement: function() {
|
||||
var self = this;
|
||||
this._super();
|
||||
|
||||
if(!this.compact){
|
||||
$('.point-of-sale .order-container').css({'bottom':'0px'});
|
||||
}
|
||||
|
||||
var $content = this.$('.orderlines');
|
||||
this.currentOrderLines.each(_.bind( function(orderLine) {
|
||||
var line = new module.OrderlineWidget(this, {
|
||||
|
@ -198,12 +204,19 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
if( at_bottom ){
|
||||
this.scrollbar.set_position(Number.MAX_VALUE, false);
|
||||
}
|
||||
|
||||
},
|
||||
update_summary: function(){
|
||||
var order = this.pos.get('selectedOrder');
|
||||
var total = order ? order.getTotal() : 0;
|
||||
this.$('.summary .value.total').html(this.format_currency(total));
|
||||
},
|
||||
set_compact: function(compact){
|
||||
if(this.compact !== compact){
|
||||
this.compact = compact;
|
||||
this.renderElement();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
module.ProductWidget = module.PosBaseWidget.extend({
|
||||
|
@ -563,7 +576,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
if(this.mode === 'cashier'){
|
||||
user = this.pos.get('cashier') || this.pos.get('user');
|
||||
}else{
|
||||
user = this.pos.get('client') || this.pos.get('user');
|
||||
user = this.pos.get('selectedOrder').get_client() || this.pos.get('user');
|
||||
}
|
||||
if(user){
|
||||
return user.name;
|
||||
|
@ -757,6 +770,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
default_cashier_screen: 'products',
|
||||
default_mode: this.pos.use_selfcheckout ? 'client' : 'cashier',
|
||||
});
|
||||
|
||||
this.screen_selector.set_default_screen();
|
||||
|
||||
this.pos.barcode_reader.connect();
|
||||
|
@ -769,19 +783,23 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
if (!scannedProductModel){
|
||||
return false;
|
||||
} else {
|
||||
selectedOrder.addProduct(new module.Product(scannedProductModel));
|
||||
if(parsed_ean.type === 'price'){
|
||||
selectedOrder.addProduct(new module.Product(scannedProductModel), { price:parsed_ean.value});
|
||||
}else if(parsed_ean.type === 'weight'){
|
||||
selectedOrder.addProduct(new module.Product(scannedProductModel), { quantity:parsed_ean.value, merge:false});
|
||||
}else{
|
||||
selectedOrder.addProduct(new module.Product(scannedProductModel));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
// returns a product that has a packaging with an EAN matching to provided parsed ean .
|
||||
// returns undefined if no such product is found.
|
||||
get_product_by_ean: function(parsed_ean) {
|
||||
var allProducts = this.pos.get('product_list');
|
||||
var allPackages = this.pos.get('product.packaging');
|
||||
var scannedProductModel = undefined;
|
||||
|
||||
if (parsed_ean.type === 'price') {
|
||||
if (parsed_ean.type === 'price' || parsed_ean.type === 'weight') {
|
||||
var itemCode = parsed_ean.id;
|
||||
var scannedPackaging = _.detect(allPackages, function(pack) {
|
||||
return pack.ean && pack.ean.substring(0,7) === itemCode;
|
||||
|
@ -791,24 +809,6 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
}else{
|
||||
scannedProductModel = _.detect(allProducts, function(pc) { return pc.ean13 && (pc.ean13.substring(0,7) === parsed_ean.id);});
|
||||
}
|
||||
if(scannedProductModel){
|
||||
scannedProductModel.list_price = parsed_ean.value;
|
||||
}
|
||||
} else if (parsed_ean.type === 'weight') {
|
||||
var weight = parsed_ean.value;
|
||||
var itemCode = parsed_ean.id;
|
||||
var scannedPackaging = _.detect(allPackages, function(pack) {
|
||||
return pack.ean && pack.ean.substring(0,7) === itemCode;
|
||||
});
|
||||
if (scannedPackaging){
|
||||
scannedProductModel = _.detect(allProducts, function(pc) { return pc.id === scannedPackaging.product_id[0];});
|
||||
}else{
|
||||
scannedProductModel = _.detect(allProducts, function(pc) { return pc.ean13 && (pc.ean13.substring(0,7) === parsed_ean.id);});
|
||||
}
|
||||
if(scannedProductModel){
|
||||
scannedProductModel.list_price *= weight;
|
||||
scannedProductModel.name += ' - ' + weight + ' Kg.';
|
||||
}
|
||||
} else if(parsed_ean.type === 'unit'){
|
||||
scannedProductModel = _.detect(allProducts, function(pc) { return pc.ean13 === parsed_ean.ean;}); //TODO DOES NOT SCALE
|
||||
}
|
||||
|
@ -827,22 +827,22 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
},
|
||||
// shows or hide the numpad and related controls like the paypad.
|
||||
set_numpad_visible: function(visible){
|
||||
if(visible != this.numpad_visible){
|
||||
if(visible !== this.numpad_visible){
|
||||
this.numpad_visible = visible;
|
||||
if(visible){
|
||||
this.numpad.show();
|
||||
this.paypad.show();
|
||||
$('.point-of-sale .order-container').css({'bottom':'232px'});
|
||||
this.order_widget.set_compact(true);
|
||||
}else{
|
||||
this.numpad.hide();
|
||||
this.paypad.hide();
|
||||
$('.point-of-sale .order-container').css({'bottom':'0px'});
|
||||
this.order_widget.set_compact(false);
|
||||
}
|
||||
}
|
||||
},
|
||||
//shows or hide the leftpane (contains the list of orderlines, the numpad, the paypad, etc.)
|
||||
set_leftpane_visible: function(visible){
|
||||
if(visible != this.leftpane_visible){
|
||||
if(visible !== this.leftpane_visible){
|
||||
this.leftpane_visible = visible;
|
||||
if(visible){
|
||||
$('#leftpane').show().animate({'width':this.leftpane_width},500,'swing');
|
||||
|
@ -856,7 +856,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
},
|
||||
//shows or hide the controls in the PosWidget that are specific to the cashier ( Orders, close button, etc. )
|
||||
set_cashier_controls_visible: function(visible){
|
||||
if(visible != this.cashier_controls_visible){
|
||||
if(visible !== this.cashier_controls_visible){
|
||||
this.cashier_controls_visible = visible;
|
||||
if(visible){
|
||||
$('#loggedas').show();
|
||||
|
|
Loading…
Reference in New Issue