From e141629a321da3fcc29c6d4293cf32a26838edb0 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_landed_cost_weight.rst | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/account.py b/account.py index d2997a1c33..1aef157211 100644 --- a/account.py +++ b/account.py @@ -14,11 +14,11 @@ class LandedCost(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_landed_cost_weight.rst b/tests/scenario_account_stock_landed_cost_weight.rst index 0d1fd6055b..70e45f2e0d 100644 --- a/tests/scenario_account_stock_landed_cost_weight.rst +++ b/tests/scenario_account_stock_landed_cost_weight.rst @@ -167,11 +167,16 @@ Add landed cost:: >>> landed_cost.save() >>> landed_cost.state 'draft' - >>> landed_cost.click('post') + >>> post_landed_cost = Wizard('account.landed_cost.post', [landed_cost]) + >>> post_landed_cost.form.cost + Decimal('30.0000') + >>> sorted([m.cost for m in post_landed_cost.form.moves]) + [Decimal('1.0000'), Decimal('2.0000')] + >>> post_landed_cost.execute('post') >>> landed_cost.state 'posted' -Check move unit price is 101:: +Check move unit price is 153:: >>> sorted([m.unit_price for m in shipment.incoming_moves]) [Decimal('51.0000'), Decimal('102.0000')]