changeset 9a6633f66c19 in modules/carrier_weight:default
details:
https://hg.tryton.org/modules/carrier_weight?cmd=changeset;node=9a6633f66c19
description:
Simplify manual alteration of shipment cost
issue10142
review340111002
diffstat:
stock.py | 10 ++++++++--
tests/scenario_carrier_weight.rst | 18 +++++++++++-------
2 files changed, 19 insertions(+), 9 deletions(-)
diffs (67 lines):
diff -r 720cf53c0c07 -r 9a6633f66c19 stock.py
--- a/stock.py Fri Mar 05 15:49:19 2021 +0100
+++ b/stock.py Sat Mar 13 23:43:51 2021 +0100
@@ -48,7 +48,9 @@
"""
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 @@
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 -r 720cf53c0c07 -r 9a6633f66c19 tests/scenario_carrier_weight.rst
--- a/tests/scenario_carrier_weight.rst Fri Mar 05 15:49:19 2021 +0100
+++ b/tests/scenario_carrier_weight.rst Sat Mar 13 23:43:51 2021 +0100
@@ -133,9 +133,9 @@
>>> 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 @@
>>> 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'