Use work_center category for calculating cost if no work center is defined

This commit is contained in:
Sergi Almacellas Abellana 2014-01-15 21:01:27 +01:00
parent e42ac6d415
commit 13e653b3e3
2 changed files with 6 additions and 1 deletions

View File

@ -187,7 +187,8 @@ class OperationTracking(ModelSQL, ModelView):
def get_cost(self, name):
Uom = Pool().get('product.uom')
work_center = self.operation.work_center
work_center = (self.operation.work_center or
self.operation.work_center_category)
if not work_center:
return Decimal('0.0')
quantity = Uom.compute_qty(self.uom, self.quantity,
@ -293,6 +294,8 @@ class Production:
for production in productions:
operation_cost = sum(o.cost for o in production.operations)
if operation_cost == Decimal('0.0'):
continue
total_quantity = Decimal(str(sum(o.quantity for o in
production.outputs)))
added_unit_price = Decimal(operation_cost / total_quantity

View File

@ -243,6 +243,8 @@ Make a production::
>>> production.reload()
>>> all(i.state == 'done' for i in production.inputs)
True
>>> all(o.state == 'waiting' for o in production.operations)
True
>>> Production.done([production.id], config.context)
Traceback (most recent call last):
...