diff --git a/modules/product_kit/purchase.py b/modules/product_kit/purchase.py index ad83343e66..295f4bebf5 100644 --- a/modules/product_kit/purchase.py +++ b/modules/product_kit/purchase.py @@ -1,5 +1,8 @@ # 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.i18n import gettext from trytond.model import ModelSQL, ModelView, fields from trytond.modules.product import round_price @@ -59,7 +62,10 @@ class Line(order_line_mixin('purchase'), metaclass=PoolMeta): def get_component_order_line(self, component, **values): values = values.copy() values['purchase'] = self.purchase - return super().get_component_order_line(component, **values) + line = super().get_component_order_line(component, **values) + if line.unit_price is None: + line.unit_price = round_price(Decimal(0)) + return line @classmethod def get_move_product_types(cls): diff --git a/modules/product_kit/tests/scenario_product_kit_purchase.rst b/modules/product_kit/tests/scenario_product_kit_purchase.rst index de61196bc7..665583ea22 100644 --- a/modules/product_kit/tests/scenario_product_kit_purchase.rst +++ b/modules/product_kit/tests/scenario_product_kit_purchase.rst @@ -259,7 +259,7 @@ 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('9.4545'), Decimal('14.1818')] + [Decimal('0.0000'), Decimal('5.0000'), Decimal('9.4545'), Decimal('14.1818')] Check backorder moves:: diff --git a/modules/production_outsourcing/production.py b/modules/production_outsourcing/production.py index c59bbb050d..6fccb8b9e6 100644 --- a/modules/production_outsourcing/production.py +++ b/modules/production_outsourcing/production.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 itertools import groupby from trytond.i18n import gettext @@ -215,6 +217,8 @@ class Production(metaclass=PoolMeta): factor * self.routing.supplier_quantity) line.purchase = purchase line.on_change_product() + if line.unit_price is None: + line.unit_price = round_price(Decimal(0)) return line @classmethod