changeset 7364619079a8 in modules/sale_supply_drop_shipment:default
details:
https://hg.tryton.org/modules/sale_supply_drop_shipment?cmd=changeset;node=7364619079a8
description:
Convert unit price to company currency and default product uom
issue9439
review325641002
diffstat:
stock.py | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diffs (31 lines):
diff -r dbe25b6e6fe4 -r 7364619079a8 stock.py
--- a/stock.py Sat Jun 06 10:30:11 2020 +0100
+++ b/stock.py Fri Jul 03 21:19:53 2020 +0200
@@ -408,6 +408,7 @@
pool = Pool()
UoM = pool.get('product.uom')
Move = pool.get('stock.move')
+ Currency = pool.get('currency.currency')
to_save = []
for shipment in shipments:
@@ -425,10 +426,15 @@
for s_move in shipment.supplier_moves:
if s_move.state == 'cancelled':
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,