Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
13242 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona

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

Risposta migliore

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
Abbandona
Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
mag 21
1644
2
ago 25
2241
1
lug 25
777
1
ago 25
1150
0
mag 25
1266