[IMP] point_of_sale: ability to change the current cashier with the GUI
authorFrederic van der Essen <fva@openerp.com / fvdessen+o@gmail.com>
Tue, 7 Oct 2014 22:18:19 +0000 (00:18 +0200)
committerFrédéric van der Essen <fvdessen@gmail.com>
Wed, 26 Nov 2014 11:06:24 +0000 (12:06 +0100)
addons/point_of_sale/static/src/css/pos.css
addons/point_of_sale/static/src/js/screens.js
addons/point_of_sale/static/src/js/widgets.js
addons/point_of_sale/static/src/xml/pos.xml

index 455b6dd..e54b584 100644 (file)
@@ -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;
+    max-height: 305px;
+    font-size: 16px;
+    margin: 0 -10px;
+    width: auto;
+    line-height: 50px;
+    border-top: dashed 1px rgb(215,215,215);
 }
-.pos .popup.popup-selection .selection .button {
-    float: none;
-    display: block;
+.pos .popup.popup-selection .selection-item {
     width: auto;
-    margin: 8px;
+    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  ********* */
index 831bdf3..713f520 100644 (file)
@@ -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'))];
index ae46906..074aa16 100644 (file)
@@ -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{
index 146b8a1..3ea598e 100644 (file)
         <div class="modal-dialog">
             <div class="popup popup-selection">
                 <p class="message"><t t-esc=" widget.message || 'Confirm ?' " /></p>
-                <div class='selection'>
+                <div class='selection scrollable-y touch-scrollable'>
                     <t t-foreach="widget.list || []" t-as="item">
-                        <div class='button item' t-att-data-item-index='item_index'>
+                        <div class='selection-item' t-att-data-item-index='item_index'>
                             <t t-esc='item.label'/>
                         </div>
                     </t>