浏览代码

[ADD] agregado boton para levantar modal y filtro de pack dependiendo del producto elegido

Rodney Elpidio Enciso Arias 6 年之前
父节点
当前提交
dc33496614
共有 2 个文件被更改,包括 51 次插入22 次删除
  1. 37 19
      static/src/js/widget.js
  2. 14 3
      static/src/xml/view.xml

+ 37 - 19
static/src/js/widget.js

@@ -10,22 +10,25 @@ function pos_customize_product_pack_widget(instance, module){
             this.pack_popup.appendTo(this.$el);
             this.pack_popup.hide();
             this.screen_selector.popup_set['PackList'] = this.pack_popup;
-        }
-    });
-
-    module.ClientListScreenWidget.include({
-        show: function(){
-            var self = this;        
-            this._super();
             
-            this.$('.select-table').click(function(){
-                self.pos_widget.screen_selector.show_popup('PackList');
-                $('#floor-cancel').click(function(){
-                    self.pos_widget.screen_selector.set_current_screen('clientlist');
-                });
-            });                
+            var kitchen_ticket_button = $(QWeb.render('PackModalButton'));
+            kitchen_ticket_button.appendTo(this.$('.control-buttons'));
+            this.$('.control-buttons').removeClass('oe_hidden');
+
+            this.$('.order-pack-modal').click(function(){
+                var check = self.pos.get('selectedOrder').selected_orderline;
+                if(check != undefined){
+                    if(check.product.pack_line_ids.length > 0){
+                        self.pos_widget.screen_selector.show_popup('PackList');
+                        $('#floor-cancel').click(function(){
+                            self.pos_widget.screen_selector.set_current_screen('products');
+                        });
+                    }
+                }
+
+            });
         }
-    });  
+    });
     
     module.PackPopUp = module.PopUpWidget.extend({
         template:'PackPopupWidget',
@@ -38,8 +41,8 @@ function pos_customize_product_pack_widget(instance, module){
 
         show: function(){
             this._super();
-            var self = this; 
-            this.floor_list_widget.replace($('.placeholder-PackListScreenWidget'));       
+            var self = this;
+            this.floor_list_widget.replace($('.placeholder-PackListScreenWidget'));           
         },
 
     }); 
@@ -59,17 +62,32 @@ function pos_customize_product_pack_widget(instance, module){
         renderElement: function() {
             this._super();
             var self = this;
+            
+            var product = self.pos.get('selectedOrder').selected_orderline.product;
+            
+            var product_pack = product.pack_line_ids;
+
             var pack_lines = this.pos.product_pack_lines || [];
-            for(var i = 0; i < pack_lines.length;  i++ ){
+
+            for(var i = 0; i < product_pack.length;  i++ ){
+
+                var product = _.filter(pack_lines,function (inv) {
+                    return inv.id === product_pack[i];
+                });
+
                 var data = [];
+                
                 data.push({
-                    id:pack_lines[i].id,
-                    name:pack_lines[i].product_id[1],
+                    id: product[0].id,
+                    name: product[0].product_id[1],
                 });
+                
                 data = data.shift();
+
                 var product = new module.PackListWidget(this, {
                     model_floor: data,
                 });
+                
                 product.appendTo(this.$('.product_list'));
             }
         },

+ 14 - 3
static/src/xml/view.xml

@@ -1,13 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <templates id="template" xml:space="preserve">
 
-    <t t-extend="ClientListScreenWidget">
+    <!-- <t t-extend="ClientListScreenWidget">
         <t t-jquery="span.new-customer" t-operation="after">
             <span class="button select-table">
                 Elegir
             </span>
         </t>
-    </t>
+    </t> -->
 
     <t t-name="PackPopupWidget">
         <div class="modal-dialog custom-dialog">
@@ -40,5 +40,16 @@
                 <t t-esc="widget.model_floor.name"/>
             </button>
         </span>
-    </t>  
+    </t> 
+
+
+    <!-- Prueba -->
+    
+    <t t-name="PackModalButton">
+        <span class="control-button order-pack-modal">
+            <i class="fa fa-print"></i>
+            Quitar Ingrediente
+        </span>
+    </t>
+
 </templates>