diff --git a/stock.py b/stock.py index a309ef46a4..db7948e235 100644 --- a/stock.py +++ b/stock.py @@ -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 diff --git a/tests/scenario_product_kit_purchase.rst b/tests/scenario_product_kit_purchase.rst index 1709c4f403..27c4db88f8 100644 --- a/tests/scenario_product_kit_purchase.rst +++ b/tests/scenario_product_kit_purchase.rst @@ -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) diff --git a/tests/scenario_product_kit_sale.rst b/tests/scenario_product_kit_sale.rst index 04f1d3efe7..6477d41153 100644 --- a/tests/scenario_product_kit_sale.rst +++ b/tests/scenario_product_kit_sale.rst @@ -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