changeset 2fea33dfe552 in modules/account_stock_landed_cost_weight:default
details:
https://hg.tryton.org/modules/account_stock_landed_cost_weight?cmd=changeset;node=2fea33dfe552
description:
Allow posted landed cost to be cancelled
issue9605
review319961002
diffstat:
account.py | 3 +++
tests/scenario_account_stock_landed_cost_weight.rst | 10 ++++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diffs (30 lines):
diff -r 6620f3f8ac58 -r 2fea33dfe552 account.py
--- a/account.py Thu Jul 09 10:21:06 2020 +0100
+++ b/account.py Sun Oct 11 13:37:32 2020 +0200
@@ -16,6 +16,9 @@
def allocate_cost_by_weight(self):
self._allocate_cost(self._get_weight_factors())
+ def unallocate_cost_by_weight(self):
+ self._allocate_cost(self._get_weight_factors(), sign=-1)
+
def _get_weight_factors(self):
"Return the factor for each move based on weight"
moves = [m for s in self.shipments for m in s.incoming_moves
diff -r 6620f3f8ac58 -r 2fea33dfe552
tests/scenario_account_stock_landed_cost_weight.rst
--- a/tests/scenario_account_stock_landed_cost_weight.rst Thu Jul 09
10:21:06 2020 +0100
+++ b/tests/scenario_account_stock_landed_cost_weight.rst Sun Oct 11
13:37:32 2020 +0200
@@ -175,3 +175,13 @@
>>> sorted([m.unit_price for m in shipment.incoming_moves])
[Decimal('51.0000'), Decimal('102.0000')]
+
+Cancel landed cost reset unit price::
+
+ >>> landed_cost.click('cancel')
+ >>> landed_cost.state
+ 'cancelled'
+
+ >>> shipment.reload()
+ >>> sorted([m.unit_price for m in shipment.incoming_moves])
+ [Decimal('50.0000'), Decimal('100.0000')]