AssertionError:外部ID必须在odoo中完全限定

时间:2022-06-01 12:37:06

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

我正在研究Odoo CRM。我继承了CRM.lead我添加了一些功能,我向他们添加了新的用户角色。

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"

文件“......... base / res / res_users.py”,在has_group断言group_ext_id和'。'中在group_ext_id中,“外部ID必须是完全限定的”

"AssertionError: External ID must be fully qualified"

“AssertionError:外部ID必须完全合格”

I tried but can't.

我试过但不能。

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

如果你知道你的宝贵意见,请帮助我。

1 个解决方案

#1


0  

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.

我认为res.users的has_group方法没有获得完全限定的组ID。我不知道那里发生了什么,但你可以通过覆盖has_group方法来绕过这个错误。

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

首先,创建一个继承自定义模块中res.users的新模型。代码如下:

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.

代替xml_id_group1和xml_id_group2,将您获得上述错误的组的组ID放入。

I hope this will help!

我希望这个能帮上忙!

#1


0  

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.

我认为res.users的has_group方法没有获得完全限定的组ID。我不知道那里发生了什么,但你可以通过覆盖has_group方法来绕过这个错误。

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

首先,创建一个继承自定义模块中res.users的新模型。代码如下:

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.

代替xml_id_group1和xml_id_group2,将您获得上述错误的组的组ID放入。

I hope this will help!

我希望这个能帮上忙!