diff --git a/addons/point_of_sale/static/src/app/store/models.js b/addons/point_of_sale/static/src/app/store/models.js index 11be9528d41..4da50821fcf 100644 --- a/addons/point_of_sale/static/src/app/store/models.js +++ b/addons/point_of_sale/static/src/app/store/models.js @@ -1556,10 +1556,13 @@ export class Order extends PosModel { date: this.receiptDate, pos_qr_code: this.pos.company.point_of_sale_use_ticket_qr_code && + this.finalized && qrCodeSrc( `${this.pos.base_url}/pos/ticket/validate?access_token=${this.access_token}` ), - ticket_code: this.pos.company.point_of_sale_ticket_unique_code && this.ticketCode, + ticket_code: this.pos.company.point_of_sale_ticket_unique_code && + this.finalized && + this.ticketCode, base_url: this.pos.base_url, footer: this.pos.config.receipt_footer, // FIXME: isn't there a better way to handle this date? diff --git a/addons/point_of_sale/static/tests/tours/helpers/utils.js b/addons/point_of_sale/static/tests/tours/helpers/utils.js index 75f801317ea..7d7a8d9c990 100644 --- a/addons/point_of_sale/static/tests/tours/helpers/utils.js +++ b/addons/point_of_sale/static/tests/tours/helpers/utils.js @@ -19,3 +19,10 @@ export function inLeftSide(steps) { export function negate(selector) { return `body:not(:has(${selector}))`; } + +export function negateStep(step) { + return { + ...step, + trigger: negate(step.trigger), + }; +} diff --git a/addons/pos_restaurant/static/tests/tours/helpers/BillScreenTourMethods.js b/addons/pos_restaurant/static/tests/tours/helpers/BillScreenTourMethods.js index 06e551fad77..f89b5c4e7cf 100644 --- a/addons/pos_restaurant/static/tests/tours/helpers/BillScreenTourMethods.js +++ b/addons/pos_restaurant/static/tests/tours/helpers/BillScreenTourMethods.js @@ -18,3 +18,32 @@ export function isShown() { }, ]; } + +export function clickBillButton() { + return [ + { + content: "click review button", + trigger: ".btn-switchpane.review-button", + mobile: true, + }, + { + content: "click more button", + trigger: ".mobile-more-button", + mobile: true, + }, + { + content: "click bill button", + trigger: '.control-button:contains("Bill")', + }, + ]; +} + +export function isQRCodeShown() { + return [ + { + content: "QR codes are shown", + trigger: '#posqrcode', + run: () => {}, + }, + ]; +} diff --git a/addons/pos_restaurant/static/tests/tours/pos_restaurant.js b/addons/pos_restaurant/static/tests/tours/pos_restaurant.js index edcd2283099..28add4c40b9 100644 --- a/addons/pos_restaurant/static/tests/tours/pos_restaurant.js +++ b/addons/pos_restaurant/static/tests/tours/pos_restaurant.js @@ -1,5 +1,6 @@ /** @odoo-module */ +import * as BillScreen from "@pos_restaurant/../tests/tours/helpers/BillScreenTourMethods"; import * as PaymentScreen from "@point_of_sale/../tests/tours/helpers/PaymentScreenTourMethods"; import * as ReceiptScreen from "@point_of_sale/../tests/tours/helpers/ReceiptScreenTourMethods"; import * as Chrome from "@point_of_sale/../tests/tours/helpers/ChromeTourMethods"; @@ -8,7 +9,7 @@ import * as ProductScreenPos from "@point_of_sale/../tests/tours/helpers/Product import * as ProductScreenResto from "@pos_restaurant/../tests/tours/helpers/ProductScreenTourMethods"; import * as Order from "@point_of_sale/../tests/tours/helpers/generic_components/OrderWidgetMethods"; import * as TicketScreen from "@point_of_sale/../tests/tours/helpers/TicketScreenTourMethods"; -import { inLeftSide } from "@point_of_sale/../tests/tours/helpers/utils"; +import { inLeftSide, negateStep } from "@point_of_sale/../tests/tours/helpers/utils"; import { registry } from "@web/core/registry"; const ProductScreen = { ...ProductScreenPos, ...ProductScreenResto }; @@ -162,3 +163,19 @@ registry.category("web_tour.tours").add("SaveLastPreparationChangesTour", { ProductScreen.orderlinesHaveNoChange() ].flat(), }); + +registry.category("web_tour.tours").add("BillScreenTour", { + test: true, + steps: () => [ + ProductScreen.confirmOpeningPopup(), + FloorScreen.clickTable("5"), + ProductScreen.clickDisplayedProduct("Coca-Cola"), + BillScreen.clickBillButton(), + negateStep(BillScreen.isQRCodeShown()), + BillScreen.clickOk(), + ProductScreen.clickPayButton(), + PaymentScreen.clickPaymentMethod("Bank"), + PaymentScreen.clickValidate(), + BillScreen.isQRCodeShown(), + ].flat(), +}); diff --git a/addons/pos_restaurant/tests/test_frontend.py b/addons/pos_restaurant/tests/test_frontend.py index 2380b59fec3..ab24af45676 100644 --- a/addons/pos_restaurant/tests/test_frontend.py +++ b/addons/pos_restaurant/tests/test_frontend.py @@ -269,3 +269,8 @@ class TestFrontend(AccountTestInvoicingCommon, HttpCaseWithUserDemo): self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'SaveLastPreparationChangesTour', login="pos_admin") self.assertTrue(self.pos_config.current_session_id.order_ids.last_order_preparation_change, "There should be a last order preparation change") self.assertTrue("Coca" in self.pos_config.current_session_id.order_ids.last_order_preparation_change, "The last order preparation change should contain 'Coca'") + + def test_11_bill_screen_qrcode(self): + self.env.company.point_of_sale_use_ticket_qr_code = True + self.pos_config.with_user(self.pos_admin).open_ui() + self.start_tour("/pos/ui?config_id=%d" % self.pos_config.id, 'BillScreenTour', login="pos_admin")