Skip to content

Commit

Permalink
[IMP] util.records.uninstall_module: use remove_group
Browse files Browse the repository at this point in the history
In `uninstall_module` it is not using `remove_group` for
records from model `res.groups` which leads to face
**psycopg2.errors.ForeignKeyViolation** while removing the records
from `res.groups`, if the group has relation
with _**ondelete=restrict**_.

closes #174

Signed-off-by: Christophe Simonis (chs) <[email protected]>
  • Loading branch information
jepbarasgarov committed Jan 3, 2025
1 parent 05aae80 commit 7c57af1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/util/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
from .models import delete_model
from .orm import env, flush
from .pg import column_exists, table_exists, target_of
from .records import ref, remove_menus, remove_records, remove_view, replace_record_references_batch
from .records import ref, remove_group, remove_menus, remove_records, remove_view, replace_record_references_batch

INSTALLED_MODULE_STATES = ("installed", "to install", "to upgrade")
_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -204,6 +204,9 @@ def uninstall_module(cr, module):
if model == "ir.ui.view":
for _, res_id in group:
remove_view(cr, view_id=res_id, silent=True)
elif model == "res.groups":
for _, res_id in group:
remove_group(cr, group_id=res_id)
else:
remove_records(cr, model, [it[1] for it in group])

Expand Down

0 comments on commit 7c57af1

Please sign in to comment.