summaryrefslogtreecommitdiff
path: root/addons/pos_restaurant/static/src/js
diff options
context:
space:
mode:
authorJoseph Caburnay <jcb@odoo.com>2020-06-22 09:44:36 +0000
committerJoseph Caburnay <jcb@odoo.com>2020-08-19 07:34:04 +0000
commit96e27f09006046aae75655386eddbca9feba31b5 (patch)
treede74d01572485c54b6f3de016ea0486729ddebcf /addons/pos_restaurant/static/src/js
parent18651864dd3bf27fd1c910888f5dbbed4046d42b (diff)
[FIX] point_of_sale,pos_*: indeterministic tour tests failures
closes odoo/odoo#56062 Related: odoo/enterprise#12487 Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
Diffstat (limited to 'addons/pos_restaurant/static/src/js')
-rw-r--r--addons/pos_restaurant/static/src/js/Screens/FloorScreen/FloorScreen.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/addons/pos_restaurant/static/src/js/Screens/FloorScreen/FloorScreen.js b/addons/pos_restaurant/static/src/js/Screens/FloorScreen/FloorScreen.js
index 587fe6e2d7c..87b599c9428 100644
--- a/addons/pos_restaurant/static/src/js/Screens/FloorScreen/FloorScreen.js
+++ b/addons/pos_restaurant/static/src/js/Screens/FloorScreen/FloorScreen.js
@@ -153,15 +153,24 @@ odoo.define('pos_restaurant.FloorScreen', function (require) {
});
if (!confirmed) return;
try {
+ const originalSelectedTableId = this.state.selectedTableId;
await this.rpc({
model: 'restaurant.table',
method: 'create_from_ui',
- args: [{ active: false, id: this.state.selectedTableId }],
+ args: [{ active: false, id: originalSelectedTableId }],
});
this.activeFloor.tables = this.activeTables.filter(
- (table) => table.id !== this.state.selectedTableId
+ (table) => table.id !== originalSelectedTableId
);
- this.state.selectedTableId = null;
+ // Value of an object can change inside async function call.
+ // Which means that in this code block, the value of `state.selectedTableId`
+ // before the await call can be different after the finishing the await call.
+ // Since we wanted to disable the selected table after deletion, we should be
+ // setting the selectedTableId to null. However, we only do this if nothing
+ // else is selected during the rpc call.
+ if (this.state.selectedTableId === originalSelectedTableId) {
+ this.state.selectedTableId = null;
+ }
} catch (error) {
if (error.message.code < 0) {
await this.showPopup('OfflineErrorPopup', {