Show cost allocation before and after posting

issue11558
review413301003
This commit is contained in:
Cédric Krier
2022-07-18 00:16:26 +02:00
parent c4e650df53
commit 42af4bb7ae
2 changed files with 8 additions and 3 deletions
+2 -2
View File
@@ -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):
@@ -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)