Browse Source

!fixup misc

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

24
pos_mail_receipt/models/pos_order.py

@ -3,10 +3,14 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import logging
import base64 import base64
from odoo import fields, models, api, _ from odoo import fields, models, api, _
_logger = logging.getLogger(__name__)
class PosOrder(models.Model): class PosOrder(models.Model):
_inherit = "pos.order" _inherit = "pos.order"
@ -18,18 +22,23 @@ class PosOrder(models.Model):
): ):
order = self.search([("pos_reference", "=", pos_reference)]) order = self.search([("pos_reference", "=", pos_reference)])
if len(order) < 1: if len(order) < 1:
return _("Error: no order found")
_logger.error(_("Error: no order found"))
return
if order.email_receipt_sent: 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: if not email and not order.partner_id and not order.partner_id.email:
return _(
_logger.error(
_(
"Cannot send the ticket, no email address found for the client" "Cannot send the ticket, no email address found for the client"
) )
)
mail_template = self.env.ref("pos_mail_receipt.email_send_ticket") mail_template = self.env.ref("pos_mail_receipt.email_send_ticket")
email_values = {}
if email: if email:
mail_template.email_to = email
email_values["email_to"] = email
else: 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( base64_pdf = self.env["ir.actions.report"]._run_wkhtmltopdf(
[body_from_ui.encode("utf-16")], [body_from_ui.encode("utf-16")],
landscape=False, landscape=False,
@ -49,10 +58,9 @@ class PosOrder(models.Model):
"res_id": order.id, "res_id": order.id,
} }
) )
email_values["attachment_ids"] = [attachment.id]
mail_template.send_mail( 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 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, timeout: timeout,
}) })
.then(function (result) { .then(function (result) {
console.log(result);
return true return true
}).fail(function (type, error){ }).fail(function (type, error){
var connection_problem = true; var connection_problem = true;

Loading…
Cancel
Save