[FIX] point_of_sale: make sure to print changes before saving them

Current behavior:
When trying to print the changes of an order, nothing was printed.
This was happening because we were first saving the changes before
sending them to the printer. Because of this when we tried to retrieve
the changes to print them, they were already saved and we were not
retrieving anything.

Steps to reproduce:
- Setup a printer to print order changes
- Create a new order in PoS restaurant
- Add a product to the order
- Click on the "Order" button
- Nothing is printed

opw-3625397

closes odoo/odoo#146461

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
This commit is contained in:
roen-odoo
2023-12-22 13:31:39 +00:00
parent 5daf8f145d
commit 09c1545412
5 changed files with 7 additions and 4 deletions
@@ -34,7 +34,7 @@ export class ReceiptScreen extends Component {
// to send in preparation it is automatically sent
if (this.pos.orderPreparationCategories.size) {
try {
await this.pos.sendOrderInPreparation(this.currentOrder);
await this.pos.sendOrderInPreparationUpdateLastChange(this.currentOrder);
} catch (error) {
Promise.reject(error);
}
@@ -155,7 +155,7 @@ export class TicketScreen extends Component {
}
if (order && (await this._onBeforeDeleteOrder(order))) {
if (Object.keys(order.lastOrderPrepaChange).length > 0) {
await this.pos.sendOrderInPreparation(order, true);
await this.pos.sendOrderInPreparationUpdateLastChange(order, true);
}
if (order === this.pos.get_order()) {
this._selectNextOrder(order);
@@ -1711,6 +1711,9 @@ export class PosStore extends Reactive {
console.warn("Failed in printing the changes in the order", e);
}
}
}
async sendOrderInPreparationUpdateLastChange(order, cancelled = false) {
await this.sendOrderInPreparation(order, cancelled);
order.updateLastOrderChange();
}
closeScreen() {
@@ -23,7 +23,7 @@ patch(ActionpadWidget.prototype, {
if (!this.clicked) {
this.clicked = true;
try {
await this.pos.sendOrderInPreparation(this.currentOrder);
await this.pos.sendOrderInPreparationUpdateLastChange(this.currentOrder);
} finally {
this.clicked = false;
}
@@ -34,7 +34,7 @@ patch(ProductScreen.prototype, {
return this.pos.config.module_pos_restaurant && this.pos.orderPreparationCategories.size;
},
submitOrder() {
this.pos.sendOrderInPreparation(this.pos.get_order());
this.pos.sendOrderInPreparationUpdateLastChange(this.pos.get_order());
},
get primaryReviewButton() {
return (