From 1086d8cce7070c28009425f67fc4f319d82bbddb Mon Sep 17 00:00:00 2001 From: Pierrick Brun Date: Mon, 9 Dec 2019 16:36:10 +0100 Subject: [PATCH 01/14] [ADD] pos_mail_receipt module --- pos_mail_receipt/README.rst | 86 ++++ pos_mail_receipt/__init__.py | 1 + pos_mail_receipt/__manifest__.py | 14 + pos_mail_receipt/data/email.xml | 19 + pos_mail_receipt/i18n/fr.po | 131 ++++++ pos_mail_receipt/i18n/pos_mail_receipt.pot | 122 +++++ pos_mail_receipt/models/__init__.py | 1 + pos_mail_receipt/models/pos_order.py | 70 +++ pos_mail_receipt/readme/CONTRIBUTORS.rst | 3 + pos_mail_receipt/readme/DESCRIPTION.rst | 5 + pos_mail_receipt/readme/USAGE.rst | 3 + pos_mail_receipt/static/description/icon.png | Bin 0 -> 9553 bytes .../static/description/index.html | 434 ++++++++++++++++++ pos_mail_receipt/static/src/js/screens.js | 93 ++++ pos_mail_receipt/static/src/xml/pos.xml | 33 ++ pos_mail_receipt/templates/assets.xml | 13 + 16 files changed, 1028 insertions(+) create mode 100644 pos_mail_receipt/README.rst create mode 100644 pos_mail_receipt/__init__.py create mode 100644 pos_mail_receipt/__manifest__.py create mode 100644 pos_mail_receipt/data/email.xml create mode 100644 pos_mail_receipt/i18n/fr.po create mode 100644 pos_mail_receipt/i18n/pos_mail_receipt.pot create mode 100644 pos_mail_receipt/models/__init__.py create mode 100644 pos_mail_receipt/models/pos_order.py create mode 100644 pos_mail_receipt/readme/CONTRIBUTORS.rst create mode 100644 pos_mail_receipt/readme/DESCRIPTION.rst create mode 100644 pos_mail_receipt/readme/USAGE.rst create mode 100644 pos_mail_receipt/static/description/icon.png create mode 100644 pos_mail_receipt/static/description/index.html create mode 100644 pos_mail_receipt/static/src/js/screens.js create mode 100644 pos_mail_receipt/static/src/xml/pos.xml create mode 100644 pos_mail_receipt/templates/assets.xml 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..a45fbcd9 --- /dev/null +++ b/pos_mail_receipt/models/pos_order.py @@ -0,0 +1,70 @@ +# Copyright 2019 Coop IT Easy SCRLfs +# @author Pierrick Brun +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + + +import base64 +from odoo import fields, models, api, _ + + +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: + return _("Error: no order found") + if order.email_receipt_sent: + return _("E-mail already sent") + if not email and not order.partner_id and not order.partner_id.email: + return _( + "Cannot send the ticket, no email address found for the client" + ) + mail_template = self.env.ref("pos_mail_receipt.email_send_ticket") + if email: + mail_template.email_to = email + else: + mail_template.email_to = order.partner_id.email + base64_pdf = self.env["ir.actions.report"]._run_wkhtmltopdf( + [body_from_ui.encode("utf-16")], + landscape=False, + specific_paperformat_args={ + "data-report-margin-top": 10, + "data-report-header-spacing": 10, + }, + ) + 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, + } + ) + mail_template.send_mail( + order.id, + force_send=force, + email_values={"attachment_ids": [attachment.id]}, + ) + 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 0000000000000000000000000000000000000000..e060fb4a53a27360dd8d7c7ef6dc780c005f8832 GIT binary patch literal 9553 zcmaJ{byQSO^ruF!**I|U>Z76e_IB_u^c8WxsVx*O>f ze*68M-`~IY&YL-B-kU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!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_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/js/screens.js b/pos_mail_receipt/static/src/js/screens.js new file mode 100644 index 00000000..cb90b432 --- /dev/null +++ b/pos_mail_receipt/static/src/js/screens.js @@ -0,0 +1,93 @@ +/* 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 ReceiptScreenWidget = screens.ReceiptScreenWidget.include({ + renderElement: function() { + this._super(); + var self = this; + this.$('.button.email').click(function(){ + if (!self._locked) { + self.email(); + } + }); + }, + email: function() { + var self = this; + var email = false; + var body_from_ui = this.$('.pos-sale-ticket').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; + 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) { + console.log(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; + 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 + }); + } + if(connection_problem){ + self.gui.show_popup('error',{ + 'title': _t('The e-mail could not be sent'), + 'body': _t('Check your internet connection and try again.'), + }); + } + }); + }, + }); + +}); + +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..df97620d --- /dev/null +++ b/pos_mail_receipt/static/src/xml/pos.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + diff --git a/pos_mail_receipt/templates/assets.xml b/pos_mail_receipt/templates/assets.xml new file mode 100644 index 00000000..b5e8ab2e --- /dev/null +++ b/pos_mail_receipt/templates/assets.xml @@ -0,0 +1,13 @@ + + + + +