Skip to Content
Menu
This question has been flagged
1 Reply
136 Views

I'm using odoo18 . In my custom pos module when call api canceled the order. The order state is cancel in database. But the pos ui when select tickets the order still paid . After refresh the data it's gone.

Thanks for help!


My code:

await this.pos.data.call(
'pos.order',
'cancel_payment',
[[this.currentOrder.id]],
);
const updatedOrders = await this.pos.data.searchRead("pos.order", [["id", "=", this.currentOrder.id]]);
if (updatedOrders.length > 0) {
const serverOrder = updatedOrders[0];
let order = this.pos.models["pos.order"].get(this.currentOrder.id);
order.state = serverOrder.state;
order.is_paying = false;
order.setScreenData({name: ""});
order.uiState.locked = true;
// I'm using this to update local order state , this not working.
this.pos.models["pos.order"].update(order, {'state': order.state});
}
// To new order
if (!this.pos.config.module_pos_restaurant) {
this.pos.selectedOrderUuid = this.pos.getEmptyOrder().uuid;
}
this.pos.searchProductWord = "";
const nextPage = this.pos.defaultPage;
this.pos.navigate(nextPage.page, nextPage.params);
Avatar
Discard
Best Answer

Hi,


Try the following,

1- After canceling the order via API, trigger a full re-fetch of POS orders using the built-in POS data loader:


await this.pos.loadNewOrders();

this.pos.showScreen("TicketScreen");


This ensures the local cache is fully updated.


2- Alternatively, remove the canceled order from the frontend manually:


this.pos.models["pos.order"].remove(this.currentOrder.id);

this.pos.showScreen("TicketScreen");


3- Avoid manually patching order.state unless you also handle re-render logic — the POS frontend isn’t reactive like Odoo web views.


In short, the issue isn’t with your backend logic but with the POS frontend not refreshing its in-memory order list. The clean solution is to reload or remove the order in the POS UI after the cancellation API call, ensuring the interface matches the database state instantly.



Hope it helps

Avatar
Discard
Related Posts Replies Views Activity
3
Apr 25
1809
1
Aug 24
2885
3
May 24
12830
1
Sep 23
4504
0
Aug 23
2381