From a8e0e1979feb8f2f33007b3ff2e7e24b36e84d2c Mon Sep 17 00:00:00 2001 From: Oscar Alvarez Date: Sat, 6 Oct 2012 21:18:20 -0500 Subject: [PATCH] Fix production Round compute of unit_price issue2764 review501004 (transplanted from 7a09a1818c64b03a0c92b07a09eef4bc0f689187) --- production.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/production.py b/production.py index 664438bc5b..33cdcc9b5d 100644 --- a/production.py +++ b/production.py @@ -258,6 +258,7 @@ class Production(Workflow, ModelSQL, ModelView): output_obj = pool.get('production.bom.output') location_obj = pool.get('stock.location') company_obj = pool.get('company.company') + template_obj = pool.get('product.template') if not (values.get('bom') and values.get('product') @@ -314,8 +315,10 @@ class Production(Workflow, ModelSQL, ModelView): if values: values['unit_price'] = Decimal(0) if output.product.id == values.get('product') and quantity: - values['unit_price'] = (changes['cost'] / - Decimal(str(quantity))) + digits = template_obj.cost_price.digits[1] + values['unit_price'] = Decimal( + changes['cost'] / Decimal(str(quantity)) + ).quantize(Decimal(str(10 ** -digits))) outputs['add'].append(values) return changes