diff options
| author | Pierre Masereel <pim@odoo.com> | 2019-11-21 09:25:17 +0000 |
|---|---|---|
| committer | Pierre Masereel <pim@odoo.com> | 2019-11-21 13:40:18 +0000 |
| commit | 1bfcbe4b3c80fcdca3ca148e0d9685e3e723e7eb (patch) | |
| tree | fb8a96f9ccefd2dd407afa1e213c95a97d38121a /addons/point_of_sale/models/pos_order.py | |
| parent | 5a72faf721505ca61faecf8bbe79e1260e62a95b (diff) | |
[FIX] point_of_sale: duplicate orders
When you create a pos order, it is possible that the request timeout or
the client loose the connection with the server, that will lead to not
have the server_id of the order sent to the server. So when the client
will try to synchronize the order again, it'll not send the server_id to
the server, and the server will create a new order which is a duplicate
of the one created when the client lost the connection.
To avoid this duplication, we are using the pos_reference to find if
there is an existing order like in 12.0 to avoid duplication.
closes odoo/odoo#40837
Task-id: 2127656
X-original-commit: cddf29e70008dc1fcb6ec41b4dfc739d4d06cf6d
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Diffstat (limited to 'addons/point_of_sale/models/pos_order.py')
| -rw-r--r-- | addons/point_of_sale/models/pos_order.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index 472c9fb802b..22d924dcfc6 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -435,8 +435,9 @@ class PosOrder(models.Model): for order in orders: existing_order = False if 'server_id' in order['data']: - existing_order = self.env['pos.order'].search([('id', '=', order['data']['server_id'])], limit=1) - order_ids.append(self._process_order(order, draft, existing_order)) + existing_order = self.env['pos.order'].search(['|', ('id', '=', order['data']['server_id']), ('pos_reference', '=', order['data']['name'])], limit=1) + if (existing_order and existing_order.state == 'draft') or not existing_order: + order_ids.append(self._process_order(order, draft, existing_order)) return self.env['pos.order'].search_read(domain = [('id', 'in', order_ids)], fields = ['id', 'pos_reference']) |
