From 494231e796b562162d3bfb19fc8ce7550657cf07 Mon Sep 17 00:00:00 2001 From: "Pedram (pebr)" Date: Mon, 12 Feb 2024 15:30:09 +0000 Subject: [PATCH] [FIX] point_of_sale: disallow refunds from multiple invoiced orders Before this commit, users could create a refund order from multiple invoiced orders. However, such an order could not be invoiced as it was associated with more than one account_move, leading to a failure. This commit fixes this issue by preventing users from creating a refund order from multiple invoiced orders. opw-3710539 closes odoo/odoo#154369 X-original-commit: 177b0378d046ac769f2349c6444d14ca280e3c77 Signed-off-by: Joseph Caburnay (jcb) Signed-off-by: Pedram Bi Ria (pebr) --- .../app/screens/ticket_screen/ticket_screen.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/static/src/app/screens/ticket_screen/ticket_screen.js b/addons/point_of_sale/static/src/app/screens/ticket_screen/ticket_screen.js index b6236e36f38..ef4c79b63ea 100644 --- a/addons/point_of_sale/static/src/app/screens/ticket_screen/ticket_screen.js +++ b/addons/point_of_sale/static/src/app/screens/ticket_screen/ticket_screen.js @@ -274,6 +274,20 @@ export class TicketScreen extends Component { return; } + const invoicedOrderIds = new Set( + allToRefundDetails + .filter(detail => this._state.syncedOrders.cache[detail.orderline.orderBackendId].state === "invoiced") + .map(detail => detail.orderline.orderBackendId) + ); + + if (invoicedOrderIds.size > 1) { + this.popup.add(ErrorPopup, { + title: _t('Multiple Invoiced Orders Selected'), + body: _t('You have selected orderlines from multiple invoiced orders. To proceed refund, please select orderlines from the same invoiced order.') + }); + return; + } + // The order that will contain the refund orderlines. // Use the destinationOrder from props if the order to refund has the same // partner as the destinationOrder. @@ -391,7 +405,7 @@ export class TicketScreen extends Component { } getStatus(order) { if (order.locked) { - return _t("Paid"); + return order.state === 'invoiced' ? _t('Invoiced') : _t("Paid"); } else { const screen = order.get_screen_data(); return this._getOrderStates().get(this._getScreenToStatusMap()[screen.name]).text;