Try to use digits from Product first before Template

review602002
This commit is contained in:
Cédric Krier committed 2012-12-06 19:32:16 +01:00
1 parent 2ca38b5ca3
commit f3befe339d
1 file changed
+6 -2
+6 -2
View File
@@ -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