Search code examples
xmlpython-2.7openerp-7openerp-8

AssertionError: External ID must be fully qualified in odoo


I am working on Odoo CRM. I inherited CRM.lead I added some functionality I added new user roles to them.

Admin thing is working fine when I given user roles which I created now it's throwing error.

File ".........base/res/res_users.py", in has_group assert group_ext_id and '.' in group_ext_id, "External ID must be fully qualified"

"AssertionError: External ID must be fully qualified"

I tried but can't.

Help me if you know your valuable suggestion very help full for me.


Solution

  • I think the has_group method of res.users is not getting the fully qualified group id. I don't know what happened there but you can bypass that error by overriding the has_group method.

    For that first create a new model that inherit the res.users in your custom module. The code would be like:

    class Users(osv.osv):
        _inherit = 'res.users'
        _columns = {}
    
        def has_group(self,cr,uid,group_ext_id):
             if '.' in group_ext_id:
                  users_group1 = [x.id for x in self.pool['ir.model.data'].get_object(cr, uid, 'bms',  'xml_id_group1').users]
                  users_group2 = [x.id for x in self.pool['ir.model.data'].get_object(cr, uid, 'bms',  'xml_id_group2').users]
    
                  if uid in users_group1:
                      return super(Users,self).has_group(cr,uid,'module.xml_id_group1')
                  elif uid in users_group2:
                      return super(Users,self).has_group(cr,uid,'module.xml_id_group2')
                  else:
                      return super(Users,self).has_group(cr,uid,'base.group_user')
    
             else:
                 return super(Users,self).has_group(cr,uid,group_ext_id)
    

    In place of xml_id_group1 and xml_id_group2 place your group IDs for the groups you are getting the above error with.

    I hope this will help!