Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
13249 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit

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

Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
kvě 21
1645
2
srp 25
2243
1
čvc 25
778
1
srp 25
1150
0
kvě 25
1266