|
@@ -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();
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|