Skip to content

[18.0][MIG] base_portal_type: Migration to 18.0 #353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions base_portal_type/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
============
Portal types
============

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f6552e1fb54368304e258e85090d45598992675542c1fef6b16f439950226f68
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github
:target: https://github.com/OCA/server-backend/tree/18.0/base_portal_type
:alt: OCA/server-backend
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-backend-18-0/server-backend-18-0-base_portal_type
: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/server-backend&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows administrator to configure groups for portal users,
which is not possible with standard Odoo.

That's useful for having different types of portal users (think
differentiate vendors from customers) and leveraging Odoo's group
mechanism for ie views instead having to cook up custom solutions.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

1. create a group of category ``base_portal_type.category_portal_type``
2. observe the group shows up on a user form for users of type Portal
3. now you can use this group in your frontend templates and code to
make some features accessible to this group

Known issues / Roadmap
======================

- allowing to chose portal groups in the portal wizard would be nice

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-backend/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/server-backend/issues/new?body=module:%20base_portal_type%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.

Credits
=======

Authors
-------

* Hunki Enterprises BV

Contributors
------------

- Holger Brunn <[email protected]>
(https://hunki-enterprises.com)
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__

- Bhavesh Heliconia

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

.. |maintainer-hbrunn| image:: https://github.com/hbrunn.png?size=40px
:target: https://github.com/hbrunn
:alt: hbrunn

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-hbrunn|

This module is part of the `OCA/server-backend <https://github.com/OCA/server-backend/tree/18.0/base_portal_type>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions base_portal_type/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
23 changes: 23 additions & 0 deletions base_portal_type/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2023 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)

{
"name": "Portal types",
"summary": "Base module to allow different types of portals",
"version": "18.0.1.0.0",
"development_status": "Alpha",
"category": "Technical",
"website": "https://github.com/OCA/server-backend",
"author": "Hunki Enterprises BV, Odoo Community Association (OCA)",
"maintainers": ["hbrunn"],
"license": "AGPL-3",
"depends": [
"portal",
],
"data": [
"data/ir_module_category.xml",
],
"demo": [
"demo/res_groups.xml",
],
}
8 changes: 8 additions & 0 deletions base_portal_type/data/ir_module_category.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Hunki Enterprises BV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) -->
<data>
<record id="category_portal_type" model="ir.module.category">
<field name="name">Portal type</field>
</record>
</data>
9 changes: 9 additions & 0 deletions base_portal_type/demo/res_groups.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Hunki Enterprises BV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) -->
<data>
<record id="group_portal_type" model="res.groups">
<field name="name">A portal type</field>
<field name="category_id" ref="category_portal_type" />
</record>
</data>
29 changes: 29 additions & 0 deletions base_portal_type/i18n/base_portal_type.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_portal_type
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: base_portal_type
#: model:res.groups,name:base_portal_type.group_portal_type
msgid "A portal type"
msgstr ""

#. module: base_portal_type
#: model:ir.model,name:base_portal_type.model_res_groups
msgid "Access Groups"
msgstr ""

#. module: base_portal_type
#: model:ir.module.category,name:base_portal_type.category_portal_type
msgid "Portal type"
msgstr ""
32 changes: 32 additions & 0 deletions base_portal_type/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_portal_type
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-01-03 14:34+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: base_portal_type
#: model:res.groups,name:base_portal_type.group_portal_type
msgid "A portal type"
msgstr "Un tipo portale"

#. module: base_portal_type
#: model:ir.model,name:base_portal_type.model_res_groups
msgid "Access Groups"
msgstr "Gruppi di accesso"

#. module: base_portal_type
#: model:ir.module.category,name:base_portal_type.category_portal_type
msgid "Portal type"
msgstr "Tipo portale"
1 change: 1 addition & 0 deletions base_portal_type/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import res_groups
79 changes: 79 additions & 0 deletions base_portal_type/models/res_groups.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Copyright 2023 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)


from lxml import etree

from odoo import api, models

from odoo.addons.base.models.res_users import name_boolean_group, name_selection_groups


class ResGroups(models.Model):
_inherit = "res.groups"

@api.model
def _update_user_groups_view(self):
result = super()._update_user_groups_view()
view = self.env.ref("base.user_groups_view")
arch = etree.fromstring(view.arch)
user_type_groups = [
groups
for app, kind, groups, category in self.get_groups_by_application()
if app.xml_id == "base.module_category_user_type"
][0]
portal_group = self.env.ref("base.group_portal")
internal_group = self.env.ref("base.group_user")
portal_groups = (
self.env["res.groups"]
.with_context(lang=None)
.search(
[
(
"category_id",
"=",
self.env.ref("base_portal_type.category_portal_type").id,
),
]
)
)
user_type_field = name_selection_groups(user_type_groups.ids)
for node in arch.xpath(f"//group/field[@name='{user_type_field}']"):
for group in portal_groups:
field_name = name_boolean_group(group.id)
for field_node in arch.xpath(f"//field[@name='{field_name}']"):
field_node.attrib["readonly"] = (
f"{user_type_field} not in "
f"{(portal_group + internal_group).ids}"
)
node.addnext(
etree.Element(
"field",
{
"name": field_name,
"on_change": "1",
"invisible": f"{user_type_field} != {portal_group.id}",
},
)
)
view_context = dict(self.env.context, lang=None)
view_context.pop("install_filename", None)
# pylint: disable=context-overridden
view.with_context(view_context).write(
{"arch": etree.tostring(arch, pretty_print=True, encoding="unicode")}
)
return result

@api.model
def get_groups_by_application(self):
return [
(
app,
kind
if app.xml_id != "base_portal_type.category_portal_type"
else "boolean",
groups,
category,
)
for app, kind, groups, category in super().get_groups_by_application()
]
3 changes: 3 additions & 0 deletions base_portal_type/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
4 changes: 4 additions & 0 deletions base_portal_type/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Holger Brunn \<[email protected]\>
(<https://hunki-enterprises.com>)
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
- Bhavesh Heliconia
6 changes: 6 additions & 0 deletions base_portal_type/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This module allows administrator to configure groups for portal users,
which is not possible with standard Odoo.

That's useful for having different types of portal users (think
differentiate vendors from customers) and leveraging Odoo's group
mechanism for ie views instead having to cook up custom solutions.
1 change: 1 addition & 0 deletions base_portal_type/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- allowing to chose portal groups in the portal wizard would be nice
6 changes: 6 additions & 0 deletions base_portal_type/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
To use this module, you need to:

1. create a group of category `base_portal_type.category_portal_type`
2. observe the group shows up on a user form for users of type Portal
3. now you can use this group in your frontend templates and code to
make some features accessible to this group
Binary file added base_portal_type/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading