Skip to content

Commit

Permalink
[MIG] document_page_access_group: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BhaveshHeliconia committed Feb 17, 2025
1 parent 4649661 commit 45c9278
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 48 deletions.
27 changes: 13 additions & 14 deletions document_page_access_group/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Document Page Access Group
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github
:target: https://github.com/OCA/knowledge/tree/17.0/document_page_access_group
:target: https://github.com/OCA/knowledge/tree/18.0/document_page_access_group
:alt: OCA/knowledge
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/knowledge-17-0/knowledge-17-0-document_page_access_group
:target: https://translation.odoo-community.org/projects/knowledge-18-0/knowledge-18-0-document_page_access_group
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/knowledge&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/knowledge&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand All @@ -42,19 +42,18 @@ Usage
To select the users that have access to a given document page you need
to open a document, go to the 'Security' tab and you have 3 options:

- Select a group: Only users with those groups will be able to see the
page.
- Select any user: Only the selected users will be able to see the
page.
- Do not select group or user: All users will be able to see the page.
- Select a group: Only users with those groups will be able to see the
page.
- Select any user: Only the selected users will be able to see the page.
- Do not select group or user: All users will be able to see the page.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/knowledge/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/knowledge/issues/new?body=module:%20document_page_access_group%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/knowledge/issues/new?body=module:%20document_page_access_group%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand All @@ -69,12 +68,12 @@ Authors
Contributors
------------

- Manuel Regidor <manuel.regidor@sygel.es>
- Alberto Martínez <alberto.martinez@sygel.es>
- Manuel Regidor <manuel.regidor@sygel.es>
- Alberto Martínez <alberto.martinez@sygel.es>

- ``Tecnativa <https://www.tecnativa.com>``\ \_:
- ``Tecnativa <https://www.tecnativa.com>``\ \_:

- Víctor Martínez
- Víctor Martínez

Maintainers
-----------
Expand All @@ -89,6 +88,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/knowledge <https://github.com/OCA/knowledge/tree/17.0/document_page_access_group>`_ project on GitHub.
This module is part of the `OCA/knowledge <https://github.com/OCA/knowledge/tree/18.0/document_page_access_group>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion document_page_access_group/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Document Page Access Group",
"summary": "Choose groups to access document pages",
"version": "17.0.2.0.0",
"version": "18.0.1.0.0",
"category": "document_knowledge",
"website": "https://github.com/OCA/knowledge",
"author": "Sygel, Odoo Community Association (OCA)",
Expand Down

This file was deleted.

12 changes: 0 additions & 12 deletions document_page_access_group/migrations/17.0.1.1.0/post-migration.py

This file was deleted.

6 changes: 4 additions & 2 deletions document_page_access_group/models/document_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import UserError


Expand All @@ -15,5 +15,7 @@ class DocumentPage(models.Model):
@api.constrains("groups_id", "user_ids")
def check_document_page_groups_users(self):
for _item in self.filtered(lambda x: x.groups_id and x.user_ids):
raise UserError(_("You cannot set groups and users at the same time."))
raise UserError(
self.env._("You cannot set groups and users at the same time.")
)
return True
4 changes: 2 additions & 2 deletions document_page_access_group/security/security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<field eval="False" name="global" />
<field
name="groups"
eval="[(4, ref('document_knowledge.group_document_user'))]"
eval="[Command.link(ref('document_knowledge.group_document_user'))]"
/>
<field
name="domain_force"
Expand All @@ -20,7 +20,7 @@
<field eval="False" name="global" />
<field
name="groups"
eval="[(4, ref('document_page.group_document_manager'))]"
eval="[Command.link(ref('document_page.group_document_manager'))]"
/>
<field name="domain_force">[(1, '=', 1)]</field>
</record>
Expand Down
9 changes: 4 additions & 5 deletions document_page_access_group/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Document Page Access Group</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:28e06c90139270717bf9f3fbe04145a72fed721a256eb4d526ee229beaf1cc69
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/knowledge/tree/17.0/document_page_access_group"><img alt="OCA/knowledge" src="https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/knowledge-17-0/knowledge-17-0-document_page_access_group"><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/knowledge&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<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/knowledge/tree/18.0/document_page_access_group"><img alt="OCA/knowledge" src="https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/knowledge-18-0/knowledge-18-0-document_page_access_group"><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/knowledge&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows to select which users groups have access to the
document pages.</p>
<p><strong>Table of contents</strong></p>
Expand All @@ -392,8 +392,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<ul class="simple">
<li>Select a group: Only users with those groups will be able to see the
page.</li>
<li>Select any user: Only the selected users will be able to see the
page.</li>
<li>Select any user: Only the selected users will be able to see the page.</li>
<li>Do not select group or user: All users will be able to see the page.</li>
</ul>
</div>
Expand All @@ -402,7 +401,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/knowledge/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/knowledge/issues/new?body=module:%20document_page_access_group%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/knowledge/issues/new?body=module:%20document_page_access_group%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -433,7 +432,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/knowledge/tree/17.0/document_page_access_group">OCA/knowledge</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/knowledge/tree/18.0/document_page_access_group">OCA/knowledge</a> project on GitHub.</p>
<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>
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions document_page_access_group/tests/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import Command
from odoo.tests import new_test_user

from odoo.addons.base.tests.common import BaseCommon
Expand All @@ -17,21 +18,21 @@ def setUpClass(cls):
login="test-manager-user",
groups="document_knowledge.group_document_user",
)
cls.manager_user.write({"groups_id": [(4, cls.group.id)]})
cls.manager_user.write({"groups_id": [Command.link(cls.group.id)]})
cls.public_page = cls.env["document.page"].create(
{"name": "Public Page", "type": "content"}
)
cls.knowledge_page = cls.env["document.page"].create(
{
"name": "Knowledge Page",
"type": "content",
"groups_id": [(6, 0, [cls.group.id])],
"groups_id": [Command.set([cls.group.id])],
}
)
cls.user_page = cls.env["document.page"].create(
{
"name": "User Page (basic user)",
"type": "content",
"user_ids": [(6, 0, [cls.user.id])],
"user_ids": [Command.set([cls.user.id])],
}
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import Command
from odoo.exceptions import UserError
from odoo.tests.common import users

Expand All @@ -8,7 +9,7 @@
class TestDocumentPageAccessGroup(TestDocumentPageAccessGroupBase):
def test_page_access_constrains(self):
with self.assertRaises(UserError):
self.knowledge_page.write({"user_ids": [(6, 0, [self.user.id])]})
self.knowledge_page.write({"user_ids": [Command.set([self.user.id])]})

@users("test-user")
def test_page_access_01(self):
Expand Down

0 comments on commit 45c9278

Please sign in to comment.