[FIX] point_of_sale: index error when send receipt to customer in offline
An IndexError "list index out of range" trace back that occurs in point_of_sale /RecieptScreen :async _sendReceiptToCustomer was caught by sentry. order_server_id is undefined because it is not properly sync with the server step to reproduce: 1. First of all start the session in point_of_sale to produce error we have to be in offline mode and generate product order. 2. Add customer, select a payment method and validate. 3. After validation send email to customer(failed to send mail. because we are in offline mode and order_server_id is undefined ) 4. Now get back to online mode and again send mail to customer 5. This time an IndexError 'list index out of range' is trace-backed. So if order_server_id is null then we throw error to user. sentry-3824163568 closes odoo/odoo#113017 X-original-commit: f7aa70bc0909bea04d6a5c251f966e03ffd44288 Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
This commit is contained in:
@@ -6552,6 +6552,13 @@ msgstr ""
|
||||
|
||||
#. module: point_of_sale
|
||||
#. odoo-python
|
||||
#. openerp-web
|
||||
#: code:addons/point_of_sale/static/src/js/Screens/ReceiptScreen/ReceiptScreen.js:0
|
||||
#, python-format
|
||||
msgid "This order is not yet synced to server. Make sure it is synced then try again."
|
||||
msgstr ""
|
||||
|
||||
#. module: point_of_sale
|
||||
#: code:addons/point_of_sale/models/pos_session.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
@@ -6687,6 +6694,9 @@ msgstr ""
|
||||
#: code:addons/point_of_sale/static/src/xml/Popups/CashMoveReceipt.xml:0
|
||||
#, python-format
|
||||
msgid "VAT:"
|
||||
#: code:addons/point_of_sale/static/src/js/Screens/ReceiptScreen/ReceiptScreen.js:0
|
||||
#, python-format
|
||||
msgid "Unsynced order"
|
||||
msgstr ""
|
||||
|
||||
#. module: point_of_sale
|
||||
|
||||
@@ -4,10 +4,9 @@ import { Printer } from "@point_of_sale/js/printers";
|
||||
import { is_email } from "web.utils";
|
||||
import { useErrorHandlers } from "@point_of_sale/js/custom_hooks";
|
||||
import { AbstractReceiptScreen } from "@point_of_sale/js/Misc/AbstractReceiptScreen";
|
||||
import { OfflineErrorPopup } from "@point_of_sale/js/Popups/OfflineErrorPopup";
|
||||
import { registry } from "@web/core/registry";
|
||||
|
||||
import { OrderReceipt } from "./OrderReceipt";
|
||||
|
||||
import { onMounted, useRef, status } from "@odoo/owl";
|
||||
import { usePos } from "@point_of_sale/app/pos_hook";
|
||||
|
||||
@@ -137,6 +136,15 @@ export class ReceiptScreen extends AbstractReceiptScreen {
|
||||
name: partner ? partner.name : this.orderUiState.inputEmail,
|
||||
};
|
||||
const order_server_id = this.env.pos.validated_orders_name_server_id_map[orderName];
|
||||
if (!order_server_id) {
|
||||
this.popup.add(OfflineErrorPopup, {
|
||||
title: this.env._t("Unsynced order"),
|
||||
body: this.env._t(
|
||||
"This order is not yet synced to server. Make sure it is synced then try again."
|
||||
),
|
||||
});
|
||||
return Promise.reject();
|
||||
}
|
||||
await this.rpc({
|
||||
model: "pos.order",
|
||||
method: "action_receipt_to_customer",
|
||||
|
||||
Reference in New Issue
Block a user