[FIX] pos_restaurant: sync empty orders

* In a pos-session with table management create a new order with products
and go back to the floor-plan.
* The order is sinced to the back-end.
* Open the table again, remove all products but keep the order.
* Go back to floorplan to trigger syncing again.
* Open the table again.

behaviour before fix:
* The empty order is not loaded in the frontend anymore.
* To close the session the order has to be manually removed in the backend.

After fix:
* The order is still visible in the frontend and can be removed or finalysed as expected.

closes odoo/odoo#40165

X-original-commit: 3add8dd226f39d5166873a575b858694eeb2e6ee
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Gert Pellin
2019-11-13 08:50:57 +00:00
committed by fw-bot
parent 72fd12e4ae
commit a1839fb305
2 changed files with 29 additions and 5 deletions
@@ -959,11 +959,9 @@ models.PosModel = models.PosModel.extend({
}
});
server_orders.forEach(function(server_order){
if (server_order.lines.length){
var new_order = new models.Order({},{pos: self, json: server_order});
self.get("orders").add(new_order);
new_order.save_to_db();
}
var new_order = new models.Order({},{pos: self, json: server_order});
self.get("orders").add(new_order);
new_order.save_to_db();
})
if (!ids_to_remove.length) {
self.set_synch('connected');
@@ -201,6 +201,32 @@ odoo.define('pos_reataurant.tour.synchronized_table_management', function (requi
// Test transfering an empty order
steps = steps.concat(transfer_order_to_table('T4', '2'));
steps = steps.concat(add_product_to_order('Coca-Cola'));
steps = steps.concat(verify_order_total('2.20'));
// Take a synced order with products, remove the products
// and check if the order is still available in the front-end
steps = steps.concat([{
content: 'back to floor',
trigger: '.floor-button',
run: 'click',
}]);
steps = steps.concat(open_table('T4', 1));
steps = steps.concat([{
content: 'click backspace to set quantity to 0',
trigger: '.numpad-backspace',
run: 'click',
}, {
content: 'click backspace to remove line',
trigger: '.numpad-backspace',
run: 'click',
}]);
steps = steps.concat([{
content: 'back to floor',
trigger: '.floor-button',
run: 'click',
}]);
steps = steps.concat(open_table('T4', 1));
steps = steps.concat(add_product_to_order('Coca-Cola'));
steps = steps.concat(verify_order_total('2.20'));
steps = steps.concat([{