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 20dd198836
commit e141629a32
2 changed files with 9 additions and 4 deletions
+2 -2
View File
@@ -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):
@@ -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')]