proper rounding for unit_price in Production.set_moves
review600003 issue2904 (transplanted from 7191832dfd42adc565d3f28b64793b2b7beb9e41)
This commit is contained in:
1 parent
47c4efbb88
commit
91a4fb4520
1 file changed
+12
-1
+12
-1
@@ -385,6 +385,10 @@ class Production(Workflow, ModelSQL, ModelView):
|
||||
return cost
|
||||
|
||||
def set_moves(self):
|
||||
pool = Pool()
|
||||
Template = pool.get('product.template')
|
||||
Product = pool.get('product.product')
|
||||
|
||||
storage_location = self.warehouse.storage_location
|
||||
location = self.location
|
||||
company = self.company
|
||||
@@ -412,6 +416,11 @@ class Production(Workflow, ModelSQL, ModelView):
|
||||
move.save()
|
||||
cost += Decimal(str(quantity)) * product.cost_price
|
||||
|
||||
if hasatttr(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)
|
||||
product = output.product
|
||||
@@ -420,7 +429,9 @@ class Production(Workflow, ModelSQL, ModelView):
|
||||
if move:
|
||||
move.production_output = self
|
||||
if product == self.product:
|
||||
move.unit_price = cost / Decimal(str(quantity))
|
||||
move.unit_price = Decimal(
|
||||
cost / Decimal(str(quantity))
|
||||
).quantize(Decimal(str(10 ** -digits[1])))
|
||||
move.save()
|
||||
self._set_move_planned_date()
|
||||
|
||||
|
||||
Reference in new issue
Block a user