Browse Source

!fixup misc

pull/428/head
Pierrick Brun 5 years ago
parent
commit
22a09e8e7a
  1. 26
      pos_mail_receipt/models/pos_order.py
  2. 1
      pos_mail_receipt/static/src/js/screens.js

26
pos_mail_receipt/models/pos_order.py

@ -3,10 +3,14 @@
# 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"
@ -18,18 +22,23 @@ class PosOrder(models.Model):
):
order = self.search([("pos_reference", "=", pos_reference)])
if len(order) < 1:
return _("Error: no order found")
_logger.error(_("Error: no order found"))
return
if order.email_receipt_sent:
return _("E-mail already sent")
_logger.info(_("E-mail already sent"))
return
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"
_logger.error(
_(
"Cannot send the ticket, no email address found for the client"
)
)
mail_template = self.env.ref("pos_mail_receipt.email_send_ticket")
email_values = {}
if email:
mail_template.email_to = email
email_values["email_to"] = email
else:
mail_template.email_to = order.partner_id.email
email_values["email_to"] = order.partner_id.email
base64_pdf = self.env["ir.actions.report"]._run_wkhtmltopdf(
[body_from_ui.encode("utf-16")],
landscape=False,
@ -49,10 +58,9 @@ class PosOrder(models.Model):
"res_id": order.id,
}
)
email_values["attachment_ids"] = [attachment.id]
mail_template.send_mail(
order.id,
force_send=force,
email_values={"attachment_ids": [attachment.id]},
order.id, force_send=force, email_values=email_values,
)
order.email_receipt_sent = True

1
pos_mail_receipt/static/src/js/screens.js

@ -54,7 +54,6 @@ odoo.define("pos_mail_receipt.screens", function (require) {
timeout: timeout,
})
.then(function (result) {
console.log(result);
return true
}).fail(function (type, error){
var connection_problem = true;

Loading…
Cancel
Save