changeset f4a92834bdb5 in modules/product_kit:default
details: 
https://hg.tryton.org/modules/product_kit?cmd=changeset&node=f4a92834bdb5
description:
        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
diffstat:

 stock.py                                |  5 +++--
 tests/scenario_product_kit_purchase.rst |  7 +++++++
 tests/scenario_product_kit_sale.rst     |  7 +++++++
 3 files changed, 17 insertions(+), 2 deletions(-)

diffs (52 lines):

diff -r 93a0aaa43ab8 -r f4a92834bdb5 stock.py
--- a/stock.py  Mon Sep 06 09:59:55 2021 +0200
+++ b/stock.py  Sat Oct 02 15:29:44 2021 +0200
@@ -22,11 +22,12 @@
                 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 -r 93a0aaa43ab8 -r f4a92834bdb5 tests/scenario_product_kit_purchase.rst
--- a/tests/scenario_product_kit_purchase.rst   Mon Sep 06 09:59:55 2021 +0200
+++ b/tests/scenario_product_kit_purchase.rst   Sat Oct 02 15:29:44 2021 +0200
@@ -248,6 +248,13 @@
     >>> 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 -r 93a0aaa43ab8 -r f4a92834bdb5 tests/scenario_product_kit_sale.rst
--- a/tests/scenario_product_kit_sale.rst       Mon Sep 06 09:59:55 2021 +0200
+++ b/tests/scenario_product_kit_sale.rst       Sat Oct 02 15:29:44 2021 +0200
@@ -231,6 +231,13 @@
     >>> 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

Reply via email to