Skip to content

Commit

Permalink
[FIX] point_of_sale: restrict refund button until qty selected on tic…
Browse files Browse the repository at this point in the history
…ket screen

Before this commit:
===================
When clicking the refund button without selecting the quantity for the selected
order lines, the ticket screen would redirect to the product screen, resulting
in empty order lines.

After this commit:
The refund button will not redirect the ticket screen to the product screen
until a quantity is selected for the selected order line.

Task ID: 3922007
  • Loading branch information
jipr-odoo committed May 17, 2024
1 parent 9853435 commit 4403691
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<SelectPartnerButton partner="props.partner"/>
<button class="pay validation pay-order-button btn-primary"
t-attf-class="{{getMainButtonClasses()}}"
t-att-class="{ 'with-more-button': props.onClickMore and ui.isSmall }"
t-att-class="{'btn-secondary': !props.isActionButtonHighlighted, 'with-more-button': props.onClickMore and ui.isSmall}"
t-on-click="props.actionToTrigger ? this.props.actionToTrigger : () => pos.get_order().pay()">
<div class="pay-circle d-flex align-items-center justify-content-center py-2 mb-2">
<i class="oi oi-chevron-right" role="img" aria-label="Pay" title="Pay" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
partner="partner"
actionName="constructor.numpadActionName"
actionType="'payment'"
onClickMore.bind="displayAllControlPopup" />
onClickMore.bind="displayAllControlPopup"
isActionButtonHighlighted="items"/>
<Numpad buttons="getNumpadButtons()" onClick.bind="onNumpadClick"/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,12 @@ export class TicketScreen extends Component {
}
}

if (!order) {
this._state.ui.highlightHeaderNote = !this._state.ui.highlightHeaderNote;
if (!order || !this.getHasItemsToRefund()){
return;
}

const partner = order.get_partner();

const allToRefundDetails = this._getRefundableDetails(partner, order);

if (!allToRefundDetails) {
this._state.ui.highlightHeaderNote = !this._state.ui.highlightHeaderNote;
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.
Expand All @@ -287,7 +280,7 @@ export class TicketScreen extends Component {
: this._getEmptyOrder(partner);

// Add orderline for each toRefundDetail to the destinationOrder.
for (const refundDetail of allToRefundDetails) {
for (const refundDetail of this._getRefundableDetails(partner, order)) {
const product = this.pos.models["product.product"].get(
refundDetail.orderline.productId
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
<t t-set="_selectedSyncedOrder" t-value="getSelectedOrder()" />
<t t-set="_selectedOrderlineId" t-value="getSelectedOrderlineId()" />
<t t-if="_selectedSyncedOrder?.get_orderlines()?.length" >
<div t-if="isOrderSynced" t-att-class="{ 'highlight text-danger': _state.ui.highlightHeaderNote }" class="text-bg-view py-2 px-3 border-bottom" >
<div t-if="isOrderSynced" t-att-class="{ 'highlight text-danger': !getHasItemsToRefund() }" class="py-2 px-3 border-bottom" >
Select the product(s) to refund and set the quantity
</div>
<OrderWidget lines="_selectedSyncedOrder.orderlines" t-slot-scope="scope"
Expand Down
1 change: 0 additions & 1 deletion addons/point_of_sale/static/src/app/store/pos_store.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ export class PosStore extends Reactive {
filter: null,
// maps the order's backendId to it's selected orderline
selectedOrderlineIds: {},
highlightHeaderNote: false,
},
};

Expand Down

0 comments on commit 4403691

Please sign in to comment.