skip to Main Content

Try to reinstall a set of custom Odoo 13 modules on a new Ubuntu-based virtual machine. For one of the modules (material_purchase_requisitions), I keep encountering the following server error at the point of installation (Error message shortened to only the most relevant part):

Odoo Server Error

Traceback (most recent call last):
  File "/home/odoo13/odoo/odoo/tools/cache.py", line 85, in lookup
    r = d[key]
  File "/home/odoo13/odoo/odoo/tools/func.py", line 69, in wrapper
    return func(self, *args, **kwargs)
  File "/home/odoo13/odoo/odoo/tools/lru.py", line 44, in __getitem__
    a = self.d[obj].me
KeyError: ('ir.model.data', <function IrModelData.xmlid_lookup at 0x7f476ef59e50>, 'material_purchase_requisitions.inventory_keeper_manager_role')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/odoo13/odoo/odoo/tools/convert.py", line 712, in parse
    self._tag_root(de)
  File "/home/odoo13/odoo/odoo/tools/convert.py", line 674, in _tag_root
    f(rec)
  File "/home/odoo13/odoo/odoo/tools/convert.py", line 674, in _tag_root
    f(rec)
  File "/home/odoo13/odoo/odoo/tools/convert.py", line 472, in _tag_menuitem
    group_id = self.id_get(group)
  File "/home/odoo13/odoo/odoo/tools/convert.py", line 657, in id_get
    res = self.model_id_get(id_str, raise_if_not_found)
  File "/home/odoo13/odoo/odoo/tools/convert.py", line 663, in model_id_get
    return self.env['ir.model.data'].xmlid_to_res_model_res_id(id_str, raise_if_not_found=raise_if_not_found)
  File "/home/odoo13/odoo/odoo/addons/base/models/ir_model.py", line 1697, in xmlid_to_res_model_res_id
    return self.xmlid_lookup(xmlid)[1:3]
  File "<decorator-gen-24>", line 2, in xmlid_lookup
  File "/home/odoo13/odoo/odoo/tools/cache.py", line 90, in lookup
    value = d[key] = self.method(*args, **kwargs)
  File "/home/odoo13/odoo/odoo/addons/base/models/ir_model.py", line 1686, in xmlid_lookup
    raise ValueError('External ID not found in the system: %s' % xmlid)
ValueError: External ID not found in the system: material_purchase_requisitions.inventory_keeper_manager_role

The indicated missing/unidentified key (inventory_keeper_manager_role) is located within the module’s security.xml file, and is used for the purposes of creating custom user groups for access rights:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data noupdate="0">

        <record model="ir.module.category" id="purchase_requisition_role">
            <field name="name">Material Purchase Requisition</field>
        </record>

        <record id="group_purchase_requisition_user" model="res.groups">
            <field name="name">Material Purchase Requisition User</field>
            <field name="implied_ids" eval="[(4, ref('stock.group_stock_user'))]"/>
            <field name="category_id" ref="purchase_requisition_role"/>
        </record>
        
        <record id="group_all_administrator" model="res.groups">
            <field name="name">Administrator </field>
             <field name="implied_ids" eval="[
             (4, ref('base.group_user')),
             (4, ref('material_purchase_requisitions.group_purchase_requisition_department')),
             (4, ref('material_purchase_requisitions.inventory_keeper_manager_role')),
             (4, ref('material_purchase_requisitions.purchase_officer_role')),
             ]"/>
            <field name="category_id" ref="purchase_requisition_role"/>
            <field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>
        </record>

        <record id="group_purchase_requisition_department" model="res.groups">
            <field name="name">Material Purchase Requisition Department Manager</field>
            <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
            <field name="category_id" ref="purchase_requisition_role"/>
        </record>

         <record id="inventory_keeper_role" model="res.groups">
             <field name="name">Inventory Keeper</field>
             <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
             <field name="category_id" ref="purchase_requisition_role"/>
        </record>

        <record id="inventory_keeper_manager_role" model="res.groups">
             <field name="name">Inventory Manager</field>
             <field name="implied_ids" eval="[(4, ref('material_purchase_requisitions.inventory_keeper_role'))]"/>
             <field name="category_id" ref="purchase_requisition_role"/>
        </record>

        <record id="purchase_officer_role" model="res.groups">
             <field name="name">Purchase Officer</field>
             <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
             <field name="category_id" ref="purchase_requisition_role"/>
        </record>
        
        <record id="purchase_requisition_own_rule" model="ir.rule">
            <field name="name">Employee Material Purchase Requistion Own</field>
            <field name="model_id" ref="model_material_purchase_requisition"/>
            <field name="domain_force">[('employee_id.user_id','=',user.id)]</field>
            <field name="groups" eval="[(4, ref('base.group_user'))]"/>
        </record>

        <record id="purchase_requisition_line_department_manager_rule" model="ir.rule">
            <field name="name">Department Manager Material Purchase Requistion</field>
            <field name="model_id" ref="model_material_purchase_requisition"/>
            <field name="domain_force">[('employee_id.department_id.manager_id.user_id','=',user.id)]</field>
            <field name="groups" eval="[(4, ref('material_purchase_requisitions.group_purchase_requisition_department'))]"/>
        </record>

        <record id="purchase_requisition_all_rule" model="ir.rule">
            <field name="name">Material Purcahse Requisitions All</field>
            <field name="model_id" ref="model_material_purchase_requisition"/>
            <field name="domain_force">[(1,'=',1)]</field>
            <field name="groups" eval="[(4, ref('material_purchase_requisitions.group_all_administrator')),
                                        (4, ref('material_purchase_requisitions.inventory_keeper_role')),
                                        (4, ref('material_purchase_requisitions.purchase_officer_role'))]"/>
        </record>

        <record id="purchase_requisition_line_all_rule" model="ir.rule">
            <field name="name">Material Purcahse Requisitions Line All</field>
            <field name="model_id" ref="model_material_purchase_requisition_line"/>
            <field name="domain_force">[(1,'=',1)]</field>
            <field name="groups" eval="[(4, ref('material_purchase_requisitions.group_all_administrator')),
                                        (4, ref('material_purchase_requisitions.inventory_keeper_role')),
                                        (4, ref('material_purchase_requisitions.purchase_officer_role'))]"/>
        </record>
    </data>
</odoo>

Given that I can accurately trace the key location and its implementation within the code, and as far I can tell there are no syntax errors. Files are also being called in a correct order within the module’s manifest file. Therefore, what is causing the KeyError to manifest?

2

Answers


  1. you can try moving the record which defines inventory_keeper_manager_role up just before you calling it in group_all_administrator

    Login or Signup to reply.
  2. Data files in the manifest and the data itself (for example xml nodes or csv rows) like in your security.xml are processed sequentially. External IDs or xml IDs are saved in table ir_model_data and are created or updated before the actual data (in security.xml usually access groups) is created or updated.

    Your access group with xml id group_all_administrator is using another xml id in the field implied_ids. Odoo will handle that in database, but only if it has all required data. But the xml id inventory_keeper_manager_role wasn’t created yet.

    So you have to get your order right in that file. I havn’t looked into everyhting in that file, but atleast you have to move up the groups with xml id inventory_keeper_manager_role and inventory_keeper_role before xml id group_all_administrator.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search