CORD-1621: Inherited models with custom code fail to import in monitoring service

Change-Id: If2b918fc81b869848f8c1e62231acf963ce77af6
diff --git a/lib/xos-genx/xosgenx/jinja2_extensions/base.py b/lib/xos-genx/xosgenx/jinja2_extensions/base.py
index 029f6eb..c15bf32 100644
--- a/lib/xos-genx/xosgenx/jinja2_extensions/base.py
+++ b/lib/xos-genx/xosgenx/jinja2_extensions/base.py
@@ -63,14 +63,15 @@
     return outlist
 
 
-def xproto_base_def(model_name, base):
+def xproto_base_def(model_name, base, suffix='', suffix_list=[]):
     if (model_name=='XOSBase'):
         return '(models.Model, PlModelMixIn)'
     elif (not base):
         return ''
     else:
-        base = map(lambda s:s['name'], base)
-        return '(' + ','.join(base) + ')'
+        int_base = [i['name']+suffix for i in base if i['name'] in suffix_list]
+        ext_base = [i['name'] for i in base if i['name'] not in suffix_list]
+        return '(' + ','.join(int_base + ext_base) + ')'
 
 def xproto_first_non_empty(lst):
     for l in lst:
diff --git a/lib/xos-genx/xosgenx/targets/service.xtarget b/lib/xos-genx/xosgenx/targets/service.xtarget
index 80d90d6..5336f82 100644
--- a/lib/xos-genx/xosgenx/targets/service.xtarget
+++ b/lib/xos-genx/xosgenx/targets/service.xtarget
@@ -33,7 +33,7 @@
 {% endfor %}
 
 {% for m in proto.messages %}
-class {{ m.name }}{{ legacy_tag }}{{ xproto_base_def(m.name, m.bases) }}:
+class {{ m.name }}{{ legacy_tag }}{{ xproto_base_def(m.name, m.bases, legacy_tag, proto.message_names) }}:
   plural_name = "{{ xproto_pluralize(m) }}"
 
   KIND = {{ xproto_first_non_empty([m.options.kind, options.kind, options.name, "Set a kind in your xproto!"]) }}