CORD-879 restore self_content_type_id in the api, fix error thrown by OneToOneField

Change-Id: I2ef79febeb0b5d82b007538d7cdfe2cbc0cee869
diff --git a/xos/coreapi/apihelper.py b/xos/coreapi/apihelper.py
index 89d1545..9d9134c 100644
--- a/xos/coreapi/apihelper.py
+++ b/xos/coreapi/apihelper.py
@@ -6,6 +6,7 @@
 from protos import xos_pb2
 from google.protobuf.empty_pb2 import Empty
 
+from django.contrib.contenttypes.models import ContentType
 from django.contrib.auth import authenticate as django_authenticate
 from django.db.models import F,Q
 from core.models import *
@@ -98,6 +99,8 @@
         bases = [x for x in bases if issubclass(x, PlCoreBase) or issubclass(x, User)]
         p_obj.class_names = ",".join( [x.__name__ for x in bases] )
 
+        p_obj.self_content_type_id = ContentType.objects.get_for_model(obj).id
+
         return p_obj
 
     def protoToArgs(self, djangoClass, message):
diff --git a/xos/tools/apigen/protobuf.template.txt b/xos/tools/apigen/protobuf.template.txt
index 43afd39..060d218 100644
--- a/xos/tools/apigen/protobuf.template.txt
+++ b/xos/tools/apigen/protobuf.template.txt
@@ -53,6 +53,8 @@
       float {{ field.name }} = {{ loop.index }};
     {%- elif field.get_internal_type() == "GenericIPAddressField" %}
       string {{ field.name }} = {{ loop.index }};
+    {%- elif field.get_internal_type() == "OneToOneField" %}
+      int32 {{ field.name }}_id = {{ loop.index }};
     {%- else %}
       UNKNOWN {{ field.get_internal_type() }} {{ field.name }} = {{ loop.index }};
     {%- endif %}
@@ -62,6 +64,7 @@
     repeated int32 {{ ref.related_name }}_ids  = {{ loop.index+100 }} [(reverseForeignKey).modelName = "{{ ref.camel() }}"];
   {%- endfor %}
   string class_names = 201;
+  int32 self_content_type_id = 202;
 }
 
 message {{ object.camel() }}s {
diff --git a/xos/xos_client/xosapi/orm.py b/xos/xos_client/xosapi/orm.py
index bf59222..8b730a8 100644
--- a/xos/xos_client/xosapi/orm.py
+++ b/xos/xos_client/xosapi/orm.py
@@ -202,9 +202,9 @@
     def ansible_tag(self):
         return "%s_%s" % (self._wrapped_class.__class__.__name__, self.id)
 
-    @property
-    def self_content_type_id(self):
-        return getattr(self.stub, self._wrapped_class.__class__.__name__).content_type_id
+#    @property
+#    def self_content_type_id(self):
+#        return getattr(self.stub, self._wrapped_class.__class__.__name__).content_type_id
 
 class ORMQuerySet(list):
     """ Makes lists look like django querysets """