diff --git a/purchase.py b/purchase.py index 83d05f8ca4..470793bea8 100644 --- a/purchase.py +++ b/purchase.py @@ -1,7 +1,5 @@ # 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.i18n import gettext from trytond.model import ModelSQL, ValueMixin, fields @@ -11,6 +9,7 @@ from trytond.pool import Pool, PoolMeta from trytond.transaction import Transaction from trytond.tools.multivalue import migrate_property +from trytond.modules.product import round_price from trytond.modules.purchase.purchase import ( get_shipments_returns, search_shipments_returns) @@ -181,11 +180,9 @@ class Line(metaclass=PoolMeta): Currency = pool.get('currency.currency') move = super().get_move(move_type) if move and self.purchase.customer: - 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]))) + move.cost_price = round_price(cost_price) return move diff --git a/stock.py b/stock.py index 53dae3b76a..891753a890 100644 --- a/stock.py +++ b/stock.py @@ -17,6 +17,7 @@ from trytond.transaction import Transaction from trytond.tools import grouped_slice, cursor_dict from trytond.modules.sale.stock import process_sale +from trytond.modules.product import round_price from trytond.modules.purchase.stock import process_purchase @@ -402,7 +403,6 @@ class ShipmentDrop(Workflow, ModelSQL, ModelView): Move = pool.get('stock.move') to_save = [] - cost_exp = Decimal(str(10.0 ** -Move.cost_price.digits[1])) for shipment in shipments: product_qty = defaultdict(int) product_cost = defaultdict(int) @@ -454,7 +454,7 @@ class ShipmentDrop(Workflow, ModelSQL, ModelView): for product, cost in product_cost.items(): qty = Decimal(str(s_product_qty[product])) if qty: - product_cost[product] = (cost / qty).quantize(cost_exp) + product_cost[product] = round_price(cost / qty) for c_move in list(shipment.customer_moves) + to_save: if c_move.id is not None and c_move.state == 'cancel': continue diff --git a/tryton.cfg b/tryton.cfg index 84b3303374..8c9b11afe0 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -3,6 +3,7 @@ version=5.5.0 depends: company ir + product purchase purchase_request sale