Skip to content

Commit debb16c

Browse files
[MIG] base_view_action_visibility: Migration to 18.0
1 parent 018495a commit debb16c

9 files changed

Lines changed: 68 additions & 62 deletions

File tree

base_view_action_visibility/README.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Base View Action Visibility
77
!! This file is generated by oca-gen-addon-readme !!
88
!! changes will be overwritten. !!
99
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:3e14bf64536a24db79c8623c6e64f6005a0865e85d3d163b0907435d44535d29
10+
!! source digest: sha256:2c40e0de96c999788560fe85a87a6251c855f2d622973fd132d6ac7aa0c96614
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
1313
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -34,7 +34,7 @@ settings. You can restrict these actions to specific security groups, or
3434
leave them unrestricted to allow all users to see them.
3535

3636
The Duplicate action restriction applies to form views, while the Delete
37-
action restriction applies to form, tree, and kanban views.
37+
action restriction applies to form, list, and kanban views.
3838

3939
Note: This module controls the visibility of UI actions only. It does
4040
not enforce server-side restrictions.
@@ -58,9 +58,14 @@ To configure action visibility for a model:
5858
action in form views to only those groups. Leave empty to allow
5959
all users to duplicate.
6060
- Add groups to *Delete Allowed Groups* to restrict the delete
61-
action in form, tree, and kanban views to only those groups. Leave
61+
action in form, list, and kanban views to only those groups. Leave
6262
empty to allow all users to delete.
6363

64+
Note: the restriction applies to every user who is not a member of the
65+
allowed groups, administrators included. If you restrict an action to a
66+
group you do not belong to, the button will be hidden for you as well.
67+
Add yourself to the allowed group to keep access.
68+
6469
Bug Tracker
6570
===========
6671

base_view_action_visibility/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"name": "Base View Action Visibility",
55
"summary": "Hide standard view actions (Duplicate, Delete) per model",
6-
"version": "15.0.1.0.0",
6+
"version": "18.0.1.0.0",
77
"category": "Server tools",
88
"website": "https://github.com/OCA/server-ux",
99
"author": "Quartile, Odoo Community Association (OCA)",

base_view_action_visibility/models/ir_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ class IrModel(models.Model):
2222
"model_id",
2323
"group_id",
2424
string="Delete Allowed Groups",
25-
help="Restrict the 'Delete' action in form, tree, and kanban views to these groups. "
26-
"Leave empty to allow all users to delete records.",
25+
help="Restrict the 'Delete' action in form, list, and kanban views to "
26+
"these groups. Leave empty to allow all users to delete records.",
2727
)

base_view_action_visibility/models/models.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from lxml import etree
55

6-
from odoo import models
6+
from odoo import api, models
77

88

99
class Base(models.AbstractModel):
@@ -16,16 +16,11 @@ def _should_hide_action(self, allowed_group_ids):
1616
user_has_permission = bool(allowed_group_ids & user_groups)
1717
return not user_has_permission
1818

19-
def fields_view_get(
20-
self, view_id=None, view_type="form", toolbar=False, submenu=False
21-
):
22-
result = super().fields_view_get(
23-
view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu
24-
)
25-
ir_model = (
26-
self.env["ir.model"].sudo().search([("model", "=", self._name)], limit=1)
27-
)
28-
if view_type not in ("form", "tree", "kanban") or not ir_model:
19+
@api.model
20+
def get_view(self, view_id=None, view_type="form", **options):
21+
result = super().get_view(view_id=view_id, view_type=view_type, **options)
22+
ir_model = self.env["ir.model"]._get(self._name)
23+
if view_type not in ("form", "list", "kanban") or not ir_model:
2924
return result
3025
hide_duplicate = self._should_hide_action(ir_model.duplicate_allowed_group_ids)
3126
hide_delete = self._should_hide_action(ir_model.delete_allowed_group_ids)

base_view_action_visibility/readme/CONFIGURE.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@ To configure action visibility for a model:
88
action in form views to only those groups. Leave empty to allow
99
all users to duplicate.
1010
- Add groups to *Delete Allowed Groups* to restrict the delete
11-
action in form, tree, and kanban views to only those groups. Leave
11+
action in form, list, and kanban views to only those groups. Leave
1212
empty to allow all users to delete.
13+
14+
Note: the restriction applies to every user who is not a member of the
15+
allowed groups, administrators included. If you restrict an action to a
16+
group you do not belong to, the button will be hidden for you as well.
17+
Add yourself to the allowed group to keep access.

base_view_action_visibility/readme/DESCRIPTION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ settings. You can restrict these actions to specific security groups, or
44
leave them unrestricted to allow all users to see them.
55

66
The Duplicate action restriction applies to form views, while the Delete
7-
action restriction applies to form, tree, and kanban views.
7+
action restriction applies to form, list, and kanban views.
88

99
Note: This module controls the visibility of UI actions only. It does
1010
not enforce server-side restrictions.

base_view_action_visibility/static/description/index.html

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
12
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
23
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
34
<head>
45
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5-
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6+
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
67
<title>Base View Action Visibility</title>
78
<style type="text/css">
89

910
/*
1011
:Author: David Goodger (goodger@python.org)
11-
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
12+
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
1213
:Copyright: This stylesheet has been placed in the public domain.
1314
1415
Default cascading style sheet for the HTML output of Docutils.
15-
Despite the name, some widely supported CSS2 features are used.
1616
17-
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
17+
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
1818
customize this style sheet.
1919
*/
2020

@@ -275,7 +275,7 @@
275275
margin-left: 2em ;
276276
margin-right: 2em }
277277

278-
pre.code .ln { color: gray; } /* line numbers */
278+
pre.code .ln { color: grey; } /* line numbers */
279279
pre.code, code { background-color: #eeeeee }
280280
pre.code .comment, code .comment { color: #5C6576 }
281281
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -301,7 +301,7 @@
301301
span.pre {
302302
white-space: pre }
303303

304-
span.problematic, pre.problematic {
304+
span.problematic {
305305
color: red }
306306

307307
span.section-subtitle {
@@ -367,32 +367,32 @@ <h1 class="title">Base View Action Visibility</h1>
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370-
!! source digest: sha256:3e14bf64536a24db79c8623c6e64f6005a0865e85d3d163b0907435d44535d29
370+
!! source digest: sha256:2c40e0de96c999788560fe85a87a6251c855f2d622973fd132d6ac7aa0c96614
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-ux/tree/18.0/base_view_action_visibility"><img alt="OCA/server-ux" src="https://img.shields.io/badge/github-OCA%2Fserver--ux-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-ux-18-0/server-ux-18-0-base_view_action_visibility"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-ux&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-ux/tree/18.0/base_view_action_visibility"><img alt="OCA/server-ux" src="https://img.shields.io/badge/github-OCA%2Fserver--ux-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-ux-18-0/server-ux-18-0-base_view_action_visibility"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/builds?repo=OCA/server-ux&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373373
<p>This module allows restricting standard view actions (Duplicate and
374374
Delete) on a per-model basis through configuration on the ir.model
375375
settings. You can restrict these actions to specific security groups, or
376376
leave them unrestricted to allow all users to see them.</p>
377377
<p>The Duplicate action restriction applies to form views, while the Delete
378-
action restriction applies to form, tree, and kanban views.</p>
378+
action restriction applies to form, list, and kanban views.</p>
379379
<p>Note: This module controls the visibility of UI actions only. It does
380380
not enforce server-side restrictions.</p>
381381
<p><strong>Table of contents</strong></p>
382382
<div class="contents local topic" id="contents">
383383
<ul class="simple">
384-
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
385-
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
386-
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
387-
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
388-
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
389-
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
384+
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
385+
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li>
386+
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
387+
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
388+
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
389+
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
390390
</ul>
391391
</li>
392392
</ul>
393393
</div>
394394
<div class="section" id="configuration">
395-
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
395+
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
396396
<p>To configure action visibility for a model:</p>
397397
<ol class="arabic simple">
398398
<li>Activate developer mode.</li>
@@ -403,30 +403,34 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
403403
action in form views to only those groups. Leave empty to allow
404404
all users to duplicate.</li>
405405
<li>Add groups to <em>Delete Allowed Groups</em> to restrict the delete
406-
action in form, tree, and kanban views to only those groups. Leave
406+
action in form, list, and kanban views to only those groups. Leave
407407
empty to allow all users to delete.</li>
408408
</ul>
409409
</li>
410410
</ol>
411+
<p>Note: the restriction applies to every user who is not a member of the
412+
allowed groups, administrators included. If you restrict an action to a
413+
group you do not belong to, the button will be hidden for you as well.
414+
Add yourself to the allowed group to keep access.</p>
411415
</div>
412416
<div class="section" id="bug-tracker">
413-
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
417+
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
414418
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-ux/issues">GitHub Issues</a>.
415419
In case of trouble, please check there if your issue has already been reported.
416420
If you spotted it first, help us to smash it by providing a detailed and welcomed
417421
<a class="reference external" href="https://github.com/OCA/server-ux/issues/new?body=module:%20base_view_action_visibility%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
418422
<p>Do not contact contributors directly about support or help with technical issues.</p>
419423
</div>
420424
<div class="section" id="credits">
421-
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
425+
<h1><a class="toc-backref" href="#id3">Credits</a></h1>
422426
<div class="section" id="authors">
423-
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
427+
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
424428
<ul class="simple">
425429
<li>Quartile</li>
426430
</ul>
427431
</div>
428432
<div class="section" id="contributors">
429-
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
433+
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
430434
<ul class="simple">
431435
<li><a class="reference external" href="https://www.quartile.co">Quartile</a>:<ul>
432436
<li>Aung Ko Ko Lin</li>
@@ -435,16 +439,14 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
435439
</ul>
436440
</div>
437441
<div class="section" id="maintainers">
438-
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
442+
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
439443
<p>This module is maintained by the OCA.</p>
440-
<a class="reference external image-reference" href="https://odoo-community.org">
441-
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
442-
</a>
444+
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
443445
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
444446
mission is to support the collaborative development of Odoo features and
445447
promote its widespread use.</p>
446448
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
447-
<p><a class="reference external image-reference" href="https://github.com/yostashiro"><img alt="yostashiro" src="https://github.com/yostashiro.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/aungkokolin1997"><img alt="aungkokolin1997" src="https://github.com/aungkokolin1997.png?size=40px" /></a></p>
449+
<p><a class="reference external" href="https://github.com/yostashiro"><img alt="yostashiro" src="https://github.com/yostashiro.png?size=40px" /></a> <a class="reference external" href="https://github.com/aungkokolin1997"><img alt="aungkokolin1997" src="https://github.com/aungkokolin1997.png?size=40px" /></a></p>
448450
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-ux/tree/18.0/base_view_action_visibility">OCA/server-ux</a> project on GitHub.</p>
449451
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
450452
</div>

0 commit comments

Comments
 (0)