I removed a field (dummy_field_ids) that was used in a One2many relationship in a model, but Odoo is still referencing it. How can I safely clean up all the relationships and data that depended on this fields.
DetailsExplanation:
I recently removed a custom module from my Odoo installation, which contained several fields and models. After removing the module code, I started encountering errors in the system, specifically KeyError messages referencing a field (dummy_field_ids) that I had deleted from the code.
From what I understand, even though the Python code defining the field no longer exists, Odoo's database still contains metadata and possibly table columns related to this field. This causes the system to continue expecting the field, which breaks views, forms, and certain automated actions.
Here's a summary of the situation:
- The module has been removed, including all model definitions for dummy_field_ids.
- The database still contains references to this field in the ir_model_fields table and in the actual table for the model.
- Attempts to open forms or pages that previously used this field now throw errors.
- I cannot uninstall the module (it's already removed) and manually deleting database columns seems risky due to foreign keys, constraints, and large amounts of data.
What I want to achieve:
- Remove the field completely from Odoo's metadata (ir_model_fields).
- Remove the actual column from the database table safely.
- Ensure that no views, actions, or reports reference this field anymore to prevent errors.
- Do this without uninstalling any modules and without losing other unrelated data.
I've seen some discussions suggesting writing a script to delete the field on server start or using SQL directly, but I want a safe, recommended approach that works with Odoo's ORM and handles both the metadata and database side.
Has anyone dealt with a similar situation? What is the recommended way to clean up removed fields from both the Odoo models and the database? Any scripts, methods, or best practices would be very helpful.
The previously implemented code has been removed from the project. I created a new model named x.custom.model, which includes four new fields and a ForeignKey field (x_dummy_fk) referencing the x.base.model table. The x.base.model also includes a One2many field named x_dummy_one2many, pointing to x.custom.model using x_dummy_fk as the inverse_name.
Although the old code has been deleted, I'm still encountering an error related to x_dummy_one2many. I need to ensure that all references to this field are fully removed from both the database and the source code. Please help identify and clean up any remaining dependencies
x_dummy_one2many = fields.One2many(
"x.custom.model",
inverse_name="x_dummy_fk",
string="Dummy Rebate",
)
could you please help me to erase all related code.