[FIX] pos_Loyalty: remove loyalty program info

The loyalty details on the orders were not useful for the end user.
Now we delete it from the order widget. It also fits the sale behavior where we don't show those informaitons.

closes odoo/odoo#118789

Task-id: 2980232
X-original-commit: bafcda0e8c851fb66b0f6c6cb890cf0bdaad596d
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
This commit is contained in:
rhe-odoo
2023-04-21 09:48:41 +02:00
parent 7d2baaa0c7
commit a40039632c
4 changed files with 4 additions and 86 deletions
@@ -1,41 +0,0 @@
/** @odoo-module **/
import { OrderWidget } from "@point_of_sale/js/Screens/ProductScreen/OrderWidget";
import { patch } from "@web/core/utils/patch";
patch(OrderWidget.prototype, "pos_loyalty.OrderWidget", {
getActiveProgramsAndRewards() {
const order = this.env.pos.get_order();
const activePrograms = Object.values(order.couponPointChanges).map(
(pe) => this.env.pos.program_by_id[pe.program_id]
);
const seenRewards = new Set();
const activeRewards = [];
for (const line of order._get_reward_lines()) {
const key = line.reward_id + "-" + line.coupon_id + "-" + line.reward_identifier_code;
if (seenRewards.has(key)) {
continue;
}
seenRewards.add(key);
const dbCoupon = this.env.pos.couponCache[line.coupon_id];
const couponCode = dbCoupon ? dbCoupon.code : false;
activeRewards.push({
id: line.cid,
name: line.get_product().display_name,
code: couponCode,
});
}
const activeCoupons = order.codeActivatedCoupons.map((coupon) => {
const program = this.env.pos.program_by_id[coupon.program_id];
return {
programName: program.name,
code: coupon.code,
};
});
return {
activePrograms: [...new Set(activePrograms)],
activeCoupons,
activeRewards,
};
},
});
@@ -38,7 +38,7 @@ ProductScreen.exec.addOrderline("Desk Organizer", "9");
PosLoyalty.check.hasRewardLine("on the cheapest product", "-4.59");
PosLoyalty.exec.removeRewardLine("90% on the cheapest product");
PosLoyalty.check.orderTotalIs("45.90");
PosLoyalty.do.enterCode("invalid_code", false);
PosLoyalty.do.enterCode("invalid_code");
PosLoyalty.check.notificationMessageContains("invalid_code");
PosLoyalty.do.enterCode("1234");
PosLoyalty.check.hasRewardLine("Free Product - Desk Organizer", "-15.30");
@@ -67,7 +67,7 @@ ProductScreen.exec.addOrderline("Desk Organizer", "3"); // 5.1
ProductScreen.exec.addOrderline("Letter Tray", "4"); // 4.8 tax 10%
PosLoyalty.check.hasRewardLine("90% on the cheapest product", "-1.78");
PosLoyalty.check.orderTotalIs("54.44");
PosLoyalty.do.enterCode("promocode", false);
PosLoyalty.do.enterCode("promocode");
PosLoyalty.check.hasRewardLine("50% on specific products", "-16.66"); // 17.55 - 1.78*0.5
PosLoyalty.check.orderTotalIs("37.78");
PosLoyalty.exec.finalizeOrder("Cash", "50");
@@ -130,7 +130,7 @@ PosLoyalty.exec.finalizeOrder("Cash", "65");
ProductScreen.exec.addOrderline("Desk Organizer", "6"); // 5.1 per item
PosLoyalty.check.hasRewardLine("on the cheapest product", "-4.59");
PosLoyalty.exec.removeRewardLine("90% on the cheapest product");
PosLoyalty.do.enterCode("promocode", false);
PosLoyalty.do.enterCode("promocode");
PosLoyalty.check.hasRewardLine("50% on specific products", "-15.30");
PosLoyalty.do.enterCode("1357");
PosLoyalty.check.hasRewardLine("Free Product - Desk Organizer", "-10.20");
@@ -25,7 +25,7 @@ class Do {
},
];
}
enterCode(code, valid = true) {
enterCode(code) {
const steps = [
{
content: "open code input dialog",
@@ -41,13 +41,6 @@ class Do {
trigger: ".popup-textinput .button.confirm",
},
];
if (valid) {
steps.push({
content: "wait for the coupon to be loaded",
trigger: `.active-coupon:contains("(${code})")`,
run: () => {},
});
}
return steps;
}
resetActivePrograms() {
@@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="pos_coupon.OrderWidget" t-inherit="point_of_sale.OrderWidget" t-inherit-mode="extension" owl="1">
<xpath expr="//OrderSummary" position="after">
<t t-set="loyaltyData" t-value="getActiveProgramsAndRewards()"/>
<div class="active-programs">
<div t-if="loyaltyData.activePrograms.length">
<div class="title">Active Programs</div>
<t t-foreach="loyaltyData.activePrograms" t-as="program" t-key="program.id">
<div class="active-program">
<t t-esc="program.name"/>
</div>
</t>
</div>
<div t-if="loyaltyData.activeCoupons.length">
<div class="title">Active Coupons</div>
<t t-foreach="loyaltyData.activeCoupons" t-as="coupon" t-key="coupon.code">
<div class="active-coupon">
<t t-esc="coupon.programName"/> (<t t-esc="coupon.code"/>)
</div>
</t>
</div>
<div t-if="loyaltyData.activeRewards.length">
<div class="title">Active Rewards</div>
<t t-foreach="loyaltyData.activeRewards" t-as="reward" t-key="reward.id">
<div class="active-reward">
<t t-esc="reward.name"/>
</div>
</t>
</div>
</div>
</xpath>
</t>
</templates>