[FIX] point_of_sale: delete validated orders immediately from db

If you validate an order it will be sent to the backend. If you then
close the POS frontend somehow before clicking 'Next order' this order
will be reloaded from localStorage when reopening it. This is
problematic because it allows the user to then modify this order and
validate it again. Everything will appear fine but in the backend this
new, modified order will be ignored as it has the same pos_reference as
the one that was sent initially.

The deeper underlying issue is that there exists a brief timeframe where
the same order can exist twice in the db: both as 'order' and
'unpaid_order'. To ensure this does not happen this fix removes the
order from the unpaid orders after it is saved as a validated order.

Fixes #13538
This commit is contained in:
Joren Van Onder
2016-10-18 16:56:46 -07:00
parent fa50349d7e
commit 8e720a9319
+4
View File
@@ -412,6 +412,10 @@ openerp.point_of_sale.load_db = function load_db(instance, module){
}
}
// Only necessary when we store a new, validated order. Orders
// that where already stored should already have been removed.
this.remove_unpaid_order(order);
orders.push({id: order_id, data: order});
this.save('orders',orders);
return order_id;