[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) <jcb@odoo.com>
Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
This commit is contained in:
Pedram (pebr)
2024-02-19 15:02:21 +00:00
parent 11ba706626
commit 494231e796
@@ -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;