Skip to Content
Menu
This question has been flagged

Context (anonymized):

# removed from code class XChild(models.Model): _name = 'x.child' parent_id = fields.Many2one('res.partner') class ResPartner(models.Model): _inherit = 'res.partner' child_ids = fields.One2many('x.child', 'parent_id')

I removed the model x.child and the field res.partner.child_ids from the code. I don’t need the old data.

Error: On server start or opening Contacts → KeyError: 'child_ids'.

Tried:

  • Deleted metadata: ir.model.fields(name='child_ids')
  • Removed view refs: ir.ui.view (arch_db ilike 'child_ids')
  • Dropped child table x_child
  • Removed actions/filters/rules/templates where domains/contexts/body mention child_ids
  • Removed ir.model.access/ir.rule for x.child


What’s the complete cleanup order to remove all references and fix the KeyError without uninstalling the module in Odoo 11?

Which places are commonly missed besides views—e.g., ir.actions.act_window (domain/context), ir.filters, ir.rule (domain_force), ir.actions.server, base.automation, mail.template, ir.translation, ir.model.data xml_ids for ir.model/ir.model.fields?

Any Odoo 11 gotchas (e.g., ir.cron has no args field) to avoid invalid-field errors while searching?

Portretas
Atmesti
Best Answer

Hi,


When you remove a model or field from the code, Odoo’s ORM still expects that references in metadata (XML/DB records) remain valid. If anything still mentions child_ids, you’ll get a KeyError.


This is happens because,

    - The ORM loads models and their fields at startup.

    - When parsing views, actions, automations, etc., Odoo validates field names.

    - If something references a field that doesn’t exist anymore, you’ll get the KeyError: 'child_ids'.


Check the following.

1- Database Tables

       * Drop the model table: DROP TABLE IF EXISTS x_child;

       * Delete the model definition: DELETE FROM ir_model WHERE model='x.child';


2- Fields Metadata

      * Remove field entry

          DELETE FROM ir_model_fields WHERE name='child_ids' AND model='res.partner';


3- Views

     * ir_ui_view → search arch_db ILIKE '%child_ids%' and remove any leftovers.


4- Actions / Menus

     * ir_act_window → check domain, context fields for child_ids.

     * ir_act_server (server actions) → check code or state=code for references.

     * ir_ui_menu → only if a menu was pointing to the child model.


5- Filters & Search Defaults

      * ir_filters → check domain JSON for child_ids.


6 - Security & Rules

        * ir_model_access → remove entries pointing to x.child.

        * ir_rule → check domain_force for child_ids.


7- Automations & Crons

    * base_automation → check trg_date_id, domain, code for child_ids.

    * ir_cron → check model and code (though Odoo 11 ir.cron doesn’t have args).


8 - Mail / Templates / Reports

           * mail_template → search body and subject for ${object.child_ids...}.

           * ir_act_report_xml → check QWeb templates.

           * ir_translation → sometimes translations cache child_ids.


9 - Model Data (xml_ids)

      * ir_model_data → entries for x.child and child_ids (you can safely delete those XMLIDs).





Hope it helps

Portretas
Atmesti
Autorius Best Answer

could you please help me with it to remove all related code, models and etc?

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
2
rugp. 25
500
2
geg. 25
2278
0
kov. 15
3705
0
liep. 22
2711
2
birž. 22
3628