[FIX] point_of_sale,pos_restaurant: show qrcode when order is paid

Current behavior:
When printing the bill before the order has been paid, the QRCode to get
the invoice shouldn't be shown.

Steps to reproduce:
- Activate the option "Show QR Code" in the POS settings
- Create a new order
- Add some products
- Click on "Bill" button
- The QRCode is shown

opw-3703720

closes odoo/odoo#152918

Signed-off-by: Robin Engels (roen) <roen@odoo.com>
This commit is contained in:
roen-odoo
2024-02-13 10:07:52 +00:00
parent 55d51b0882
commit 4c68472e3c
5 changed files with 63 additions and 2 deletions
@@ -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?
@@ -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),
};
}
@@ -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: () => {},
},
];
}
@@ -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(),
});
@@ -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")