changeset 6f1155c28168 in modules/sale_supply_drop_shipment:5.2
details: 
https://hg.tryton.org/modules/sale_supply_drop_shipment?cmd=changeset;node=6f1155c28168
description:
        Convert unit price to company currency and default product uom

        issue9439
        review325641002
        (grafted from 7364619079a8277fabcd6ebe57200b8a7ea59b8b)
diffstat:

 stock.py |  14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diffs (31 lines):

diff -r 45d37ab10d1a -r 6f1155c28168 stock.py
--- a/stock.py  Wed Jun 03 22:19:53 2020 +0200
+++ b/stock.py  Fri Jul 03 21:19:53 2020 +0200
@@ -404,6 +404,7 @@
         pool = Pool()
         UoM = pool.get('product.uom')
         Move = pool.get('stock.move')
+        Currency = pool.get('currency.currency')
 
         to_save = []
         cost_exp = Decimal(str(10.0 ** -Move.cost_price.digits[1]))
@@ -422,10 +423,15 @@
             for s_move in shipment.supplier_moves:
                 if s_move.state == 'cancel':
                     continue
-                if s_move.cost_price:
-                    internal_quantity = Decimal(str(s_move.internal_quantity))
-                    product_cost[s_move.product] += (
-                        s_move.unit_price * internal_quantity)
+                internal_quantity = Decimal(str(s_move.internal_quantity))
+                with Transaction().set_context(date=s_move.effective_date):
+                    unit_price = Currency.compute(
+                        s_move.currency, s_move.unit_price,
+                        s_move.company.currency, round=False)
+                unit_price = UoM.compute_price(
+                    s_move.uom, unit_price, s_move.product.default_uom)
+                product_cost[s_move.product] += (
+                    unit_price * internal_quantity)
 
                 quantity = UoM.compute_qty(
                     s_move.uom, s_move.quantity, s_move.product.default_uom,

Reply via email to