Browse Source

Módulo para ticket en factura de ventas

SEBAS 2 ngày trước cách đây
commit
fafcc151d9

+ 3 - 0
__init__.py

@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+import controllers
+import models  # si tienes carpeta models; si no, borra esta línea

BIN
__init__.pyc


+ 13 - 0
__openerp__.py

@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+{
+    'name': 'Ticket Venta POS Print',
+    'version': '1.0',
+    'author': 'Tu Nombre',
+    'category': 'Accounting',
+    'depends': ['account', 'web'],
+    'data': [
+        'views/ticket_template.xml',
+        'views/invoice_button.xml',  # si existe
+    ],
+    'installable': True,
+}

+ 2 - 0
controllers/__init__.py

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

BIN
controllers/__init__.pyc


+ 11 - 0
controllers/main.py

@@ -0,0 +1,11 @@
+# -*- coding: utf-8 -*-
+from openerp import http
+from openerp.http import request
+
+class TicketVentaPOSPrint(http.Controller):
+    @http.route(['/ticket_venta/print/<int:invoice_id>'], type='http', auth='public')
+    def print_ticket(self, invoice_id, **kw):
+        invoice = request.env['account.invoice'].sudo().browse(invoice_id)
+        if not invoice.exists():
+            return request.not_found()
+        return request.render('ticket_venta_posprint.ticket_venta_template', {'doc': invoice})

BIN
controllers/main.pyc


+ 2 - 0
models/__init__.py

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

BIN
models/__init__.pyc


+ 20 - 0
models/account_invoice.py

@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+import logging
+from openerp.osv import orm
+
+_logger = logging.getLogger(__name__)
+
+class account_invoice(orm.Model):
+    _inherit = 'account.invoice'
+
+    def action_print_ticket_direct(self, cr, uid, ids, context=None):
+        _logger.info('ticket_venta_posprint: action_print_ticket_direct called ids=%s uid=%s', ids, uid)
+        if not ids:
+            return {}
+        invoice_id = ids[0]
+        url = '/ticket_venta/print/%s' % invoice_id
+        return {
+            'type': 'ir.actions.act_url',
+            'url': url,
+            'target': 'new',
+        }

BIN
models/account_invoice.pyc


BIN
static/description/icon.png


+ 52 - 0
static/description/index.html

@@ -0,0 +1,52 @@
+<head>
+  <style>
+      .backgrounds{background-color:#fff;color:#a41d35}
+  </style>
+</head>
+<section class="oe_container">
+ <div class="oe_row oe_spaced">
+  <h2 class="oe_slogan">
+   Add stock_kardex in menuitem
+  </h2>
+  <p class="oe_mt32">
+   This module add stock_kardex in menuitem
+  </p>
+ </div>
+</section>
+<section class="oe_container">
+    <div class="oe_row oe_spaced">
+        <div class="oe_span6">
+            <h2 class="oe_slogan">Do you need help?</h2>
+            <h3 class="oe_slogan">
+                Let's offer you the best services!
+            </h3>
+            <p class="oe_mt32 text-center">
+                Contact us by our official channels.
+            </p>
+            <div class="oe_spaced">
+                <ul class="text-center list-inline">
+                    <li>
+                        <a href="https://facebook.com/vauxoo" Target="_blank"><i class="fa fa-facebook-square fa-xs backgrounds"></i></a>
+                    </li>
+                    <li>
+                        <a href="https://twitter.com/vauxoo" Target="_blank" ><i class="fa fa-twitter-square fa-xs backgrounds"></i></a>
+                    </li>
+                    <li>
+                        <a href="https://www.linkedin.com/company/vauxoo" Target="_blank"><i class="fa fa-linkedin-square fa-xs backgrounds"></i></a>
+                    </li>
+                    <li>
+                        <a title="Contact us" data-toggle="tooltip" data-placement="left" Target="_blank" href="https://www.vauxoo.com/page/website.contactus"><i class="fa fa-envelope-square fa-xs backgrounds"></i></a>
+                    </li>
+                </ul>
+            </div>
+        </div>
+        <div class="oe_span6">
+            <div class="oe_demo oe_picture oe_screenshot">
+                <a href="https://www.vauxoo.com"  target="_blank"r>
+                    <img src="https://s3.amazonaws.com/s3.vauxoo.com/description_logo.png" width="200" height="auto">
+                </a>
+                <div class="oe_demo_footer oe_centeralign">Meet Us</div>
+            </div>
+        </div>
+    </div>
+</section>

+ 18 - 0
views/invoice_button.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+  <data>
+    <record id="view_invoice_form_ticket_posprint" model="ir.ui.view">
+      <field name="name">account.invoice.form.ticket.posprint</field>
+      <field name="model">account.invoice</field>
+      <field name="inherit_id" ref="account.invoice_form"/>
+      <field name="arch" type="xml">
+        <xpath expr="//field[@name='number']" position="after">
+          <button name="action_print_ticket_direct"
+                  type="object"
+                  string="Imprimir Ticket"
+                  class="oe_button"/>
+        </xpath>
+      </field>
+    </record>
+  </data>
+</openerp>

+ 86 - 0
views/ticket_template.xml

@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+  <data>
+    <template id="ticket_venta_template">
+      <!-- NOTA: no llamamos a web.assets_frontend porque en Odoo8 puede no existir -->
+      <t t-set="layout" t-value="None"/>
+      <html>
+        <head>
+          <meta charset="utf-8"/>
+          <title>Ticket</title>
+          <style type="text/css">
+            @page { size: 78mm auto; margin: 0; }
+            html, body { padding: 0; margin: 0; }
+            .page {
+              width: 78mm;
+              font-family: monospace;
+              font-size: 12px;
+              line-height: 1.2;
+              padding: 2mm 2mm;
+              box-sizing: border-box;
+            }
+            .center { text-align: center; }
+            .right { text-align: right; }
+            .divider { border-top: 1px dashed #000; margin: 3px 0; }
+            table { width: 100%; border-collapse: collapse; }
+            th, td { padding: 0; vertical-align: top; }
+            .qty { width: 18%; }
+            .desc { width: 52%; }
+            .tot { width: 30%; text-align: right; white-space: nowrap; }
+          </style>
+        </head>
+        <body>
+          <div class="page">
+            <div class="center">
+              <strong><t t-esc="doc.company_id and doc.company_id.name or ''"/></strong><br/>
+              <t t-esc="doc.company_id and (doc.company_id.actividad or '') or ''"/><br/>
+              <t t-esc="doc.company_id and (doc.company_id.street or '') or ''"/><br/>
+              <t t-esc="doc.company_id and (doc.company_id.street2 or '') or ''"/><br/>
+              <t t-if="doc.company_id and doc.company_id.phone">Tel: <t t-esc="doc.company_id.phone"/></t><br/>
+              -------------------------------
+            </div>
+
+            <div>
+              <strong>Factura:</strong> <t t-esc="doc.number or doc.name or ''"/><br/>
+              <strong>Cliente:</strong> <t t-esc="doc.partner_id and doc.partner_id.name or ''"/><br/>
+              <t t-if="doc.date_invoice"><strong>Fecha:</strong> <t t-esc="doc.date_invoice"/></t>
+              <div class="divider"></div>
+            </div>
+
+            <table>
+              <thead>
+                <tr>
+                  <th class="qty">Cant</th>
+                  <th class="desc">Descripción</th>
+                  <th class="tot">Total</th>
+                </tr>
+              </thead>
+              <tbody>
+                <tr t-foreach="doc.invoice_line" t-as="line">
+                  <td class="qty"><t t-esc="'{0:,.0f}'.format(line.quantity)"/></td>
+                  <td class="desc"><t t-esc="line.name"/></td>
+                  <td class="tot"><t t-esc="'{0:,.0f}'.format(line.quantity * line.price_unit)"/></td>
+                </tr>
+              </tbody>
+            </table>
+
+            <div class="divider"></div>
+
+            <div class="right">
+              <strong>Total:</strong> <t t-esc="'{0:,.0f}'.format(doc.amount_total)"/>
+            </div>
+
+            <div class="center" style="margin-top:6px;">¡Gracias por su compra!</div>
+          </div>
+
+          <script type="text/javascript">
+            window.onload = function() {
+              try { window.print(); } catch(e) {}
+              setTimeout(function(){ window.close(); }, 500);
+            };
+          </script>
+        </body>
+      </html>
+    </template>
+  </data>
+</openerp>