[FIX] point_of_sale: send receipt ticket as attachment
Open POS, make an order, on the payment screen select email, select a customer, pay and validate. The receipt will be not an attachment, but a code image. The side effect is the visualization dependant on the viewer (email client, webmail, etc.) opw-2179303 closes odoo/odoo#44354 X-original-commit: c4ea4c045b97379b3c2f9e4904fb659d232bf41a Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
@@ -523,12 +523,23 @@ class PosOrder(models.Model):
|
||||
return False
|
||||
|
||||
message = _("<p>Dear %s,<br/>Here is your electronic ticket for the %s. </p>") % (client['name'], name)
|
||||
filename = 'Receipt-' + name + '.jpg'
|
||||
receipt = self.env['ir.attachment'].create({
|
||||
'name': filename,
|
||||
'type': 'binary',
|
||||
'datas': ticket,
|
||||
'res_model': 'pos.order',
|
||||
'res_id': self.ids[0],
|
||||
'store_fname': filename,
|
||||
'mimetype': 'image/jpeg',
|
||||
})
|
||||
mail_values = {
|
||||
'subject': _('Receipt %s') % name,
|
||||
'body_html': message + '<img src="data:image/jpeg;base64,%s"/>' % ticket,
|
||||
'body_html': message,
|
||||
'author_id': self.env.user.partner_id.id,
|
||||
'email_from': self.env.company.email or self.env.user.email_formatted,
|
||||
'email_to': client['email']
|
||||
'email_to': client['email'],
|
||||
'attachment_ids': [(4, receipt.id)],
|
||||
}
|
||||
|
||||
if self.mapped('account_move'):
|
||||
@@ -539,11 +550,11 @@ class PosOrder(models.Model):
|
||||
'type': 'binary',
|
||||
'datas': base64.b64encode(report[0]),
|
||||
'store_fname': filename,
|
||||
'res_model': 'account.move',
|
||||
'res_model': 'pos.order',
|
||||
'res_id': self.ids[0],
|
||||
'mimetype': 'application/x-pdf'
|
||||
})
|
||||
mail_values['attachment_ids'] = attachment
|
||||
mail_values['attachment_ids'] += [(4, attachment.id)]
|
||||
|
||||
mail = self.env['mail.mail'].create(mail_values)
|
||||
mail.send()
|
||||
|
||||
Reference in New Issue
Block a user