[SEBA-217] Certain fields should be marked as readonly

Change-Id: Ic8de963a878a8c85f1fb0706e08a93d39c7dc913
diff --git a/VERSION b/VERSION
index 3485cb2..4d54dad 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-4.0.2-dev
+4.0.2
diff --git a/lib/xos-genx/xosgenx/generator.py b/lib/xos-genx/xosgenx/generator.py
index 307e914..d354f9a 100644
--- a/lib/xos-genx/xosgenx/generator.py
+++ b/lib/xos-genx/xosgenx/generator.py
@@ -178,11 +178,11 @@
 
         lines = rendered.splitlines()
         current_buffer = []
-        for l in lines:
-            if l.startswith("+++"):
+        for line in lines:
+            if line.startswith("+++"):
 
                 if dir:
-                    path = dir + "/" + l[4:].lower()
+                    path = dir + "/" + line[4:].lower()
 
                 fil = open(path, "w")
                 buf = "\n".join(current_buffer)
@@ -197,7 +197,7 @@
 
                 current_buffer = []
             else:
-                current_buffer.append(l)
+                current_buffer.append(line)
 
     @staticmethod
     def _find_message_by_model_name(messages, model):
diff --git a/lib/xos-genx/xosgenx/jinja2_extensions/gui.py b/lib/xos-genx/xosgenx/jinja2_extensions/gui.py
index 476548b..4abc651 100644
--- a/lib/xos-genx/xosgenx/jinja2_extensions/gui.py
+++ b/lib/xos-genx/xosgenx/jinja2_extensions/gui.py
@@ -134,22 +134,22 @@
 def xproto_links_to_modeldef_relations(llst):
     outlist = []
     seen = []
-    for l in llst:
+    for ll in llst:
         try:
-            t = l["link_type"]
+            t = ll["link_type"]
         except KeyError as e:
             raise e
 
-        if l["peer"]["fqn"] not in seen and t != "manytomany":
+        if ll["peer"]["fqn"] not in seen and t != "manytomany":
             on_field = "null"
-            if l["link_type"] == "manytoone":
-                on_field = l["src_port"]
-            elif l["link_type"] == "onetomany":
-                on_field = l["dst_port"]
+            if ll["link_type"] == "manytoone":
+                on_field = ll["src_port"]
+            elif ll["link_type"] == "onetomany":
+                on_field = ll["dst_port"]
             outlist.append(
                 "{model: %s, type: %s, on_field: %s}"
-                % (l["peer"]["name"], l["link_type"], on_field)
+                % (ll["peer"]["name"], ll["link_type"], on_field)
             )
-        seen.append(l["peer"])
+        seen.append(ll["peer"])
 
     return outlist
diff --git a/xos/core/models/core.xproto b/xos/core/models/core.xproto
index 50ad6a6..29cbb54 100644
--- a/xos/core/models/core.xproto
+++ b/xos/core/models/core.xproto
@@ -67,7 +67,7 @@
      required bool is_registering = 16 [default = False, db_index = False];
      required bool is_appuser = 17 [default = False, db_index = False];
      optional string login_page = 18 [max_length = 200, content_type = "stripped", blank = True, help_text = "send this user to a specific page on login", db_index = False];
-     required string created = 19 [content_type = "date", auto_now_add = True, help_text = "Time this model was created"];
+     required string created = 19 [content_type = "date", auto_now_add = True, help_text = "Time this model was created", bookkeeping_state = True];
      required string updated = 20 [default = "now()", content_type = "date", help_text = "Time this model was changed by a non-synchronizer"];
      optional string enacted = 21 [content_type = "date", blank = True, default = None, help_text = "When synced, set to the timestamp of the data that was synced"];
      optional string policed = 22 [content_type = "date", blank = True, default = None, help_text = "When policed, set to the timestamp of the data that was policed"];
@@ -83,7 +83,7 @@
      required string timezone = 32 [default = "America/New_York", max_length = 100, blank = False, db_index = False];
      optional string policy_status = 33 [default = "0 - Policy in process", max_length = 1024];
      optional int32 policy_code = 34 [default = 0];
-     required string leaf_model_name = 35 [max_length = 1024, help_text = "The most specialized model in this chain of inheritance, often defined by a service developer"];
+     required string leaf_model_name = 35 [max_length = 1024, help_text = "The most specialized model in this chain of inheritance, often defined by a service developer", bookkeeping_state = True];
      required bool backend_need_delete_policy = 36 [default = False, help_text = "True if delete model_policy must be run before object can be reaped"];
      required bool xos_managed = 37 [default = True, help_text = "True if xos is responsible for creating/deleting this object", gui_hidden = True];
      optional string backend_handle = 38 [max_length = 1024, feedback_state = True, blank=True, help_text = "Handle used by the backend to track this object", gui_hidden = True];