Browse Source

Agregar pack line.

sebas 4 years ago
parent
commit
8fd81a1679
2 changed files with 63 additions and 3 deletions
  1. 24 0
      static/src/js/main.js
  2. 39 3
      static/src/xml/pos.xml

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

@@ -40,7 +40,10 @@ openerp.eiru_kitchen_ticket = function (instance) {
             var resume = {};
             var order = this.pos.get('selectedOrder');
             order.get('orderLines').each(function(item){
+
+
                 var line = item.export_as_JSON();
+
                 if( typeof resume[line.product_id] === 'undefined'){
                     resume[line.product_id] = line.qty;
                 }else{
@@ -64,6 +67,7 @@ openerp.eiru_kitchen_ticket = function (instance) {
                         'id': product,
                         'name': this.pos.db.get_product_by_id(product).display_name,
                         'price': this.pos.db.get_product_by_id(product).price,
+                        // 'product_pack_lines': this.pos.db.get_product_by_id(product).pack_lines,
                         'quantity': current[product],
                     });
                 }else if( old[product] < current[product]){
@@ -71,6 +75,7 @@ openerp.eiru_kitchen_ticket = function (instance) {
                         'id': product,
                         'name': this.pos.db.get_product_by_id(product).display_name,
                         'price': this.pos.db.get_product_by_id(product).price,
+                        // 'product_pack_lines': this.pos.db.get_product_by_id(product).pack_lines,
                         'quantity': current[product] - old[product],
                     });
                 }else if( old[product] > current[product]){
@@ -78,6 +83,7 @@ openerp.eiru_kitchen_ticket = function (instance) {
                         'id': product,
                         'name': this.pos.db.get_product_by_id(product).display_name,
                         'price': this.pos.db.get_product_by_id(product).price,
+                        // 'product_pack_lines': this.pos.db.get_product_by_id(product).pack_lines,
                         'quantity': old[product] - current[product],
                     });
                 }
@@ -89,6 +95,7 @@ openerp.eiru_kitchen_ticket = function (instance) {
                         'id': product,
                         'name': this.pos.db.get_product_by_id(product).display_name,
                         'price': this.pos.db.get_product_by_id(product).price,
+                        // 'product_pack_lines': this.pos.db.get_product_by_id(product).pack_lines,
                         'quantity': old[product],
                     });
                 }
@@ -147,6 +154,22 @@ openerp.eiru_kitchen_ticket = function (instance) {
         refresh: function() {
             var self = this;
             var order = self.pos.get('selectedOrder');
+            var categories = this.pos.printers[0].config.product_categories_ids;
+            var orderlines = order.get('orderLines').models;
+            var data = [];
+            _.each(orderlines, function(item){
+                 for (var i = 0; i < categories.length; i++) {
+                     if(item.product.pos_categ_id[0] == categories[i]){
+                         data.push({
+                             product_id: item.product.id,
+                             product_name: item.product.display_name,
+                             product_pack_lines: item.pack_lines,
+                             product_qty: ' --> ' + item.quantity,
+                             line_id: item.id,
+                         })
+                     }
+                  }
+             });
             var place = order.export_as_JSON().table;
             var floor = ' ';
             var table = ' ';
@@ -162,6 +185,7 @@ openerp.eiru_kitchen_ticket = function (instance) {
                 filterLines: change.new,
                 floor: floor,
                 table: table,
+                kitchenlines: data,
             }));
         },
     });

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

@@ -77,10 +77,8 @@
 
                 </tbody>
             </table>
+              <p>--------------------------------------------</p>
             <table>
-              <tr>
-                  <td><p>---------------------------------</p></td>
-              </tr>
                 <tr class="emph">
                     <br />
                     <td>Total:</td>
@@ -90,6 +88,44 @@
                 </tr>
             </table>
 
+            <br/>
+            <t t-if="kitchenlines.length > 0">
+                <div class="pos-sale-ticket" style='font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;font-size: 15px;'>
+
+                    <!-- <p style="page-break-after: always;"></p> -->
+                    <!-- <div style='text-align:center'>
+                        <h3>Cocina</h3>
+                    </div> -->
+
+                    <table>
+                        <tbody>
+                            <colgroup>
+                                <col width='80%'/>
+                                <col width='20%'/>
+                            </colgroup>
+                            <t t-foreach="kitchenlines" t-as="kitchenline">
+                                <tr>
+                                    <td>
+                                        <t t-esc="kitchenline.product_name"/>
+                                        <t t-foreach="kitchenline.product_pack_lines" t-as="item">
+                                            <ul>
+                                                <li><t t-esc="item.product_name"/></li>
+                                            </ul>
+                                        </t>
+                                    </td>
+                                    <!-- <td>
+                                        <t t-esc="kitchenline.product_qty"/>
+                                    </td> -->
+                                </tr>
+                                <tr>
+                                    <td>-----------------------------------</td>
+                                    <td></td>
+                                </tr>
+                            </t>
+                        </tbody>
+                    </table>
+                </div>
+            </t>
 
             <br/>
             <t t-if="widget.pos.config.receipt_footer">