diff --git a/purchase.py b/purchase.py index 14cd897e57..c54eb5e33c 100644 --- a/purchase.py +++ b/purchase.py @@ -1,5 +1,7 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. +from decimal import Decimal + from trytond import backend from trytond.model import ModelSQL, ValueMixin, fields from trytond.pyson import Eval @@ -187,9 +189,15 @@ class PurchaseLine: return result def get_move(self, move_type): + pool = Pool() + Currency = pool.get('currency.currency') move = super(PurchaseLine, self).get_move(move_type) if move and self.purchase.customer: - move.cost_price = move.unit_price + digits = move.__class__.cost_price.digits + cost_price = Currency.compute( + move.currency, move.unit_price, move.company.currency) + move.cost_price = cost_price.quantize( + Decimal(str(10.0 ** -digits[1]))) return move diff --git a/tests/scenario_sale_supply_drop_shipment.rst b/tests/scenario_sale_supply_drop_shipment.rst index f44483fca9..50dd5b6beb 100644 --- a/tests/scenario_sale_supply_drop_shipment.rst +++ b/tests/scenario_sale_supply_drop_shipment.rst @@ -180,6 +180,8 @@ Receiving only 100 products:: >>> move.quantity = 100 >>> move.unit_price Decimal('3.0000') + >>> move.cost_price + Decimal('3.0000') >>> shipment.click('ship') >>> move, = shipment.customer_moves >>> move.unit_price