Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
3 Antworten
13246 Ansichten

Hi:

I see this is a long standing bug, I deleted some models in the code but now upgrading the module raise this error:

  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_model.py", line 1202, in unlink
    not self.env[selection.field_id.model]._abstract:
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 463, in __getitem__
    return self.registry[model_name]._browse(self, (), ())
  File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 177, in __getitem__
    return self.models[model_name]
KeyError: 'my.deleted.model'

Any solutions for this bug, besides brute force suggested in this post \https://github.com/odoo/odoo/issues/27758 ?

DELETE FROM ir_model_fields WHERE model = '<model>';
DELETE FROM ir_model_constraint WHERE model = (SELECT id FROM ir_model WHERE model = '<model>');
DELETE FROM ir_model_relation WHERE model = (SELECT id FROM ir_model WHERE model = '<model>');
DELETE FROM ir_model WHERE model = '<model>';


Thanks!

Mayte

Avatar
Verwerfen
Beste Antwort

Thanks for the answer inside the question that helped me to solved my problem.

If some one is looking for the force solution, you can try this:

sudo -i -u postgres
psql -d `your-db-name`
DELETE FROM ir_model_fields WHERE model = '`model`'; DELETE FROM ir_model_constraint WHERE model = (SELECT id FROM ir_model WHERE model = '`model`'); DELETE FROM ir_model_relation WHERE model = (SELECT id FROM ir_model WHERE model = '`model`'); DELETE FROM ir_model WHERE model = '`model`';

Remember to replace `your-db-name` and `model` with your actual values.

Thanks.

Avatar
Verwerfen

This worked for me. What can be done to avoid having to do this?

Beste Antwort

Go trough your database and delete the related model that KeyError.


user$host: sudo su - postgres
postgress$host: psql
postgres=#  \connect "database_name";
connected_db=# DELETE FROM ir_model WHERE model='model.name.that.keyError';

Thanks,
Tri

Avatar
Verwerfen
Beste Antwort

EDIT:

For all experiencing this issue, try deleting model's record in your security CSV. That is file in your security folder where you define default access to your models.


Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
0
Mai 21
1645
2
Aug. 25
2243
1
Juli 25
777
1
Aug. 25
1150
0
Mai 25
1266