diff --git a/.travis.yml b/.travis.yml index c478db8c..485f041e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ addons: apt: packages: - expect-dev # provides unbuffer utility + - wkhtmltopdf env: global: diff --git a/pos_mail_receipt/README.rst b/pos_mail_receipt/README.rst new file mode 100644 index 00000000..7cc432ee --- /dev/null +++ b/pos_mail_receipt/README.rst @@ -0,0 +1,86 @@ +================ +Pos Mail Receipt +================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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/12.0/pos_mail_receipt + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-12-0/pos-12-0-pos_mail_receipt + :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/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This modules allows you to send the PoS receipt by e-mail. + +Instead of printing the ticket you can choose to send it be e-mail. +If you know the customer's e-mail, it will use it. +If not you will be prompted for it. + +**Table of contents** + +.. contents:: + :local: + +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 +~~~~~~~ + +* Coop IT Easy SCRLfs + +Contributors +~~~~~~~~~~~~ + +* `Coop IT Easy SCRLfs `_: + + * Pierrick Brun + +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. + +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_mail_receipt/__init__.py b/pos_mail_receipt/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/pos_mail_receipt/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_mail_receipt/__manifest__.py b/pos_mail_receipt/__manifest__.py new file mode 100644 index 00000000..150d1b0e --- /dev/null +++ b/pos_mail_receipt/__manifest__.py @@ -0,0 +1,14 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Pos Mail Receipt", + "category": "Point Of Sale", + "version": "12.0.1.0.0", + "author": "Coop IT Easy SCRLfs, " "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/pos", + "license": "AGPL-3", + "depends": ["point_of_sale"], + "data": ["templates/assets.xml", "data/email.xml"], + "qweb": ["static/src/xml/pos.xml"], + "installable": True, +} diff --git a/pos_mail_receipt/data/email.xml b/pos_mail_receipt/data/email.xml new file mode 100644 index 00000000..aff3af80 --- /dev/null +++ b/pos_mail_receipt/data/email.xml @@ -0,0 +1,19 @@ + + + + + + + Send Receipt + ${(object.user_id.email and '%s <%s>' % (object.user_id.name, object.user_id.email) or '')|safe} + ${object.pos_reference} + + + ${object.partner_id.lang} + + + + + diff --git a/pos_mail_receipt/i18n/fr.po b/pos_mail_receipt/i18n/fr.po new file mode 100644 index 00000000..094ec1a2 --- /dev/null +++ b/pos_mail_receipt/i18n/fr.po @@ -0,0 +1,131 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_mail_receipt +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-12-17 14:32+0000\n" +"PO-Revision-Date: 2019-12-17 15:38+0100\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"X-Generator: Poedit 2.2.4\n" +"Last-Translator: \n" +"Language: fr\n" + +#. module: pos_mail_receipt +#: model:mail.template,subject:pos_mail_receipt.email_send_ticket +msgid "${object.pos_reference}" +msgstr "" + +#. module: pos_mail_receipt +#: model:mail.template,body_html:pos_mail_receipt.email_send_ticket +msgid "" +"

\n" +"Your Ticket ${object.pos_reference}\n" +"

" +msgstr "" +"

\n" +"Votre Ticket ${object.pos_reference}\n" +"

" + +#. module: pos_mail_receipt +#. openerp-web +#: code:addons/pos_mail_receipt/static/src/xml/pos.xml:25 +#, python-format +msgid "Cancel" +msgstr "Annuler" + +#. module: pos_mail_receipt +#: code:addons/pos_mail_receipt/models/pos_order.py:25 +#, python-format +msgid "Cannot send the ticket, no email address found for the client" +msgstr "" +"Impossible d'envoyer le ticket, pas d'adresse mail trouvée pour le " +"client" + +#. module: pos_mail_receipt +#. openerp-web +#: code:addons/pos_mail_receipt/static/src/js/screens.js:82 +#, python-format +msgid "Check your internet connection and try again." +msgstr "Vérifiez votre connexion internet et essayez à nouveau." + +#. module: pos_mail_receipt +#. openerp-web +#: code:addons/pos_mail_receipt/static/src/xml/pos.xml:22 +#, python-format +msgid "Confirm" +msgstr "Confirmer" + +#. module: pos_mail_receipt +#. openerp-web +#: code:addons/pos_mail_receipt/static/src/js/screens.js:28 +#, python-format +msgid "E-mail address to use" +msgstr "Adresse mail à utiliser" + +#. module: pos_mail_receipt +#: code:addons/pos_mail_receipt/models/pos_order.py:23 +#, python-format +msgid "E-mail already sent" +msgstr "E-mail déjà envoyé" + +#. module: pos_mail_receipt +#: model:ir.model.fields,field_description:pos_mail_receipt.field_pos_order__email_receipt_sent +msgid "Email Receipt Sent" +msgstr "Reçu envoyé" + +#. module: pos_mail_receipt +#: code:addons/pos_mail_receipt/models/pos_order.py:21 +#, python-format +msgid "Error: no order found" +msgstr "Erreur: pas de commande trouvée" + +#. module: pos_mail_receipt +#. openerp-web +#: code:addons/pos_mail_receipt/static/src/xml/pos.xml:19 +#, python-format +msgid "Mail" +msgstr "Mail" + +#. module: pos_mail_receipt +#. openerp-web +#: code:addons/pos_mail_receipt/static/src/xml/pos.xml:8 +#, python-format +msgid "Mail Receipt" +msgstr "Reçu" + +#. module: pos_mail_receipt +#: model:ir.model,name:pos_mail_receipt.model_pos_order +msgid "Point of Sale Orders" +msgstr "Commandes du point de vente" + +#. module: pos_mail_receipt +#: code:addons/pos_mail_receipt/models/pos_order.py:44 +#, python-format +msgid "Receipt_{}.pdf" +msgstr "Recu_{}.pdf" + +#. module: pos_mail_receipt +#. openerp-web +#: code:addons/pos_mail_receipt/static/src/js/screens.js:81 +#, python-format +msgid "The e-mail could not be sent" +msgstr "L'e-mail n'a pas pu être envoyé" + +#. module: pos_mail_receipt +#: model:mail.template,report_name:pos_mail_receipt.email_send_ticket +msgid "Ticket ${object.pos_reference}" +msgstr "Ticket ${object.pos_reference}" + +#. module: pos_mail_receipt +#: model:ir.model,name:pos_mail_receipt.model_report_pos_mail_receipt_pos_receipt_report +msgid "report.pos_mail_receipt.pos_receipt_report" +msgstr "" diff --git a/pos_mail_receipt/i18n/pos_mail_receipt.pot b/pos_mail_receipt/i18n/pos_mail_receipt.pot new file mode 100644 index 00000000..3641c716 --- /dev/null +++ b/pos_mail_receipt/i18n/pos_mail_receipt.pot @@ -0,0 +1,122 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_mail_receipt +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-12-17 14:32+0000\n" +"PO-Revision-Date: 2019-12-17 14:32+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: pos_mail_receipt +#: model:mail.template,subject:pos_mail_receipt.email_send_ticket +msgid "${object.pos_reference}" +msgstr "" + +#. module: pos_mail_receipt +#: model:mail.template,body_html:pos_mail_receipt.email_send_ticket +msgid "

\n" +"Your Ticket ${object.pos_reference}\n" +"

" +msgstr "" + +#. module: pos_mail_receipt +#. openerp-web +#: code:addons/pos_mail_receipt/static/src/xml/pos.xml:25 +#, python-format +msgid "Cancel" +msgstr "" + +#. module: pos_mail_receipt +#: code:addons/pos_mail_receipt/models/pos_order.py:25 +#, python-format +msgid "Cannot send the ticket, no email address found for the client" +msgstr "" + +#. module: pos_mail_receipt +#. openerp-web +#: code:addons/pos_mail_receipt/static/src/js/screens.js:82 +#, python-format +msgid "Check your internet connection and try again." +msgstr "" + +#. module: pos_mail_receipt +#. openerp-web +#: code:addons/pos_mail_receipt/static/src/xml/pos.xml:22 +#, python-format +msgid "Confirm" +msgstr "" + +#. module: pos_mail_receipt +#. openerp-web +#: code:addons/pos_mail_receipt/static/src/js/screens.js:28 +#, python-format +msgid "E-mail address to use" +msgstr "" + +#. module: pos_mail_receipt +#: code:addons/pos_mail_receipt/models/pos_order.py:23 +#, python-format +msgid "E-mail already sent" +msgstr "" + +#. module: pos_mail_receipt +#: model:ir.model.fields,field_description:pos_mail_receipt.field_pos_order__email_receipt_sent +msgid "Email Receipt Sent" +msgstr "" + +#. module: pos_mail_receipt +#: code:addons/pos_mail_receipt/models/pos_order.py:21 +#, python-format +msgid "Error: no order found" +msgstr "" + +#. module: pos_mail_receipt +#. openerp-web +#: code:addons/pos_mail_receipt/static/src/xml/pos.xml:19 +#, python-format +msgid "Mail" +msgstr "" + +#. module: pos_mail_receipt +#. openerp-web +#: code:addons/pos_mail_receipt/static/src/xml/pos.xml:8 +#, python-format +msgid "Mail Receipt" +msgstr "" + +#. module: pos_mail_receipt +#: model:ir.model,name:pos_mail_receipt.model_pos_order +msgid "Point of Sale Orders" +msgstr "" + +#. module: pos_mail_receipt +#: code:addons/pos_mail_receipt/models/pos_order.py:44 +#, python-format +msgid "Receipt_{}.pdf" +msgstr "" + +#. module: pos_mail_receipt +#. openerp-web +#: code:addons/pos_mail_receipt/static/src/js/screens.js:81 +#, python-format +msgid "The e-mail could not be sent" +msgstr "" + +#. module: pos_mail_receipt +#: model:mail.template,report_name:pos_mail_receipt.email_send_ticket +msgid "Ticket ${object.pos_reference}" +msgstr "" + +#. module: pos_mail_receipt +#: model:ir.model,name:pos_mail_receipt.model_report_pos_mail_receipt_pos_receipt_report +msgid "report.pos_mail_receipt.pos_receipt_report" +msgstr "" + diff --git a/pos_mail_receipt/models/__init__.py b/pos_mail_receipt/models/__init__.py new file mode 100644 index 00000000..e9ab911d --- /dev/null +++ b/pos_mail_receipt/models/__init__.py @@ -0,0 +1 @@ +from . import pos_order diff --git a/pos_mail_receipt/models/pos_order.py b/pos_mail_receipt/models/pos_order.py new file mode 100644 index 00000000..a3884455 --- /dev/null +++ b/pos_mail_receipt/models/pos_order.py @@ -0,0 +1,86 @@ +# Copyright 2019 Coop IT Easy SCRLfs +# @author Pierrick Brun +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + + +import logging +import base64 +from odoo import fields, models, api, _ + + +_logger = logging.getLogger(__name__) + + +class PosOrder(models.Model): + _inherit = "pos.order" + + email_receipt_sent = fields.Boolean() + + @api.model + def send_mail_receipt( + self, pos_reference, email, body_from_ui, force=True + ): + order = self.search([("pos_reference", "=", pos_reference)]) + if len(order) < 1: + _logger.error(_("Error: no order found")) + return + if order.email_receipt_sent: + _logger.info(_("E-mail already sent")) + return + if not email and not order.partner_id and not order.partner_id.email: + _logger.error( + _( + "Cannot send the ticket, " + "no email address found for the client" + ) + ) + email_values = {} + if email: + email_values["email_to"] = email + else: + email_values["email_to"] = order.partner_id.email + + receipt = ( + "
" + "
" + "{}
".format(body_from_ui) + ) + + bodies, html_ids, header, footer, specific_paperformat_args = self.env[ + "ir.actions.report" + ]._prepare_html(receipt) + base64_pdf = self.env["ir.actions.report"]._run_wkhtmltopdf( + bodies, + landscape=False, + specific_paperformat_args=specific_paperformat_args, + ) + attachment = self.env["ir.attachment"].create( + { + "name": pos_reference, + "datas_fname": _("Receipt_{}.pdf".format(pos_reference)), + "type": "binary", + "mimetype": "application/x-pdf", + "db_datas": base64.encodestring(base64_pdf), + "res_model": "pos.order", + "res_id": order.id, + } + ) + email_values["attachment_ids"] = [attachment.id] + mail_template = self.env.ref("pos_mail_receipt.email_send_ticket") + mail_template.send_mail( + order.id, force_send=force, email_values=email_values, + ) + order.email_receipt_sent = True + + @api.model + def create_from_ui(self, orders): + res = super(PosOrder, self).create_from_ui(orders) + for order in orders: + if "email" in order["data"]: + self.send_mail_receipt( + order["data"]["name"], + order["data"]["email"], + order["data"]["body_from_ui"], + force=False, + ) + return res diff --git a/pos_mail_receipt/readme/CONTRIBUTORS.rst b/pos_mail_receipt/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..0316142d --- /dev/null +++ b/pos_mail_receipt/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Coop IT Easy SCRLfs `_: + + * Pierrick Brun diff --git a/pos_mail_receipt/readme/DESCRIPTION.rst b/pos_mail_receipt/readme/DESCRIPTION.rst new file mode 100644 index 00000000..59b716b9 --- /dev/null +++ b/pos_mail_receipt/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +This modules allows you to send the PoS receipt by e-mail. + +Instead of printing the ticket you can choose to send it be e-mail. +If you know the customer's e-mail, it will use it. +If not you will be prompted for it. diff --git a/pos_mail_receipt/readme/USAGE.rst b/pos_mail_receipt/readme/USAGE.rst new file mode 100644 index 00000000..8bf546e6 --- /dev/null +++ b/pos_mail_receipt/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_mail_receipt/static/description/icon.png b/pos_mail_receipt/static/description/icon.png new file mode 100644 index 00000000..e060fb4a Binary files /dev/null and b/pos_mail_receipt/static/description/icon.png differ diff --git a/pos_mail_receipt/static/description/index.html b/pos_mail_receipt/static/description/index.html new file mode 100644 index 00000000..f8193fbf --- /dev/null +++ b/pos_mail_receipt/static/description/index.html @@ -0,0 +1,434 @@ + + + + + + +Pos Mail Receipt + + + +
+

Pos Mail Receipt

+ + +

Beta License: AGPL-3 OCA/pos Translate me on Weblate Try me on Runbot

+

This modules allows you to send the PoS receipt by e-mail.

+

Instead of printing the ticket you can choose to send it be e-mail. +If you know the customer’s e-mail, it will use it. +If not you will be prompted for it.

+

Table of contents

+ +
+

Usage

+
    +
  1. Open a new PoS session.
  2. +
  3. Make an order and validate it.
  4. +
  5. You should see the company logo in the receipt preview.
  6. +
+
+
+

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

+
    +
  • Coop IT Easy SCRLfs
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

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_mail_receipt/static/src/css/pos.css b/pos_mail_receipt/static/src/css/pos.css new file mode 100644 index 00000000..a6481084 --- /dev/null +++ b/pos_mail_receipt/static/src/css/pos.css @@ -0,0 +1,3 @@ +.pos .modal-dialog .popup-textinput input{ + margin-left: 10% +} diff --git a/pos_mail_receipt/static/src/css/print.css b/pos_mail_receipt/static/src/css/print.css new file mode 100644 index 00000000..edb0b670 --- /dev/null +++ b/pos_mail_receipt/static/src/css/print.css @@ -0,0 +1,129 @@ +/* This is a copy of the pos receipt screen CSS + * This allows to use it in the backend */ +.pos .receipt-screen .centered-content .button { + line-height: 40px; + padding: 3px 13px; + font-size: 20px; + text-align: center; + background: rgb(230, 230, 230); + margin: 16px; + margin-bottom: 0px; + border-radius: 3px; + border: solid 1px rgb(209, 209, 209); + cursor: pointer; +} + +.pos .pos-receipt-container { + font-size: 0.75em; + text-align: center; + direction: ltr; +} + +.pos .pos-sale-ticket { + text-align: left; + width: 300px; + background-color: white; + margin: 20px; + padding: 15px; + font-size: 14px; + padding-bottom:30px; + display: inline-block; + font-family: "Inconsolata"; + border: solid 1px rgb(220,220,220); + border-radius: 3px; + overflow: hidden; +} +.pos .pos-sale-ticket pre{ + font-family: "Inconsolata"; +} +.pos .pos-sale-ticket .emph{ + font-size: 20px; + margin:5px; +} +.pos .pos-sale-ticket table { + width: 100%; + border: 0; + table-layout: fixed; +} +.pos .pos-sale-ticket table td { + border: 0; + word-wrap: break-word; +} + +@page { + margin: 0; +} +@media print { + * { + color: black !important; + } + body { + margin: 0; + color: white !important; + /* avoid black background if backgrounds are printed */ + background: initial; + } + .oe_leftbar, + .oe_loading, + .pos .pos-topheader, + .pos .pos-leftpane, + .pos .keyboard_frame, + .pos .receipt-screen header, + .pos .receipt-screen .top-content, + .pos .receipt-screen .centered-content .button { + display: none !important; + } + .pos, + .pos .pos-content, + .pos .rightpane, + .pos .screen, + .pos .window, + .pos .window .subwindow, + .pos .subwindow .subwindow-container{ + display: block; + position: static; + height: auto; + } + .pos{ + background: white !important; + } + .pos .rightpane { + left: 0px !important; + background-color: white; + } + .pos .receipt-screen { + text-align: left; + } + .pos .receipt-screen .centered-content{ + position: static; + border: none; + } + .pos .pos-receipt-container { + text-align: left; + } + .pos-actionbar { + display: none !important; + } + .debug-widget{ + display: none !important; + } + .pos *{ + text-shadow: none !important; + box-shadow: none !important; + background: transparent !important; + } + .pos .pos-sale-ticket{ + margin: 0; + margin-left: auto !important; + margin-right: auto !important; + border: none !important; + font-size: 13px !important; + width: 266px !important; + } + .o_debug_manager { + display: none !important; + } + .o_chat_window { + display: none !important; + } +} diff --git a/pos_mail_receipt/static/src/js/screens.js b/pos_mail_receipt/static/src/js/screens.js new file mode 100644 index 00000000..7d67d17c --- /dev/null +++ b/pos_mail_receipt/static/src/js/screens.js @@ -0,0 +1,102 @@ +/* License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */ + + +odoo.define("pos_mail_receipt.screens", function (require) { + "use strict"; + + var screens = require('point_of_sale.screens'); + var rpc = require('web.rpc'); + var core = require('web.core'); + var _t = core._t; + + var ReceiptScreenWidget = screens.ReceiptScreenWidget.include({ + renderElement: function() { + this._super(); + var self = this; + this.$('.button.email').click(function(){ + if (!self._locked) { + self.email(); + } + }); + }, + click_next: function() { + this._super(); + this.$('.button.email').removeClass("highlight"); + }, + email: function() { + var self = this; + var email = false; + var body_from_ui = this.$('.pos-receipt-container').html() + if( this.pos.get_order().get_client() && this.pos.get_order().get_client().email ) { + self._send_email_server(this.pos.get_order().name, {"email": this.pos.get_order().get_client().email, "body_from_ui": body_from_ui}); + } else { + this.gui.show_popup('textinput', { + 'title':_t('E-mail address to use'), + 'value': '', + 'confirm': function(value) { + self._send_email_server(self.pos.get_order().name, {"email": value, "body_from_ui": body_from_ui}); + } + }); + } + }, + // ask the server to send the ticket as e-mail + // available options: + // - timeout: timeout for the rpc call in ms + // - email: email to use instead of the partner's + // returns a deferred + _send_email_server: async function (order, options) { + var self = this; + options = options || {}; + var timeout = typeof options.timeout === 'number' ? options.timeout : 7500; + this.$('.button.email').addClass("highlight"); + while (self.pos.get("synch").state == "connecting") { + await sleep(1000); + } + + return rpc.query({ + model: 'pos.order', + method: 'send_mail_receipt', + args: [order, options["email"], options["body_from_ui"]], + }, { + timeout: timeout, + }) + .then(function (result) { + return true + }).fail(function (type, error){ + var connection_problem = true; + for (var i = 0; i < self.pos.db.get_orders().length; i++) { + if (order == self.pos.db.get_orders()[i].data.name) { + self.pos.db.get_orders()[i].data["email"] = options["email"] || false; + self.pos.db.get_orders()[i].data["body_from_ui"] = options["body_from_ui"] || false; + connection_problem = false; + } + } + if(error.code === 200 ){ + // Business Logic Error, not a connection problem + //if warning do not need to display traceback!! + if (error.data.exception_type == 'warning') { + delete error.data.debug; + } + + self.gui.show_popup('error-traceback',{ + 'title': error.data.message, + 'body': error.data.debug + }); + self.$('.button.email').removeClass("highlight"); + } + if(connection_problem){ + self.gui.show_popup('error',{ + 'title': _t('The e-mail could not be sent'), + 'body': _t('The e-mail could not be sent to ') + options["email"] + _t('. Check your internet connection and try again.'), + }); + self.$('.button.email').removeClass("highlight"); + } + }); + }, + }); + +}); + +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} diff --git a/pos_mail_receipt/static/src/xml/pos.xml b/pos_mail_receipt/static/src/xml/pos.xml new file mode 100644 index 00000000..672e7129 --- /dev/null +++ b/pos_mail_receipt/static/src/xml/pos.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/pos_mail_receipt/templates/assets.xml b/pos_mail_receipt/templates/assets.xml new file mode 100644 index 00000000..99be6065 --- /dev/null +++ b/pos_mail_receipt/templates/assets.xml @@ -0,0 +1,20 @@ + + + + +