[FIX] point_of_sale,pos_restaurant:save last preparation change on order

Current behavior:
Before this fix, when you sent the order to the kitchen, the preparation
changes were not saved directly. So if you refreshed the page right
after sending the order to the kitchen, the preparation changes were
lost.

Steps to reproduce:
- Open a POS restaurant session
- Add a product to the order
- Click on Order
- Refresh the page (F5)
- Go back to the table were you made the order
- The product still appears as not sent to the kitchen

opw-3614345

closes odoo/odoo#148755

X-original-commit: 8f33d6fa0261373fee276efd20dcbf75e95e1e28
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
Signed-off-by: Robin Engels (roen) <roen@odoo.com>
This commit is contained in:
roen-odoo
2024-01-10 18:25:12 +00:00
parent 13bb9c21ab
commit 40ee728812
3 changed files with 25 additions and 0 deletions
@@ -1715,6 +1715,11 @@ export class PosStore extends Reactive {
async sendOrderInPreparationUpdateLastChange(order, cancelled = false) {
await this.sendOrderInPreparation(order, cancelled);
order.updateLastOrderChange();
//We make sure that the last_order_change is updated in the backend
order.save_to_db();
order.pos.ordersToUpdateSet.add(this);
order.pos.sendDraftToServer();
}
closeScreen() {
this.addOrderIfEmpty();
@@ -142,3 +142,16 @@ registry.category("web_tour.tours").add("pos_restaurant_sync_second_login", {
FloorScreen.orderCountSyncedInTableIs("4", "1"),
].flat(),
});
registry.category("web_tour.tours").add("SaveLastPreparationChangesTour", {
test: true,
url: "/pos/ui",
steps: () => [
ProductScreen.confirmOpeningPopup(),
FloorScreen.clickTable("5"),
ProductScreen.clickDisplayedProduct("Coca-Cola"),
ProductScreen.selectedOrderlineHas("Coca-Cola", "1.0"),
ProductScreen.clickOrderButton(),
ProductScreen.orderlinesHaveNoChange()
].flat(),
});
@@ -262,3 +262,10 @@ class TestFrontend(AccountTestInvoicingCommon, HttpCaseWithUserDemo):
self.office_combo.write({'lst_price': 40})
self.pos_config.with_user(self.pos_admin).open_ui()
self.start_tour(f"/pos/ui?config_id={self.pos_config.id}", 'SplitBillScreenTour4PosCombo', login="pos_admin")
def test_10_save_last_preparation_changes(self):
self.pos_config.write({'printer_ids': False})
self.pos_config.with_user(self.pos_admin).open_ui()
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'")