Skip to content

Commit 640c884

Browse files
yelizarievtrojikman
authored andcommitted
🚑 access_apps: allow safely uninstall module
STEPS: * install access_apps * uninstall access_apps * open Apps menu BEFORE: access error AFTER: no errors, access rights are restored
1 parent 3c2f775 commit 640c884

File tree

6 files changed

+24
-9
lines changed

6 files changed

+24
-9
lines changed

access_apps/README.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ Adds **Apps access** selection in user's access rights tab. Two options are avai
1313
* *Allow installing apps*
1414
* *Allow installing apps only from settings*
1515

16-
Roadmap
17-
=======
18-
19-
* Access records (e.g. ``access_ir_module_module_group_user``) should not be deleted. It has to be disactivated and make active on uninstallation
20-
2116
Questions?
2217
==========
2318

access_apps/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
from . import models
2+
from .hooks import uninstall_hook

access_apps/__manifest__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
1+
# Copyright 2018,2021 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
22
# Copyright 2018 Ildar Nasyrov <https://it-projects.info/team/iledarn>
33
# License MIT (https://opensource.org/licenses/MIT).
44
{
@@ -7,7 +7,7 @@
77
"category": "Access",
88
# "live_test_url": "",
99
"images": [],
10-
"version": "14.0.1.3.3",
10+
"version": "14.0.2.0.0",
1111
"application": False,
1212
"author": "IT-Projects LLC, Ivan Yelizariev",
1313
"support": "apps@itpp.dev",
@@ -23,7 +23,7 @@
2323
"post_load": None,
2424
"pre_init_hook": None,
2525
"post_init_hook": None,
26-
"uninstall_hook": None,
26+
"uninstall_hook": "uninstall_hook",
2727
"auto_install": False,
2828
"installable": True,
2929
}

access_apps/doc/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
`2.0.0`
2+
-------
3+
- **Fix:** restore original access rights on uninstallation
4+
15
`1.3.3`
26
-------
37
- **Fix:** Grant `Allow installing apps` to Admin and System users (it was only System)

access_apps/hooks.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright 2021 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
2+
# License MIT (https://opensource.org/licenses/MIT).
3+
from odoo import api, SUPERUSER_ID
4+
5+
6+
def uninstall_hook(cr, registry):
7+
env = api.Environment(cr, SUPERUSER_ID, {})
8+
access = env.ref("base.access_ir_module_module_group_user", raise_if_not_found=False)
9+
access.write({'active': True})

access_apps/security/access_apps_security.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
<?xml version="1.0" encoding="utf-8" ?>
2+
<!-- Copyright 2018,2021 Ivan Yelizariev <https://twitter.com/yelizariev>
3+
Copyright 2018 Ildar Nasyrov <https://it-projects.info/team/iledarn>
4+
License MIT (https://opensource.org/licenses/MIT).
5+
-->
26
<odoo>
3-
<delete id="base.access_ir_module_module_group_user" model="ir.model.access" />
7+
<record id="base.access_ir_module_module_group_user" model="ir.model.access">
8+
<field name="active" eval="False"/>
9+
</record>
410
<record id="module_category_access_apps" model="ir.module.category">
511
<field name="name">Apps access</field>
612
<field name="sequence">18</field>

0 commit comments

Comments
 (0)