Browse Source

!fixup Revert "!fixup Use XmlReceipt instead of Html Receipt"

This reverts commit 4e9bef3919.
pull/428/head
Pierrick Brun 4 years ago
parent
commit
9fb80b2e72
  1. 9
      pos_mail_receipt/models/pos_order.py
  2. 12
      pos_mail_receipt/static/src/js/screens.js

9
pos_mail_receipt/models/pos_order.py

@ -18,7 +18,7 @@ class PosOrder(models.Model):
@api.model
def send_mail_receipt(
self, pos_reference, email, receipt, force=True
self, pos_reference, email, body_from_ui, force=True
):
order = self.search([("pos_reference", "=", pos_reference)])
if len(order) < 1:
@ -33,14 +33,14 @@ class PosOrder(models.Model):
"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:
email_values["email_to"] = email
else:
email_values["email_to"] = order.partner_id.email
base64_pdf = self.env["ir.actions.report"]._run_wkhtmltopdf(
[receipt.encode("utf-16")],
[body_from_ui.encode("utf-16")],
landscape=False,
specific_paperformat_args={
"data-report-margin-top": 10,
@ -59,7 +59,6 @@ class PosOrder(models.Model):
}
)
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,
)
@ -73,7 +72,7 @@ class PosOrder(models.Model):
self.send_mail_receipt(
order["data"]["name"],
order["data"]["email"],
order["data"]["receipt"],
order["data"]["body_from_ui"],
force=False,
)
return res

12
pos_mail_receipt/static/src/js/screens.js

@ -6,8 +6,6 @@ odoo.define("pos_mail_receipt.screens", function (require) {
var screens = require('point_of_sale.screens');
var rpc = require('web.rpc');
var core = require('web.core');
var QWeb = core.qweb;
var ReceiptScreenWidget = screens.ReceiptScreenWidget.include({
renderElement: function() {
@ -26,14 +24,15 @@ odoo.define("pos_mail_receipt.screens", function (require) {
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(), {"email": 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(), {"email": value});
self._send_email_server(self.pos.get_order().name, {"email": value, "body_from_ui": body_from_ui});
}
});
}
@ -51,12 +50,11 @@ odoo.define("pos_mail_receipt.screens", function (require) {
while (self.pos.get("synch").state == "connecting") {
await sleep(1000);
}
var receipt = QWeb.render('XmlReceipt', this.get_receipt_render_env());
return rpc.query({
model: 'pos.order',
method: 'send_mail_receipt',
args: [order.name, options["email"], receipt],
args: [order, options["email"], options["body_from_ui"]],
}, {
timeout: timeout,
})
@ -81,14 +79,12 @@ odoo.define("pos_mail_receipt.screens", function (require) {
'title': error.data.message,
'body': error.data.debug
});
this.$('.button.email').removeClass("highlight");
}
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.'),
});
this.$('.button.email').removeClass("highlight");
}
});
},

Loading…
Cancel
Save