Convert invoiced quantity into the order line unit
And only after applying the price ratio, we can convert from the price from the component unit to the move unit. issue10800 review375611002
This commit is contained in:
@@ -22,11 +22,12 @@ class Move(metaclass=PoolMeta):
|
||||
with Transaction().set_context(date=self.effective_date):
|
||||
amount += Currency.compute(
|
||||
line.invoice.currency, line.amount, self.currency)
|
||||
quantity = UoM.compute_qty(
|
||||
line.unit, line.quantity, self.uom)
|
||||
quantity += UoM.compute_qty(
|
||||
line.unit, line.quantity, self.origin.line.unit)
|
||||
amount *= self.origin.price_ratio
|
||||
if quantity:
|
||||
unit_price = round_price(amount / Decimal(str(quantity)))
|
||||
unit_price = UoM.compute_price(self.origin.unit, unit_price, self.uom)
|
||||
return unit_price
|
||||
|
||||
|
||||
|
||||
@@ -248,6 +248,13 @@ Post invoice::
|
||||
>>> invoice.state
|
||||
'posted'
|
||||
|
||||
Check unit price of moves::
|
||||
|
||||
>>> shipment.reload()
|
||||
>>> invoice.reload()
|
||||
>>> sorted([m.unit_price for m in shipment.incoming_moves])
|
||||
[Decimal('5.0000'), Decimal('5.0000'), Decimal('7.0909'), Decimal('18.9091')]
|
||||
|
||||
Check backorder moves::
|
||||
|
||||
>>> len(purchase.moves)
|
||||
|
||||
@@ -231,6 +231,13 @@ Post invoice::
|
||||
>>> invoice.state
|
||||
'posted'
|
||||
|
||||
Check unit price of moves::
|
||||
|
||||
>>> shipment.reload()
|
||||
>>> invoice.reload()
|
||||
>>> sorted([m.unit_price for m in shipment.outgoing_moves])
|
||||
[Decimal('10.0000'), Decimal('10.0000'), Decimal('15.0000'), Decimal('25.0000')]
|
||||
|
||||
Check backorder::
|
||||
|
||||
>>> _, backorder = sale.shipments
|
||||
|
||||
Reference in New Issue
Block a user