':param bom: in case of recursive boms: we could create work orders for child
BoMs'

def _workorders_create(self, bom, bom_data):

    workorders = self.env['mrp.workorder']
    bom_qty = bom_data['qty']
    if (self.product_id.tracking == 'serial'):
        quantity = 1.0
    else:
        quantity = (self.product_qty - sum(self.move_finished_ids.mapped('quantity_done')))
        quantity = (quantity if (quantity > 0) else 0)
    for operation in bom.routing_id.operation_ids:
        cycle_number = math.ceil((bom_qty / operation.workcenter_id.capacity))
        duration_expected = ((operation.workcenter_id.time_start + operation.workcenter_id.time_stop) + (((cycle_number * operation.time_cycle) * 100.0) / operation.workcenter_id.time_efficiency))
        workorder = workorders.create({'name': operation.name, 'production_id': self.id, 'workcenter_id': operation.workcenter_id.id, 'operation_id': operation.id, 'duration_expected': duration_expected, 'state': (((len(workorders) == 0) and 'ready') or 'pending'), 'qty_producing': quantity, 'capacity': operation.workcenter_id.capacity})
        if workorders:
            workorders[(-1)].next_work_order_id = workorder.id
        workorders += workorder
        moves_raw = self.move_raw_ids.filtered((lambda move: (move.operation_id == operation)))
        if (len(workorders) == len(bom.routing_id.operation_ids)):
            moves_raw |= self.move_raw_ids.filtered((lambda move: (not move.operation_id)))
        moves_finished = self.move_finished_ids.filtered((lambda move: (move.operation_id == operation)))
        moves_raw.mapped('move_lot_ids').write({'workorder_id': workorder.id})
        (moves_finished + moves_raw).write({'workorder_id': workorder.id})
        workorder._generate_lot_ids()
    return workorders
