[IMP] point_of_sale,pos_loyalty: gift card info notification empty cart

When a valid gift card is added in a empty cart, the pos will display a
notification of the resume of the gift card.

We also made the notification component to preserve white space.

Task-3265311

closes odoo/odoo#118609

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
This commit is contained in:
Loukas Wets (lowe)
2023-04-27 10:13:00 +02:00
committed by Joseph Caburnay
parent 1bbdd77f0e
commit cd65f8bdb2
2 changed files with 15 additions and 2 deletions
@@ -22,4 +22,8 @@
padding: 16px;
margin: .5rem;
font-size: 1rem;
span {
white-space: pre-line;
}
}
+11 -2
View File
@@ -7,6 +7,7 @@ import { roundDecimals, roundPrecision } from "@web/core/utils/numbers";
import { _t } from "@web/core/l10n/translation";
import { patch } from "@web/core/utils/patch";
import { ConfirmPopup } from "@point_of_sale/js/Popups/ConfirmPopup";
import { sprintf } from "@web/core/utils/strings";
// FIXME: Perhaps MutexedDropPrevious can be replaced by the new KeepLast.
// > This might require thorough investigation on how _updateRewards work.
@@ -1579,6 +1580,7 @@ patch(Order.prototype, "pos_loyalty.Order", {
return rule.mode === "with_code" && (rule.promo_barcode === code || rule.code === code);
});
let claimableRewards = null;
let coupon = null;
if (rule) {
if (this.codeActivatedProgramRules.includes(rule.id)) {
return _t("That promo code program has already been activated.");
@@ -1610,7 +1612,7 @@ patch(Order.prototype, "pos_loyalty.Order", {
return _t("Unpaid gift card rejected.");
}
}
const coupon = new PosLoyaltyCard(
coupon = new PosLoyaltyCard(
code,
payload.coupon_id,
payload.program_id,
@@ -1634,12 +1636,19 @@ patch(Order.prototype, "pos_loyalty.Order", {
this._updateRewards();
}
}
if (!rule && this.orderlines.length === 0 && coupon) {
return sprintf(
_t("Gift Card: %s\nBalance: %s"),
code,
this.pos.format_currency(coupon.balance)
);
}
return true;
},
async activateCode(code) {
const res = await this._activateCode(code);
if (res !== true) {
this.pos.env.services.pos_notification.add(res);
this.pos.env.services.pos_notification.add(res, 5000);
}
},
isProgramsResettable() {