소스 검색

[FIX] modificaciones en el logo y en la forma de impresion

Rodney Elpidio Enciso Arias 6 년 전
부모
커밋
9fc3ef9fbf
6개의 변경된 파일71개의 추가작업 그리고 115개의 파일을 삭제
  1. 1 24
      __init__.py
  2. BIN
      __init__.pyc
  3. 4 24
      __openerp__.py
  4. 55 66
      static/src/js/main.js
  5. 1 1
      static/src/xml/pos.xml
  6. 10 0
      template.xml

+ 1 - 24
__init__.py

@@ -1,24 +1 @@
-# -*- coding: utf-8 -*-
-# Python source code encoding : https://www.python.org/dev/peps/pep-0263/
-##############################################################################
-#
-#    OpenERP, Open Source Management Solution
-#    This module copyright :
-#        (c) 2014 Antiun Ingenieria, SL (Madrid, Spain, http://www.antiun.com)
-#                 Endika Iglesias <endikaig@antiun.com>
-#                 Antonio Espinosa <antonioea@antiun.com>
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU Affero General Public License as
-#    published by the Free Software Foundation, either version 3 of the
-#    License, or (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU Affero General Public License for more details.
-#
-#    You should have received a copy of the GNU Affero General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
+# -*- coding: utf-8 -*-

BIN
__init__.pyc


+ 4 - 24
__openerp__.py

@@ -1,27 +1,4 @@
 # -*- coding: utf-8 -*-
-# Python source code encoding : https://www.python.org/dev/peps/pep-0263/
-##############################################################################
-#
-#    OpenERP, Open Source Management Solution
-#    This module copyright :
-#        (c) 2014 Antiun Ingenieria, SL (Madrid, Spain, http://www.antiun.com)
-#                 Endika Iglesias <endikaig@antiun.com>
-#                 Antonio Espinosa <antonioea@antiun.com>
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU Affero General Public License as
-#    published by the Free Software Foundation, either version 3 of the
-#    License, or (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU Affero General Public License for more details.
-#
-#    You should have received a copy of the GNU Affero General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
 {
     'name': 'Pos ticket ferresur',
     'category': 'Point Of Sale',
@@ -29,10 +6,13 @@
     'depends': [
         'point_of_sale',
     ],
+    'data': [
+        "template.xml",
+    ],
     'qweb': [
         'static/src/xml/pos.xml',
     ],
-    'author': 'Antiun Ingeniería S.L. - Eiru',
+    'author': 'Eiru',
     'website': 'https://www.eiru.com.py',
     'license': 'AGPL-3',
     'installable': True,

+ 55 - 66
static/src/js/main.js

@@ -1,73 +1,62 @@
-/**
- * # -*- coding: utf-8 -*-
- * ##############################################################################
- * #
- * #    OpenERP, Open Source Management Solution
- * #    This module copyright :
- * #        (c) 2014 Antiun Ingenieria, SL (Madrid, Spain, http://www.antiun.com)
- * #                 Endika Iglesias <endikaig@antiun.com>
- * #                 Antonio Espinosa <antonioea@antiun.com>
- * #
- * #    This program is free software: you can redistribute it and/or modify
- * #    it under the terms of the GNU Affero General Public License as
- * #    published by the Free Software Foundation, either version 3 of the
- * #    License, or (at your option) any later version.
- * #
- * #    This program is distributed in the hope that it will be useful,
- * #    but WITHOUT ANY WARRANTY; without even the implied warranty of
- * #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * #    GNU Affero General Public License for more details.
- * #
- * #    You should have received a copy of the GNU Affero General Public License
- * #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
- * #
- * ##############################################################################
- */
 
-// Check jQuery available
-if (typeof jQuery === 'undefined') { throw new Error('POS Ticket Logo Addon requires jQuery'); }
+openerp.pos_ticket_ferresur = function (instance) {
+	var module   = instance.point_of_sale;
+    var _t = instance.web._t,
+        _lt = instance.web._lt;
+    var QWeb = instance.web.qweb;
 
-+function ($) {
-    'use strict';
+    module.ReceiptScreenWidget = module.ScreenWidget.extend({
+        template: 'ReceiptScreenWidget',
 
-    openerp.pos_ticket_logo = function (instance, module) {
-        var _t = instance.web._t,
-            _lt = instance.web._lt;
-        var QWeb = instance.web.qweb;
+        show_numpad:     false,
+        show_leftpane:   false,
 
-        var PosModelParent = instance.point_of_sale.PosModel;
-        instance.point_of_sale.PosModel = instance.point_of_sale.PosModel.extend({
-            load_server_data: function(){
-                var self = this;
-                var loaded = PosModelParent.prototype.load_server_data.apply(this, arguments);
-                $.when(loaded).then(function(){
-                    self.company_logo.onload = function(){
-                        var img = self.company_logo;
-                        var ratio = 1;
-                        var targetwidth = 260;
-                        var maxheight = 120;
-                        if( img.width !== targetwidth ){
-                            ratio = targetwidth / img.width;
-                        }
-                        if( img.height * ratio > maxheight ){
-                            ratio = maxheight / img.height;
-                        }
-                        var width  = Math.floor(img.width * ratio);
-                        var height = Math.floor(img.height * ratio);
-                        var c = document.createElement('canvas');
-                            c.width  = width;
-                            c.height = height;
-                        var ctx = c.getContext('2d');
-                            ctx.drawImage(self.company_logo,0,0, width, height);
+        show: function(){
+            this._super();
+            var self = this;
 
-                        self.company_logo_base64 = c.toDataURL();
-                        loaded.resolve();
-                    };
-                    self.company_logo.src = '/web/binary/image?model=res.company&id=' + self.company.id + '&field=logo';
+            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(); },
                 });
-                return loaded;
-            }
-        });
-    };
 
-}(jQuery);
+            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();
+            // }
+
+            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 order = this.pos.get('selectedOrder');            
+            $('.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
+                }));
+        },
+        close: function(){
+            this._super();
+        }
+    });
+};

+ 1 - 1
static/src/xml/pos.xml

@@ -5,7 +5,7 @@
             <div class="pos-sale-ticket" style='font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;font-size: 15px;'>
 
             <div class="pos-center-align">
-                <img t-att-src="widget.pos.company_logo_base64"/><br />
+                <div id="company_logo" style="text-align:center;"><img t-att-src="logo"/></div>
             </div>
             <br/><br/>
             <div class="pos-center-align"><t t-esc="new Date().toString(Date.CultureInfo.formatPatterns.shortDate + ' ' +

+ 10 - 0
template.xml

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