Browse Source

[FIX] ajustes varios

Rodney Elpidio Enciso Arias 6 years ago
parent
commit
b91fe0d327
5 changed files with 19 additions and 5 deletions
  1. 1 0
      static/src/js/main.js
  2. 11 3
      static/src/js/model.js
  3. 3 2
      static/src/js/screen.js
  4. 3 0
      static/src/xml/pos.xml
  5. 1 0
      template.xml

+ 1 - 0
static/src/js/main.js

@@ -2,6 +2,7 @@ openerp.pos_ticket_homepro = function(instance) {
     var module = instance.point_of_sale;
     pos_screens(instance, module);
     pos_customer(instance, module);
+    pos_ticket_model(instance, module);
 
     instance.web.client_actions.add('pos.ui', 'instance.point_of_sale.PosWidget');
 };

+ 11 - 3
static/src/js/model.js

@@ -45,17 +45,25 @@ function pos_ticket_model(instance, module){
         },
         refresh: function() {
             var order = this.pos.get('selectedOrder');
-            console.log(order);
+            var orderLines = order.get('orderLines').models;
+            // console.log(orderLines);
+            var qty =  _.reduce(_.map(orderLines,function(item){
+                return item.quantity;
+            }), function(memo, num){
+                return memo + num;
+            },0);
+            // console.log(total);
             $('.pos-receipt-container', this.$el).html(QWeb.render('PosTicket',{
                     widget:this,
                     order: order,
                     orderlines: order.get('orderLines').models,
                     paymentlines: order.get('paymentLines').models,
-                    logo: order.pos.company_logo_base64
+                    logo: order.pos.company_logo_base64,
+                    quantity: qty,
                 }));
         },
         close: function(){
             this._super();
         }
     });
-};
+}

+ 3 - 2
static/src/js/screen.js

@@ -80,8 +80,9 @@ function pos_screens(instance, module){ //module is instance.point_of_sale
             }
         },
         perform_search: function(query, associate_result){
+            var customers;
             if(query){
-                var customers = this.pos.db.search_partner(query);
+                customers = this.pos.db.search_partner(query);
                 this.display_client_details('hide');
                 if ( associate_result && customers.length === 1){
                     this.new_client = customers[0];
@@ -90,7 +91,7 @@ function pos_screens(instance, module){ //module is instance.point_of_sale
                 }
                 this.render_list(customers);
             }else{
-                var customers = this.pos.db.get_partners_sorted();
+                customers = this.pos.db.get_partners_sorted();
                 this.render_list(customers);
             }
         },

+ 3 - 0
static/src/xml/pos.xml

@@ -70,6 +70,9 @@
                         </t>
                     </tbody>
                 </table>
+                <p>========================</p>
+                <strong>Total de itenes: <t t-esc="quantity"/></strong>
+                <p>========================</p>
                 <table>
                     <tr>
                         <td>Subtotal:</td>

+ 1 - 0
template.xml

@@ -5,6 +5,7 @@
                 <script src="/pos_ticket_homepro/static/src/js/main.js" type="text/javascript"></script>
                 <script src="/pos_ticket_homepro/static/src/js/customer.js" type="text/javascript"></script>
                 <script src="/pos_ticket_homepro/static/src/js/screen.js" type="text/javascript"></script>
+                <script src="/pos_ticket_homepro/static/src/js/model.js" type="text/javascript"></script>
             </xpath>
         </template>
     </data>