From 42af4bb7aeb6b04e12e240c592d8b78a8efb3756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 18 Jul 2022 00:16:26 +0200 Subject: [PATCH] Show cost allocation before and after posting issue11558 review413301003 --- account.py | 4 ++-- tests/scenario_account_stock_shipment_cost_weight.rst | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/account.py b/account.py index 5b3488d1f6..8d60359ec6 100644 --- a/account.py +++ b/account.py @@ -14,11 +14,11 @@ class ShipmentCost(metaclass=PoolMeta): cls.allocation_method.selection.append(('weight', "By Weight")) def allocate_cost_by_weight(self): - self.factors = self._get_weight_factors() + self.factors = self._get_factors('weight') self._allocate_cost(self.factors) def unallocate_cost_by_weight(self): - factors = self.factors or self._get_weight_factors() + factors = self.factors or self._get_factors('weight') self._allocate_cost(factors, sign=-1) def _get_weight_factors(self): diff --git a/tests/scenario_account_stock_shipment_cost_weight.rst b/tests/scenario_account_stock_shipment_cost_weight.rst index f7f535708a..54b89f5056 100644 --- a/tests/scenario_account_stock_shipment_cost_weight.rst +++ b/tests/scenario_account_stock_shipment_cost_weight.rst @@ -149,7 +149,12 @@ Add shipment cost to both shipments:: >>> shipment_cost.save() >>> shipment_cost.state 'draft' - >>> shipment_cost.click('post') + >>> post_shipment_cost = Wizard('account.shipment_cost.post', [shipment_cost]) + >>> post_shipment_cost.form.cost + Decimal('20.0000') + >>> sorted([s.cost for s in post_shipment_cost.form.shipments]) + [Decimal('5.0000'), Decimal('15.0000')] + >>> post_shipment_cost.execute('post') >>> shipment_cost.state 'posted' >>> bool(shipment_cost.posted_date)