[MIG] document_page_access_group: Migration to 18.0

This commit is contained in:
Bhavesh Heliconia 2025-02-17 16:41:17 +05:30
parent f37e9e1720
commit 893d3bd8a5
10 changed files with 40 additions and 48 deletions

View File

@ -17,13 +17,13 @@ Document Page Access Group
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github .. |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 :alt: OCA/knowledge
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |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 :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png .. |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 :alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -42,11 +42,10 @@ Usage
To select the users that have access to a given document page you need 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: 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 - Select a group: Only users with those groups will be able to see the
page. page.
- Select any user: Only the selected users will be able to see the - Select any user: Only the selected users will be able to see the page.
page. - Do not select group or user: All 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 Bug Tracker
=========== ===========
@ -54,7 +53,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/knowledge/issues>`_. 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. 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 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. Do not contact contributors directly about support or help with technical issues.
@ -69,12 +68,16 @@ Authors
Contributors Contributors
------------ ------------
- Manuel Regidor <manuel.regidor@sygel.es> - Manuel Regidor <manuel.regidor@sygel.es>
- Alberto Martínez <alberto.martinez@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
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__
- Bhavesh Heliconia
Maintainers Maintainers
----------- -----------
@ -89,6 +92,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. 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. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -4,7 +4,7 @@
{ {
"name": "Document Page Access Group", "name": "Document Page Access Group",
"summary": "Choose groups to access document pages", "summary": "Choose groups to access document pages",
"version": "17.0.2.0.0", "version": "18.0.1.0.0",
"category": "document_knowledge", "category": "document_knowledge",
"website": "https://github.com/OCA/knowledge", "website": "https://github.com/OCA/knowledge",
"author": "Sygel, Odoo Community Association (OCA)", "author": "Sygel, Odoo Community Association (OCA)",

View File

@ -1,8 +0,0 @@
<?xml version='1.0' encoding='utf-8' ?>
<odoo>
<record id="document_page_rule" model="ir.rule">
<field
name="domain_force"
>['|', ('groups_id', 'in', [g.id for g in user.groups_id]), '|', ('user_ids', 'in', [user.id]), '&amp;', ('groups_id', '=', False), ('user_ids', '=', False)]</field>
</record>
</odoo>

View File

@ -1,12 +0,0 @@
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade
@openupgrade.migrate()
def migrate(env, version):
openupgrade.load_data(
env,
"document_page_access_group",
"migrations/17.0.1.1.0/noupdate_changes.xml",
)

View File

@ -2,7 +2,7 @@
# Copyright 2024 Tecnativa - Víctor Martínez # Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). # 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 from odoo.exceptions import UserError
@ -15,5 +15,7 @@ class DocumentPage(models.Model):
@api.constrains("groups_id", "user_ids") @api.constrains("groups_id", "user_ids")
def check_document_page_groups_users(self): def check_document_page_groups_users(self):
for _item in self.filtered(lambda x: x.groups_id and x.user_ids): 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 return True

View File

@ -3,3 +3,5 @@
* `Tecnativa <https://www.tecnativa.com>`_: * `Tecnativa <https://www.tecnativa.com>`_:
* Víctor Martínez * Víctor Martínez
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
- Bhavesh Heliconia

View File

@ -8,7 +8,7 @@
<field eval="False" name="global" /> <field eval="False" name="global" />
<field <field
name="groups" name="groups"
eval="[(4, ref('document_knowledge.group_document_user'))]" eval="[Command.link(ref('document_knowledge.group_document_user'))]"
/> />
<field <field
name="domain_force" name="domain_force"
@ -20,7 +20,7 @@
<field eval="False" name="global" /> <field eval="False" name="global" />
<field <field
name="groups" 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> <field name="domain_force">[(1, '=', 1)]</field>
</record> </record>

View File

@ -369,7 +369,7 @@ ul.auto-toc {
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:28e06c90139270717bf9f3fbe04145a72fed721a256eb4d526ee229beaf1cc69 !! 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 <p>This module allows to select which users groups have access to the
document pages.</p> document pages.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
@ -392,8 +392,7 @@ to open a document, go to the Security tab and you have 3 options:</p>
<ul class="simple"> <ul class="simple">
<li>Select a group: Only users with those groups will be able to see the <li>Select a group: Only users with those groups will be able to see the
page.</li> page.</li>
<li>Select any user: Only the selected users will be able to see the <li>Select any user: Only the selected users will be able to see the page.</li>
page.</li>
<li>Do not select group or user: All 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> </ul>
</div> </div>
@ -402,7 +401,7 @@ page.</li>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/knowledge/issues">GitHub Issues</a>. <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. 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 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> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -422,6 +421,10 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<li>Víctor Martínez</li> <li>Víctor Martínez</li>
</ul> </ul>
</li> </li>
<li><a class="reference external" href="https://www.heliconia.io">Heliconia Solutions Pvt. Ltd.</a><ul>
<li>Bhavesh Heliconia</li>
</ul>
</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
@ -433,7 +436,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> 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> <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>
</div> </div>

View File

@ -1,4 +1,5 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # 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.tests import new_test_user
from odoo.addons.base.tests.common import BaseCommon from odoo.addons.base.tests.common import BaseCommon
@ -17,7 +18,7 @@ class TestDocumentPageAccessGroupBase(BaseCommon):
login="test-manager-user", login="test-manager-user",
groups="document_knowledge.group_document_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( cls.public_page = cls.env["document.page"].create(
{"name": "Public Page", "type": "content"} {"name": "Public Page", "type": "content"}
) )
@ -25,13 +26,13 @@ class TestDocumentPageAccessGroupBase(BaseCommon):
{ {
"name": "Knowledge Page", "name": "Knowledge Page",
"type": "content", "type": "content",
"groups_id": [(6, 0, [cls.group.id])], "groups_id": [Command.set([cls.group.id])],
} }
) )
cls.user_page = cls.env["document.page"].create( cls.user_page = cls.env["document.page"].create(
{ {
"name": "User Page (basic user)", "name": "User Page (basic user)",
"type": "content", "type": "content",
"user_ids": [(6, 0, [cls.user.id])], "user_ids": [Command.set([cls.user.id])],
} }
) )

View File

@ -1,4 +1,5 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import Command
from odoo.exceptions import UserError from odoo.exceptions import UserError
from odoo.tests.common import users from odoo.tests.common import users
@ -8,7 +9,7 @@ from .common import TestDocumentPageAccessGroupBase
class TestDocumentPageAccessGroup(TestDocumentPageAccessGroupBase): class TestDocumentPageAccessGroup(TestDocumentPageAccessGroupBase):
def test_page_access_constrains(self): def test_page_access_constrains(self):
with self.assertRaises(UserError): 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") @users("test-user")
def test_page_access_01(self): def test_page_access_01(self):