Rodney Elpidio Enciso Arias vor 6 Jahren
Commit
1b4af02a4f
7 geänderte Dateien mit 282 neuen und 0 gelöschten Zeilen
  1. 1 0
      __init__.py
  2. BIN
      __init__.pyc
  3. 22 0
      __openerp__.py
  4. 3 0
      static/src/css/custom.css
  5. 94 0
      static/src/js/screen.js
  6. 152 0
      static/src/xml/pos_receipt.xml
  7. 10 0
      template.xml

+ 1 - 0
__init__.py

@@ -0,0 +1 @@
+# -*- coding: utf-8 -*-

BIN
__init__.pyc


+ 22 - 0
__openerp__.py

@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+{
+    'name': "Eiru - Bill and Kitchen Ticket",
+    'summary': """This module print POS receipt and kitchen ticket.""",
+    'author': "Eiru",
+    'website': "http://www.eiru.com.py",
+    'category': 'Point of Sale',
+    'version': '0.1',
+    'depends': [
+                'base',
+                'point_of_sale',
+                ],
+    'data': [
+        "template.xml",
+    ],
+    'qweb': [
+        'static/src/xml/pos_receipt.xml',
+    ],
+    'license': 'AGPL-3',
+    'installable': True,
+    'auto_install': False,
+}

+ 3 - 0
static/src/css/custom.css

@@ -0,0 +1,3 @@
+/*@media print {
+    footer {page-break-after: always;}
+}*/

+ 94 - 0
static/src/js/screen.js

@@ -0,0 +1,94 @@
+openerp.eiru_ticket_bill_kitchen = function (instance) {
+    var module   = instance.point_of_sale;
+    var _t = instance.web._t,
+        _lt = instance.web._lt;
+    var QWeb = instance.web.qweb;
+
+
+    module.ReceiptScreenWidget = module.ScreenWidget.extend({
+        template: 'ReceiptScreenWidget',
+
+        show_numpad:     false,
+        show_leftpane:   false,
+
+        show: function(){
+            this._super();
+            var self = this;
+
+            var print_button = this.add_action_button({
+                    label: _t('Print'),
+                    icon: '/point_of_sale/static/src/img/icons/png48/printer.png',
+                    click: function(){ self.print(); },
+                });
+
+            var finish_button = this.add_action_button({
+                    label: _t('Next Order'),
+                    icon: '/point_of_sale/static/src/img/icons/png48/go-next.png',
+                    click: function() { self.finishOrder(); },
+                });
+
+            this.refresh();
+
+            if (!this.pos.get('selectedOrder')._printed) {
+                this.print();
+            }
+
+            //
+            // The problem is that in chrome the print() is asynchronous and doesn't
+            // execute until all rpc are finished. So it conflicts with the rpc used
+            // to send the orders to the backend, and the user is able to go to the next
+            // screen before the printing dialog is opened. The problem is that what's
+            // printed is whatever is in the page when the dialog is opened and not when it's called,
+            // and so you end up printing the product list instead of the receipt...
+            //
+            // Fixing this would need a re-architecturing
+            // of the code to postpone sending of orders after printing.
+            //
+            // But since the print dialog also blocks the other asynchronous calls, the
+            // button enabling in the setTimeout() is blocked until the printing dialog is
+            // closed. But the timeout has to be big enough or else it doesn't work
+            // 2 seconds is the same as the default timeout for sending orders and so the dialog
+            // should have appeared before the timeout... so yeah that's not ultra reliable.
+
+            finish_button.set_disabled(true);
+            setTimeout(function(){
+                finish_button.set_disabled(false);
+            }, 2000);
+        },
+        print: function() {
+            this.pos.get('selectedOrder')._printed = true;
+            window.print();
+        },
+        finishOrder: function() {
+            this.pos.get('selectedOrder').destroy();
+        },
+        refresh: function() {
+            var data = [];
+            var order = this.pos.get('selectedOrder');
+            var categories = this.pos.printers[0].config.product_categories_ids;
+            var orderlines = order.get('orderLines').models;
+            _.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_description: item.product.description,
+                            product_qty: ' --> ' + item.quantity,
+                        })
+                    }
+                }
+            });
+            $('.pos-receipt-container', this.$el).html(QWeb.render('PosTicket',{
+                widget:this,
+                order: order,
+                orderlines: order.get('orderLines').models,
+                paymentlines: order.get('paymentLines').models,
+                kitchenlines: data, 
+            }));
+        },
+        close: function(){
+            this._super();
+        }
+    });
+}

+ 152 - 0
static/src/xml/pos_receipt.xml

@@ -0,0 +1,152 @@
+<templates>
+    <t t-extend="PosTicket">
+        <t t-jquery="div.pos-sale-ticket" t-operation="replace">
+            <div class="pos-sale-ticket" style='font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;font-size: 15px;'>
+
+                <div class="pos-center-align"><t t-esc="new Date().toString(Date.CultureInfo.formatPatterns.shortDate + ' ' +
+                    Date.CultureInfo.formatPatterns.longTime)"/> 
+                    <br/>
+                    <t t-esc="order.get('name')"/>
+                </div>
+                <br/>
+                <t t-if="widget.pos.config.receipt_header">
+                    <div style='text-align:center;font-size: 20px;'>
+                        <t t-esc="widget.pos.config.receipt_header" />
+                    </div>
+                    <br />
+                </t>
+                Vendedor: <t t-esc="widget.pos.cashier ? widget.pos.cashier.name : widget.pos.user.name"/>
+                <t t-if="order.attributes.client">
+                    <br/>
+                    Cliente: <t t-esc="order.attributes.client.name ? order.attributes.client.name : ''"/><br/>
+                    Teléfono: <t t-esc="order.attributes.client.phone ? order.attributes.client.phone : ''"/><br/><br/>
+                </t>
+                <table class="table table-condensed">
+                    <thead>
+                        <tr>
+                            <th>Producto</th>
+                            <th class="text-right">Cant.</th>
+                            <th class="text-right">Precio</th>
+                        </tr>
+                    </thead>
+                    <tbody>
+                        <colgroup>
+                            <col width='50%'/>
+                            <col width='20%'/>
+                            <col width='30%'/>
+                        </colgroup>
+                        <tr t-foreach="orderlines" t-as="orderline">
+                            <td>
+                                <t t-esc="orderline.get_product().display_name"/>
+                                <t t-if="orderline.get_discount() > 0">
+                                    <div class="pos-disc-font">
+                                        Con <t t-esc="orderline.get_discount()"/>% descuento
+                                    </div>
+                                </t>
+                            </td>
+                            <td>
+                                <t t-esc="orderline.get_quantity_str_with_unit()"/>
+                            </td>
+                            <td class="pos-right-align">
+                                <t t-esc="widget.format_currency(orderline.get_display_price())"/>
+                            </td>
+                        </tr>
+                    </tbody>
+                </table>
+                <br />
+                <table>
+                    <tr>
+                        <td>Subtotal:</td>
+                        <td class="pos-right-align">
+                            <t t-esc="widget.format_currency(order.getTotalTaxExcluded())"/>
+                        </td>
+                    </tr>
+                    <t t-foreach="order.getTaxDetails()" t-as="taxdetail">
+                        <tr>
+                            <td><t t-esc="taxdetail.name" /></td>
+                            <td class="pos-right-align">
+                                <t t-esc="widget.format_currency(taxdetail.amount)"/>
+                            </td>
+                        </tr>
+                    </t>
+                    <tr>
+                        <td>Descuento:</td>
+                        <td class="pos-right-align">
+                            <t t-esc="widget.format_currency(order.getDiscountTotal())"/>
+                        </td>
+                    </tr>
+                    <tr class="emph">
+                        <td>Total:</td>
+                        <td class="pos-right-align" style='font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;font-size: 20px;'>
+                            <t t-esc="widget.format_currency(order.getTotalTaxIncluded())"/>
+                        </td>
+                    </tr>
+                </table>
+                <br/>
+                <table>
+                    <tr t-foreach="paymentlines" t-as="line">
+                        <td>
+                            <t t-esc="line.name"/>
+                        </td>
+                        <td class="pos-right-align">
+                            <t t-esc="widget.format_currency(line.get_amount())"/>
+                        </td>
+                    </tr>
+                </table>
+                <table>
+                    <tr><td>Change:</td><td class="pos-right-align">
+                        <t t-esc="widget.format_currency(order.getChange())"/>
+                        </td></tr>
+                </table>
+                <t t-if="widget.pos.config.receipt_footer">
+                    <br />
+                    <div style='text-align:center'>
+                        <t t-esc="widget.pos.config.receipt_footer" />
+                    </div>
+                </t>
+            </div>
+            <p></p>
+            
+            <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 class="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-esc="orderlines[0].order.uid"/>
+                                    <t t-="kitchenline.product_description !== false">
+                                        <t t-foreach="kitchenline.product_description" t-as="item">
+                                            <t t-if="orderlines[0].order.uid == item.order">
+                                                <ul>
+                                                    <li><t t-esc="item.product_name"/></li>
+                                                </ul>   
+                                            </t>
+                                        </t>    
+                                    </t>
+                                </td>
+                                <td>
+                                    <t t-esc="kitchenline.product_qty"/>
+                                </td>
+                            </tr>
+                            <tr>
+                                <td>-------------------------------------</td>
+                                <td></td>
+                            </tr>
+                        </t>
+                    </tbody>
+                </table>
+            </div>
+        </t>
+    </t>
+</templates>

+ 10 - 0
template.xml

@@ -0,0 +1,10 @@
+<openerp>
+    <data>
+        <template id="pos_ticket_bill_kitchen_assets_backend" name="pos_ticket_bill_kitchen_assets_backend" inherit_id="point_of_sale.assets_backend">
+            <xpath expr="." position="inside">
+                <script src="/eiru_ticket_bill_kitchen/static/src/js/screen.js"
+                        type="text/javascript"></script>
+            </xpath>
+        </template> 
+    </data>
+</openerp>