From a40039632c2194285adb641c3fdc82eec6b3c10a Mon Sep 17 00:00:00 2001 From: rhe-odoo Date: Wed, 5 Apr 2023 09:08:31 +0000 Subject: [PATCH] [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) --- .../pos_loyalty/static/src/js/OrderWidget.js | 41 ------------------- .../static/src/tours/PosLoyaltyTour.js | 6 +-- .../static/src/tours/PosLoyaltyTourMethods.js | 9 +--- .../static/src/xml/OrderWidget.xml | 34 --------------- 4 files changed, 4 insertions(+), 86 deletions(-) delete mode 100644 addons/pos_loyalty/static/src/js/OrderWidget.js delete mode 100644 addons/pos_loyalty/static/src/xml/OrderWidget.xml diff --git a/addons/pos_loyalty/static/src/js/OrderWidget.js b/addons/pos_loyalty/static/src/js/OrderWidget.js deleted file mode 100644 index bb5ef91ed2d..00000000000 --- a/addons/pos_loyalty/static/src/js/OrderWidget.js +++ /dev/null @@ -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, - }; - }, -}); diff --git a/addons/pos_loyalty/static/src/tours/PosLoyaltyTour.js b/addons/pos_loyalty/static/src/tours/PosLoyaltyTour.js index df1ce6de2df..970fc997544 100644 --- a/addons/pos_loyalty/static/src/tours/PosLoyaltyTour.js +++ b/addons/pos_loyalty/static/src/tours/PosLoyaltyTour.js @@ -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"); diff --git a/addons/pos_loyalty/static/src/tours/PosLoyaltyTourMethods.js b/addons/pos_loyalty/static/src/tours/PosLoyaltyTourMethods.js index f5a591ed9c3..f8363500e91 100644 --- a/addons/pos_loyalty/static/src/tours/PosLoyaltyTourMethods.js +++ b/addons/pos_loyalty/static/src/tours/PosLoyaltyTourMethods.js @@ -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() { diff --git a/addons/pos_loyalty/static/src/xml/OrderWidget.xml b/addons/pos_loyalty/static/src/xml/OrderWidget.xml deleted file mode 100644 index eb1b3d95ae1..00000000000 --- a/addons/pos_loyalty/static/src/xml/OrderWidget.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - -
-
-
Active Programs
- -
- -
-
-
-
-
Active Coupons
- -
- () -
-
-
-
-
Active Rewards
- -
- -
-
-
-
-
-
-