[IMP] point_of_sale: Improve the flow of emailing gift cards

The process of emailing _gift cards_ bought from the Point of Sale is rather confusing.
This PR makes the experience more intuitive.

closes odoo/odoo#123222

Task: 2711714
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
This commit is contained in:
vlst
2023-06-08 13:10:09 +02:00
parent 9aa5d76938
commit 9eb008dd77
5 changed files with 17 additions and 5 deletions
@@ -54,6 +54,7 @@ export class ReceiptScreen extends AbstractReceiptScreen {
}
});
}
_addNewOrder() {
this.pos.globalState.add_new_order();
}
@@ -13,7 +13,7 @@
</div>
<div class="default-view">
<div class="actions">
<h1>How would you like to receive your receipt<t t-if="currentOrder.is_to_invoice()"> &amp; invoice</t>?</h1>
<h1>Payment Successful</h1>
<div class="buttons">
<div class="button print" t-on-click="printReceipt">
<i class="fa fa-print" t-ref="order-print-receipt-button"></i> Print Receipt
@@ -21,7 +21,7 @@
</div>
<form t-on-submit.prevent="onSendEmail" class="send-email">
<div class="input-email">
<input type="email" placeholder="Send receipt by email" t-model="orderUiState.inputEmail" />
<input type="email" t-attf-placeholder="Email: {{currentOrder.getEmailItems().join(', ')}}" t-model="orderUiState.inputEmail" />
<button class="send" t-att-class="{ highlight: isValidEmail() }" type="submit">
<i class="fa fa-paper-plane" aria-hidden="true" t-ref="order-mail-receipt-button" />
</button>
@@ -31,9 +31,6 @@
<div t-if="orderUiState.emailSuccessful !== null" t-attf-class="{{ orderUiState.emailSuccessful ? 'successful' : 'failed' }}">
<t t-esc="orderUiState.emailNotice"></t>
</div>
<div class="send-mail-info" t-if="currentOrder.is_to_invoice()">
(Both will be sent by email)
</div>
</div>
</div>
<div class="pos-receipt-container" t-ref="order-receipt">
@@ -2775,6 +2775,11 @@ export class Order extends PosModel {
this.lastOrderPrepaChange = this.lastOrderPrepaChange || {};
}
getEmailItems() {
return [_t("the receipt")].concat(this.is_to_invoice() ? [_t("the invoice")] : []);
}
save_to_db() {
if (!this.temporary && !this.locked && !this.finalized) {
this.assert_editable();
@@ -347,6 +347,14 @@ patch(Order.prototype, "pos_loyalty.Order", {
// order is properly assigned. @see _checkMissingCoupons
this.invalidCoupons = true;
},
/** @override */
getEmailItems() {
return this._super(...arguments).concat(
this.has_pdf_gift_card ? [_t("the gift cards")] : []
);
},
export_as_JSON() {
const json = this._super(...arguments);
json.disabledRewards = [...this.disabledRewards];
@@ -159,6 +159,7 @@ patch(PaymentScreen.prototype, "pos_loyalty.PaymentScreen", {
for (const [actionId, active_ids] of Object.entries(payload.coupon_report)) {
await this.report.download(actionId, active_ids);
}
order.has_pdf_gift_card = Object.keys(payload.coupon_report).length > 0;
}
order.new_coupon_info = payload.new_coupon_info;
}