From 9e941795da32085a771dc5b8a3dd80f670b6ef27 Mon Sep 17 00:00:00 2001 From: Antonio Espinosa Date: Mon, 22 Jun 2015 16:20:14 +0200 Subject: [PATCH 1/4] [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_j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2=z-xL@=(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 @@ + + + + + + From a34b551691ce0ac325e0983a6d3adc4be980eac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul=20=28ACSONE=29?= Date: Wed, 19 Apr 2017 09:47:04 +0200 Subject: [PATCH 2/4] [FIX] normalize version number in manifest --- pos_ticket_logo/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pos_ticket_logo/__openerp__.py b/pos_ticket_logo/__openerp__.py index e035b6ee..709aa150 100644 --- a/pos_ticket_logo/__openerp__.py +++ b/pos_ticket_logo/__openerp__.py @@ -25,7 +25,7 @@ { 'name': 'Pos ticket logo', 'category': 'Point Of Sale', - 'version': '1.0', + 'version': '8.0.1.0.0', 'depends': [ 'point_of_sale', ], From 9dea10c3a4651e8a11c85753f3b41966e6f79ea6 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Mon, 1 May 2017 22:05:39 +0200 Subject: [PATCH 3/4] OCA Transbot updated translations from Transifex --- pos_ticket_logo/i18n/es.po | 24 ++++++++++++++++++++++++ pos_ticket_logo/i18n/sl.po | 24 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 pos_ticket_logo/i18n/es.po create mode 100644 pos_ticket_logo/i18n/sl.po diff --git a/pos_ticket_logo/i18n/es.po b/pos_ticket_logo/i18n/es.po new file mode 100644 index 00000000..ec41fc99 --- /dev/null +++ b/pos_ticket_logo/i18n/es.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_ticket_logo +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-29 00:49+0000\n" +"PO-Revision-Date: 2017-04-29 00:49+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: es\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: pos_ticket_logo +#: view:website:point_of_sale.report_receipt +msgid "display:none;" +msgstr "display:none;" diff --git a/pos_ticket_logo/i18n/sl.po b/pos_ticket_logo/i18n/sl.po new file mode 100644 index 00000000..c7185ca8 --- /dev/null +++ b/pos_ticket_logo/i18n/sl.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_ticket_logo +# +# Translators: +# Matjaž Mozetič , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-29 00:49+0000\n" +"PO-Revision-Date: 2017-04-29 00:49+0000\n" +"Last-Translator: Matjaž Mozetič , 2017\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: sl\n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" + +#. module: pos_ticket_logo +#: view:website:point_of_sale.report_receipt +msgid "display:none;" +msgstr "display:none;" From cebf697d9d35d2c8e015c659c4942ff205445f36 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 23 Apr 2018 19:07:45 +0200 Subject: [PATCH 4/4] [MIG] pos_ticket_logo: Migration to 11.0 --- pos_ticket_logo/README.rst | 112 ++++++++++++++---- pos_ticket_logo/__init__.py | 24 ---- pos_ticket_logo/__manifest__.py | 21 ++++ pos_ticket_logo/__openerp__.py | 43 ------- pos_ticket_logo/i18n/es.po | 24 ---- pos_ticket_logo/i18n/sl.po | 24 ---- pos_ticket_logo/readme/CONFIGURE.rst | 11 ++ pos_ticket_logo/readme/CONTRIBUTORS.rst | 6 + pos_ticket_logo/readme/DESCRIPTION.rst | 11 ++ pos_ticket_logo/readme/USAGE.rst | 3 + pos_ticket_logo/static/src/js/main.js | 73 ------------ pos_ticket_logo/static/src/js/models.js | 49 ++++++++ pos_ticket_logo/static/src/xml/pos.xml | 5 +- pos_ticket_logo/templates/assets.xml | 13 ++ pos_ticket_logo/views/pos_template.xml | 12 -- .../pos_ticket_logo_report_receipt_report.xml | 17 --- 16 files changed, 204 insertions(+), 244 deletions(-) create mode 100644 pos_ticket_logo/__manifest__.py delete mode 100644 pos_ticket_logo/__openerp__.py delete mode 100644 pos_ticket_logo/i18n/es.po delete mode 100644 pos_ticket_logo/i18n/sl.po create mode 100644 pos_ticket_logo/readme/CONFIGURE.rst create mode 100644 pos_ticket_logo/readme/CONTRIBUTORS.rst create mode 100644 pos_ticket_logo/readme/DESCRIPTION.rst create mode 100644 pos_ticket_logo/readme/USAGE.rst delete mode 100644 pos_ticket_logo/static/src/js/main.js create mode 100644 pos_ticket_logo/static/src/js/models.js create mode 100644 pos_ticket_logo/templates/assets.xml delete mode 100644 pos_ticket_logo/views/pos_template.xml delete 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 index 366150d4..d001a5c1 100644 --- a/pos_ticket_logo/README.rst +++ b/pos_ticket_logo/README.rst @@ -1,50 +1,110 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :alt: AGPLv3 License - -POS Ticket logo +=============== +Pos Ticket Logo =============== -Add company logo in POS ticket +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github + :target: https://github.com/OCA/pos/tree/11.0/pos_ticket_logo + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-11-0/pos-11-0-pos_ticket_logo + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/184/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +A different receipt template is used if the PoS ticket is printed via web or +via proxy. In the case the ticket is printed via web (through the browser) the +company logo isn't printed. This module adds it. + +In other hand, company_logo is loaded using `/web/binary/company_logo` +controller `that returns a 150px wide logo `_: +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. -Motivation -========== +**Table of contents** -```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 +.. contents:: + :local: -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 +Configuration +============= -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: +To add a logo to any given company: + +#. Go to *Settings > Users & Companies > Companies* +#. Edit one and add the logo editing the top left corner image. + +To configure receipt web print in the PoS (is the default setting): + +#. Go to *Point of Sale > Configuration > Point of Sale*. +#. Edit the one you want to configure. +#. If the *PosBox* setting is enabled the *Receipt Printer* setting should be + disabled. +Usage +===== + +#. Open a new PoS session. +#. Make an order and validate it. +#. You should see the company logo in the receipt preview. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= +Authors +~~~~~~~ + +* Tecnativa + Contributors ------------- +~~~~~~~~~~~~ -* Antonio Espinosa * Endika Iglesias -Maintainer ----------- +* `Tecnativa `_: -.. image:: http://odoo-community.org/logo.png - :alt: Odoo Community Association - :target: http://odoo-community.org + * Antonio Espinosa + * David Vidal + +Maintainers +~~~~~~~~~~~ This module is maintained by the OCA. +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + 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. +This module is part of the `OCA/pos `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/pos_ticket_logo/__init__.py b/pos_ticket_logo/__init__.py index f3ebd3ec..e69de29b 100644 --- a/pos_ticket_logo/__init__.py +++ b/pos_ticket_logo/__init__.py @@ -1,24 +0,0 @@ -# -*- 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/__manifest__.py b/pos_ticket_logo/__manifest__.py new file mode 100644 index 00000000..c843b9fd --- /dev/null +++ b/pos_ticket_logo/__manifest__.py @@ -0,0 +1,21 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Pos Ticket Logo", + "category": "Point Of Sale", + "version": "11.0.1.0.0", + "author": "Tecnativa, " + "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/pos", + "license": "AGPL-3", + "depends": [ + "point_of_sale", + ], + "data": [ + "templates/assets.xml", + ], + "qweb": [ + "static/src/xml/pos.xml", + ], + "installable": True, +} diff --git a/pos_ticket_logo/__openerp__.py b/pos_ticket_logo/__openerp__.py deleted file mode 100644 index 709aa150..00000000 --- a/pos_ticket_logo/__openerp__.py +++ /dev/null @@ -1,43 +0,0 @@ -# -*- 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': '8.0.1.0.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/i18n/es.po b/pos_ticket_logo/i18n/es.po deleted file mode 100644 index ec41fc99..00000000 --- a/pos_ticket_logo/i18n/es.po +++ /dev/null @@ -1,24 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * pos_ticket_logo -# -# Translators: -# OCA Transbot , 2017 -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-04-29 00:49+0000\n" -"PO-Revision-Date: 2017-04-29 00:49+0000\n" -"Last-Translator: OCA Transbot , 2017\n" -"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Language: es\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#. module: pos_ticket_logo -#: view:website:point_of_sale.report_receipt -msgid "display:none;" -msgstr "display:none;" diff --git a/pos_ticket_logo/i18n/sl.po b/pos_ticket_logo/i18n/sl.po deleted file mode 100644 index c7185ca8..00000000 --- a/pos_ticket_logo/i18n/sl.po +++ /dev/null @@ -1,24 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * pos_ticket_logo -# -# Translators: -# Matjaž Mozetič , 2017 -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-04-29 00:49+0000\n" -"PO-Revision-Date: 2017-04-29 00:49+0000\n" -"Last-Translator: Matjaž Mozetič , 2017\n" -"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Language: sl\n" -"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" - -#. module: pos_ticket_logo -#: view:website:point_of_sale.report_receipt -msgid "display:none;" -msgstr "display:none;" diff --git a/pos_ticket_logo/readme/CONFIGURE.rst b/pos_ticket_logo/readme/CONFIGURE.rst new file mode 100644 index 00000000..e08bb247 --- /dev/null +++ b/pos_ticket_logo/readme/CONFIGURE.rst @@ -0,0 +1,11 @@ +To add a logo to any given company: + +#. Go to *Settings > Users & Companies > Companies* +#. Edit one and add the logo editing the top left corner image. + +To configure receipt web print in the PoS (is the default setting): + +#. Go to *Point of Sale > Configuration > Point of Sale*. +#. Edit the one you want to configure. +#. If the *PosBox* setting is enabled the *Receipt Printer* setting should be + disabled. diff --git a/pos_ticket_logo/readme/CONTRIBUTORS.rst b/pos_ticket_logo/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..fdd98c7a --- /dev/null +++ b/pos_ticket_logo/readme/CONTRIBUTORS.rst @@ -0,0 +1,6 @@ +* Endika Iglesias + +* `Tecnativa `_: + + * Antonio Espinosa + * David Vidal diff --git a/pos_ticket_logo/readme/DESCRIPTION.rst b/pos_ticket_logo/readme/DESCRIPTION.rst new file mode 100644 index 00000000..b1b03fd1 --- /dev/null +++ b/pos_ticket_logo/readme/DESCRIPTION.rst @@ -0,0 +1,11 @@ +A different receipt template is used if the PoS ticket is printed via web or +via proxy. In the case the ticket is printed via web (through the browser) the +company logo isn't printed. This module adds it. + +In other hand, company_logo is loaded using `/web/binary/company_logo` +controller `that returns a 150px wide logo `_: + +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. diff --git a/pos_ticket_logo/readme/USAGE.rst b/pos_ticket_logo/readme/USAGE.rst new file mode 100644 index 00000000..8bf546e6 --- /dev/null +++ b/pos_ticket_logo/readme/USAGE.rst @@ -0,0 +1,3 @@ +#. Open a new PoS session. +#. Make an order and validate it. +#. You should see the company logo in the receipt preview. diff --git a/pos_ticket_logo/static/src/js/main.js b/pos_ticket_logo/static/src/js/main.js deleted file mode 100644 index 90903f5b..00000000 --- a/pos_ticket_logo/static/src/js/main.js +++ /dev/null @@ -1,73 +0,0 @@ -/** - * # -*- 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/js/models.js b/pos_ticket_logo/static/src/js/models.js new file mode 100644 index 00000000..11e919ee --- /dev/null +++ b/pos_ticket_logo/static/src/js/models.js @@ -0,0 +1,49 @@ +/* License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */ + + +odoo.define("pos_ticket_logo.models", function (require) { + "use strict"; + + var models = require("point_of_sale.models"); + + var exports = {}; + + var _pictures = _.findWhere( + models.PosModel.prototype.models, + {label: "pictures"} + ); + _pictures.loaded = function (self) { + self.company_logo = new Image(); + var logo_loaded = new $.Deferred(); + 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(); + logo_loaded.resolve(); + }; + self.company_logo.onerror = function () { + logo_loaded.reject(); + }; + self.company_logo.crossOrigin = "anonymous"; + self.company_logo.src = '/web/binary/image?model=res.company&id=' + + self.company.id + '&field=logo'; + return logo_loaded; + }; + + return exports; +}); diff --git a/pos_ticket_logo/static/src/xml/pos.xml b/pos_ticket_logo/static/src/xml/pos.xml index 80262d61..4b6968ca 100644 --- a/pos_ticket_logo/static/src/xml/pos.xml +++ b/pos_ticket_logo/static/src/xml/pos.xml @@ -1,10 +1,13 @@ + + - +

+
diff --git a/pos_ticket_logo/templates/assets.xml b/pos_ticket_logo/templates/assets.xml new file mode 100644 index 00000000..882dab80 --- /dev/null +++ b/pos_ticket_logo/templates/assets.xml @@ -0,0 +1,13 @@ + + + + + - - \ 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 deleted file mode 100644 index 8f8f34e6..00000000 --- a/pos_ticket_logo/views/pos_ticket_logo_report_receipt_report.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - -