From 56c005b44135718b4479370581d849045e8ebfd3 Mon Sep 17 00:00:00 2001 From: Antonio Espinosa Date: Mon, 22 Jun 2015 16:20:14 +0200 Subject: [PATCH] [ADD] POS ticket logo addon --- pos_ticket_logo/README.rst | 50 ++++++++++++ pos_ticket_logo/__init__.py | 24 ++++++ pos_ticket_logo/__openerp__.py | 43 +++++++++++ pos_ticket_logo/static/description/icon.png | Bin 0 -> 9553 bytes pos_ticket_logo/static/src/js/main.js | 73 ++++++++++++++++++ pos_ticket_logo/static/src/xml/pos.xml | 10 +++ pos_ticket_logo/views/pos_template.xml | 12 +++ .../pos_ticket_logo_report_receipt_report.xml | 17 ++++ 8 files changed, 229 insertions(+) create mode 100644 pos_ticket_logo/README.rst create mode 100644 pos_ticket_logo/__init__.py create mode 100644 pos_ticket_logo/__openerp__.py create mode 100644 pos_ticket_logo/static/description/icon.png create mode 100644 pos_ticket_logo/static/src/js/main.js create mode 100644 pos_ticket_logo/static/src/xml/pos.xml create mode 100644 pos_ticket_logo/views/pos_template.xml create mode 100644 pos_ticket_logo/views/pos_ticket_logo_report_receipt_report.xml diff --git a/pos_ticket_logo/README.rst b/pos_ticket_logo/README.rst new file mode 100644 index 00000000..366150d4 --- /dev/null +++ b/pos_ticket_logo/README.rst @@ -0,0 +1,50 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: AGPLv3 License + +POS Ticket logo +=============== + +Add company logo in POS ticket + + +Motivation +========== + +```XmlReceipt``` Qweb report is used when ```iface_print_via_proxy``` config is **True**: +https://github.com/odoo/odoo/blob/8.0/addons/point_of_sale/static/src/js/screens.js#L1341 + +But in the case ```iface_print_via_proxy``` config is **False**, ```PosTicket``` +Qweb report is used, and company_logo is not used: +https://github.com/odoo/odoo/blob/8.0/addons/point_of_sale/static/src/js/screens.js#L984 + +In other hand, company_logo is loaded using ```/web/binary/company_logo``` controller that returns a 150px wide logo: +https://github.com/odoo/odoo/blob/8.0/addons/point_of_sale/static/src/js/models.js#L371 +but after that logo is resized to 300px width, so a pixelled logo appears even +original logo is 300px wide. +That's why we override how company_logo is loaded. We also resized it to 260px +(not 300px) wide because appears cut in PDF: + + +Credits +======= + +Contributors +------------ + +* Antonio Espinosa +* Endika Iglesias + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/pos_ticket_logo/__init__.py b/pos_ticket_logo/__init__.py new file mode 100644 index 00000000..f3ebd3ec --- /dev/null +++ b/pos_ticket_logo/__init__.py @@ -0,0 +1,24 @@ +# -*- 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 +# Antonio Espinosa +# +# 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 . +# +############################################################################## diff --git a/pos_ticket_logo/__openerp__.py b/pos_ticket_logo/__openerp__.py new file mode 100644 index 00000000..e035b6ee --- /dev/null +++ b/pos_ticket_logo/__openerp__.py @@ -0,0 +1,43 @@ +# -*- 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 +# Antonio Espinosa +# +# 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 . +# +############################################################################## +{ + 'name': 'Pos ticket logo', + 'category': 'Point Of Sale', + 'version': '1.0', + 'depends': [ + 'point_of_sale', + ], + 'data': [ + 'views/pos_ticket_logo_report_receipt_report.xml', + 'views/pos_template.xml', + ], + 'qweb': [ + 'static/src/xml/pos.xml', + ], + 'author': 'Antiun IngenierĂ­a S.L.', + 'website': 'http://www.antiun.com', + 'license': 'AGPL-3', + 'installable': True, +} diff --git a/pos_ticket_logo/static/description/icon.png b/pos_ticket_logo/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..e060fb4a53a27360dd8d7c7ef6dc780c005f8832 GIT binary patch literal 9553 zcmaJ{byQSO^ruF!**I|U>Z76e_IB_u^c8WxsVx*O>f ze*68M-`~IY&YL-B-kUdf&Ye5=&gXt&Uu&z95i<~DVPTP}t0_Y;b;y4YfB;i=%UTX% zDuVYKs>)ao|J_AxW$Bm}B3HF{9#~i;RR2BLSh=6+FpY$s>RPV|mk5Z70rbvRh!9K@ zz2_@KPbC*8Cu?U1X_P6kM&Yl*CwXS~6T1gr_V_IEo@3S{$-(cd}@Z6qhz*?NH zx>H(h{*Sg37&0v|mJ(#v8NwT*u8)p9_{+NoSVK2 zN0+x3N4skZ*!a}1<^R9J^;Xf-+q?2$d)qKIIUikXt?|mo$7j&JVQF#E424A2JuS4F zKq7T#XJ?yffG*$W_u6I`7TU}J$8JT8+jw#AELvFDY|0(L_l2Wd0oJ1hGAMX!^Wx&7 z*mAhho>>vC?MRRatYMKm!k7NapA`t`pgM3_YHyRy*Onu29Be!6|8tyG{~&o|p9+yJ zYFH$2#IGce0SE#}ZQ&1Y78c7_j1=-0X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L@=(1TZ5d5sx8uZLJ^sfMGUoCZ5FopNwq7%;k^+wX_ zl0BPRPU*X>fM@dpe0U2S5rRuvI8COHq3J0IrzOI`%Up5uQ-09HI)T78PrrzZYjMlf zq{CU;S@PlGp_9?x<-&3g>R_&6kf$G`O=MRKV*;)}CdG9GHN~X3WId>y0(1&x+lq_A zHeP8HF6Q+U$aDOcP$@F`lKlIFg{v474EL%p zD)1p!1azQUXt#rTLouV^1_cGl33)*8hK&RDe&EhjG%Omu9+!%5+)HhL$@`b8#_x1f z8#b95X6quy0~6DLO;%AWy9FqMuS15SZSbk99h-FQ;o^_iUD02a?BS}!?oCd(0~DZ$ zZGo6ogcj(Q1g~kB$f6XvL(4?23dE$%4|H(Lu(-#%;O3D`xKV!$l(LJ1NF<&`s5!vV z&F3~R@Q^!aByV{`JDx{eZAwk1kTFdf9i>7F@U)GxyzKvr7|%(hd=5prSN^K7DK`RF zgF36+^2>J{W8C2951A0=8a@YGSJ%I!%`zwdefOcpFb~zD3OWyF`~Bfa{uYa)S$2Qg zh=m*v=j~hm*x@{Jam>gKs3(ds0SzdhErLF&jR!d~LBYQ+@w{RF{{976%t3jTECcxp zrwMksqb#z4zK0)!=h0|%X~xZ0;OfD*H~UBo4jAn@d+dkK_&j_?!VeUD&5)f0?R zckq@y3<*UWejeW0-TASy?(-2rjd=Q>z^h%FuvG99YH~3eAKBmseFC?F-i@qgoza8M(O~H(u_~rU!Cc)q3rr z?9m98Nh3MDdBXYr)7bR?qm?v7Ok2P4@wxP8``!0vM8XT_m4?c-<#IJ}HS+%c-q?F` zHjCf*8Q9Y2KryF(BI0w2SV96Q_6@GkTQnpgr)vUTe(uvBJ6(vKjny4 literal 0 HcmV?d00001 diff --git a/pos_ticket_logo/static/src/js/main.js b/pos_ticket_logo/static/src/js/main.js new file mode 100644 index 00000000..90903f5b --- /dev/null +++ b/pos_ticket_logo/static/src/js/main.js @@ -0,0 +1,73 @@ +/** + * # -*- coding: utf-8 -*- + * ############################################################################## + * # + * # OpenERP, Open Source Management Solution + * # This module copyright : + * # (c) 2014 Antiun Ingenieria, SL (Madrid, Spain, http://www.antiun.com) + * # Endika Iglesias + * # Antonio Espinosa + * # + * # 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 . + * # + * ############################################################################## + */ + +// Check jQuery available +if (typeof jQuery === 'undefined') { throw new Error('POS Ticket Logo Addon requires jQuery'); } + ++function ($) { + 'use strict'; + + openerp.pos_ticket_logo = function (instance, module) { + var _t = instance.web._t, + _lt = instance.web._lt; + var QWeb = instance.web.qweb; + + 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); + + self.company_logo_base64 = c.toDataURL(); + loaded.resolve(); + }; + self.company_logo.src = '/web/binary/image?model=res.company&id=' + self.company.id + '&field=logo'; + }); + return loaded; + } + }); + }; + +}(jQuery); diff --git a/pos_ticket_logo/static/src/xml/pos.xml b/pos_ticket_logo/static/src/xml/pos.xml new file mode 100644 index 00000000..80262d61 --- /dev/null +++ b/pos_ticket_logo/static/src/xml/pos.xml @@ -0,0 +1,10 @@ + + + + +

+
+
+ + + diff --git a/pos_ticket_logo/views/pos_template.xml b/pos_ticket_logo/views/pos_template.xml new file mode 100644 index 00000000..eb29caab --- /dev/null +++ b/pos_ticket_logo/views/pos_template.xml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/pos_ticket_logo/views/pos_ticket_logo_report_receipt_report.xml b/pos_ticket_logo/views/pos_ticket_logo_report_receipt_report.xml new file mode 100644 index 00000000..8f8f34e6 --- /dev/null +++ b/pos_ticket_logo/views/pos_ticket_logo_report_receipt_report.xml @@ -0,0 +1,17 @@ + + + + + +