From 78fc2ef84b01afae7e2c91fed41d6567287ff10e Mon Sep 17 00:00:00 2001 From: Frederic van der Essen Date: Wed, 8 Oct 2014 00:18:19 +0200 Subject: [PATCH] [IMP] point_of_sale: ability to change the current cashier with the GUI --- addons/point_of_sale/static/src/css/pos.css | 25 +++++++++--- addons/point_of_sale/static/src/js/screens.js | 2 +- addons/point_of_sale/static/src/js/widgets.js | 40 ++++++++++++++----- addons/point_of_sale/static/src/xml/pos.xml | 4 +- 4 files changed, 52 insertions(+), 19 deletions(-) diff --git a/addons/point_of_sale/static/src/css/pos.css b/addons/point_of_sale/static/src/css/pos.css index 455b6dd609e..e54b584ce43 100644 --- a/addons/point_of_sale/static/src/css/pos.css +++ b/addons/point_of_sale/static/src/css/pos.css @@ -1884,6 +1884,7 @@ td { height: 40px; line-height:40px; text-align:center; + border-radius: 2px; margin:3px; margin-top:10px; margin-right:10px; @@ -1933,15 +1934,27 @@ td { box-sizing: border-box; width: 80%; } +.pos .popup.popup-selection .message { + margin-top: 0; +} .pos .popup.popup-selection .selection { overflow-y: auto; - max-height: 270px; -} -.pos .popup.popup-selection .selection .button { - float: none; - display: block; + max-height: 305px; + font-size: 16px; + margin: 0 -10px; width: auto; - margin: 8px; + line-height: 50px; + border-top: dashed 1px rgb(215,215,215); +} +.pos .popup.popup-selection .selection-item { + width: auto; + background: rgb(230,230,230); + cursor: pointer; + text-align: left; + padding: 0px 16px; +} +.pos .popup.popup-selection .selection-item:nth-child(even) { + background: rgb(247,247,247); } /* ********* The Webkit Scrollbar ********* */ diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index 831bdf3b9e3..713f5208c1a 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -417,7 +417,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa } }); - this.$('.button.item').click(function(){ + this.$('.selection-item').click(function(){ self.pos_widget.screen_selector.close_popup(); if (options.confirm) { var item = self.list[parseInt($(this).data('item-index'))]; diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js index ae469060b3a..074aa16dd80 100644 --- a/addons/point_of_sale/static/src/js/widgets.js +++ b/addons/point_of_sale/static/src/js/widgets.js @@ -577,22 +577,42 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa init: function(parent, options){ var options = options || {}; this._super(parent,options); - this.mode = options.mode || 'cashier'; }, set_user_mode: function(mode){ this.mode = mode; - this.refresh(); - }, - refresh: function(){ this.renderElement(); }, - get_name: function(){ - var user; - if(this.mode === 'cashier'){ - user = this.pos.cashier || this.pos.user; - }else{ - user = this.pos.get_order().get_client() || this.pos.user; + renderElement: function(){ + var self = this; + this._super(); + + this.$el.click(function(){ + self.click_username(); + }); + }, + click_username: function(){ + var self = this; + + var list = []; + for (var i = 0; i < this.pos.users.length; i++) { + list.push({ + 'label':this.pos.users[i].name, + 'item': this.pos.users[i], + }); } + + this.pos_widget.screen_selector.show_popup('selection',{ + 'message': _t('Change Cashier'), + list: list, + confirm: function(cashier){ + this.pos.cashier = cashier; + self.renderElement(); + }, + }); + + }, + get_name: function(){ + var user = this.pos.cashier || this.pos.user; if(user){ return user.name; }else{ diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index 146b8a1a9ae..3ea598ea983 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -1013,9 +1013,9 @@