Add total_quantity field at Operation class

#041534
This commit is contained in:
Raimon Esteve 2020-12-15 12:24:12 +01:00
parent 0c82dc7728
commit 9cd00c2fa5
1 changed files with 11 additions and 0 deletions

View File

@ -36,6 +36,8 @@ class Operation(sequence_ordered(), Workflow, ModelSQL, ModelView):
'work_center': Eval('work_center'),
})
cost = fields.Function(fields.Numeric('Cost'), 'get_cost')
total_quantity = fields.Function(fields.Float('Total Quantity'),
'get_total_quantity')
operation_type = fields.Many2One('production.operation.type',
'Operation Type', states=STATES, depends=DEPENDS, required=True)
state = fields.Selection([
@ -137,6 +139,15 @@ class Operation(sequence_ordered(), Workflow, ModelSQL, ModelView):
cost += line.cost
return cost
def get_total_quantity(self, name):
Uom = Pool().get('product.uom')
total = 0.
for line in self.lines:
total += Uom.compute_qty(line.uom, line.quantity,
self.work_center_category.uom)
return total
@classmethod
@ModelView.button
@Workflow.transition('waiting')