diff --git a/stock.py b/stock.py index 08046f25ee..3d3324eb32 100644 --- a/stock.py +++ b/stock.py @@ -48,7 +48,9 @@ class ShipmentOut(metaclass=PoolMeta): """ return () - @fields.depends('carrier', 'inventory_moves', + @fields.depends( + 'state', 'carrier', 'inventory_moves', 'outgoing_moves', + 'warehouse_storage', 'warehouse_output', methods=['_group_parcel_key']) def _get_carrier_context(self): context = super(ShipmentOut, self)._get_carrier_context() @@ -59,7 +61,11 @@ class ShipmentOut(metaclass=PoolMeta): weights = [] context['weights'] = weights - lines = self.inventory_moves or [] + if (self.state in {'draft', 'waiting', 'assigned'} + and self.warehouse_storage != self.warehouse_output): + lines = self.inventory_moves or [] + else: + lines = self.outgoing_moves or [] keyfunc = partial(self._group_parcel_key, lines) lines = sorted(lines, key=sortable_values(keyfunc)) diff --git a/tests/scenario_carrier_weight.rst b/tests/scenario_carrier_weight.rst index 3ee415e069..be3d3a963d 100644 --- a/tests/scenario_carrier_weight.rst +++ b/tests/scenario_carrier_weight.rst @@ -133,9 +133,9 @@ Receive a single product line:: >>> move.quantity = 4 >>> move.unit_price = Decimal('8') >>> shipment.carrier = carrier - >>> shipment.cost - Decimal('25') - >>> shipment.cost_currency == company.currency + >>> shipment.cost_used + Decimal('25.0000') + >>> shipment.cost_currency_used == company.currency True >>> shipment.click('receive') >>> shipment.state @@ -188,15 +188,19 @@ Send products:: >>> shipment, = sale.shipments >>> shipment.carrier == carrier True - >>> shipment.cost + >>> shipment.cost_used Decimal('40.0000') - >>> shipment.cost_currency == company.currency + >>> shipment.cost_sale_used + Decimal('40.0000') + >>> shipment.cost_sale_currency_used == company.currency True >>> move = shipment.inventory_moves[0] >>> move.quantity -= 1 - >>> shipment.cost + >>> shipment.cost_used Decimal('25.0000') - >>> shipment.cost_currency == company.currency + >>> shipment.cost_sale_used + Decimal('25.0000') + >>> shipment.cost_sale_currency_used == company.currency True >>> shipment.state 'waiting'