From e43ac132aa7743947ecf0dacb97c3cf1036726c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 27 Jun 2017 12:44:17 +0200 Subject: [PATCH] Use not grouped shipment to search grouped shipment issue6580 review34201002 --- sale.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sale.py b/sale.py index 07bbe57016..0b96f85ea4 100644 --- a/sale.py +++ b/sale.py @@ -2,6 +2,7 @@ # this repository contains the full copyright notices and license terms. from trytond.pool import PoolMeta +from trytond.transaction import Transaction __all__ = ['Sale'] @@ -41,9 +42,14 @@ class Sale: return shipment_domain def _get_shipment_sale(self, shipment_type, values): + transaction = Transaction() + context = transaction.context shipment = super(Sale, self)._get_shipment_sale(shipment_type, values) - Shipment = shipment.__class__ - if self.shipment_grouping_method: + if (not context.get('skip_grouping', False) + and self.shipment_grouping_method): + with transaction.set_context(skip_grouping=True): + shipment = self._get_shipment_sale(shipment_type, values) + Shipment = shipment.__class__ domain = self._get_grouped_shipment_domain(shipment) order = self._get_grouped_shipment_order() grouped_shipments = Shipment.search(domain, order=order, limit=1)