Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] 14.0 send receipt by email from pos #54

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pos_sale_order/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class SaleOrderPatched(models.Model):
SaleOrderPatched._payment_fields = PosOrder._payment_fields
SaleOrderPatched._get_valid_session = PosOrder._get_valid_session
SaleOrderPatched._process_payment_lines = PosOrder._process_payment_lines
SaleOrderPatched.action_receipt_to_customer = PosOrder.action_receipt_to_customer
SaleOrderPatched._prepare_mail_values = PosOrder._prepare_mail_values


class SaleOrder(models.Model):
Expand Down
33 changes: 33 additions & 0 deletions pos_sale_order/static/src/js/ReceiptScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
odoo.define("pos_sale_order.ReceiptScreen", function (require) {
"use strict";

const { Printer } = require('point_of_sale.Printer');
var ReceiptScreen = require("point_of_sale.ReceiptScreen");
var Registries = require("point_of_sale.Registries");

var PSOReceiptScreen = (ReceiptScreen) =>
class PSOReceiptScreen extends ReceiptScreen {
// copy entire function from odoo
// because there is no way to inherit it properly
async _sendReceiptToCustomer() {
const printer = new Printer(null, this.env.pos);
const receiptString = this.orderReceipt.comp.el.outerHTML;
const ticketImage = await printer.htmlToImg(receiptString);
const order = this.currentOrder;
const client = order.get_client();
const orderName = order.get_name();
const orderClient = { email: this.orderUiState.inputEmail, name: client ? client.name : this.orderUiState.inputEmail };
const order_server_id = this.env.pos.validated_orders_name_server_id_map[orderName];
await this.rpc({
// CHANGE: pos.order -> sale.order
model: 'sale.order',
// END CHANGE
method: 'action_receipt_to_customer',
args: [[order_server_id], orderName, orderClient, ticketImage],
});
}
};

Registries.Component.extend(ReceiptScreen, PSOReceiptScreen);
return PSOReceiptScreen;
});
4 changes: 4 additions & 0 deletions pos_sale_order/templates/assets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
type="text/javascript"
src="/pos_sale_order/static/src/js/SaleOrderButton.js"
/>
<script
type="text/javascript"
src="/pos_sale_order/static/src/js/ReceiptScreen.js"
/>
</xpath>
</template>

Expand Down