From 47c4efbb881a1b53bf36b53d2bc080c195a31e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 6 Dec 2012 19:32:16 +0100 Subject: [PATCH] Try to use digits from Product first before Template review602002 (transplanted from f8f25226df181e23a6129470384c2160c7a75dcd) --- production.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/production.py b/production.py index b05e9534bc..e5dce450c7 100644 --- a/production.py +++ b/production.py @@ -258,6 +258,7 @@ class Production(Workflow, ModelSQL, ModelView): pool = Pool() Uom = pool.get('product.uom') Template = pool.get('product.template') + Product = pool.get('product.product') if not (self.bom and self.product and self.uom): return {} inputs = { @@ -292,6 +293,10 @@ class Production(Workflow, ModelSQL, ModelView): changes['cost'] += (Decimal(str(quantity)) * input_.product.cost_price) + if hasattr(Product, 'cost_price'): + digits = Product.cost_price.digits + else: + digits = Template.cost_price.digits for output in self.bom.outputs: quantity = output.compute_quantity(factor) values = self._explode_move_values(self.location, storage_location, @@ -299,10 +304,9 @@ class Production(Workflow, ModelSQL, ModelView): if values: values['unit_price'] = Decimal(0) if output.product.id == values.get('product') and quantity: - digits = Template.cost_price.digits[1] values['unit_price'] = Decimal( changes['cost'] / Decimal(str(quantity)) - ).quantize(Decimal(str(10 ** -digits))) + ).quantize(Decimal(str(10 ** -digits[1]))) outputs['add'].append(values) return changes