diff --git a/base_group_backend/README.rst b/base_group_backend/README.rst new file mode 100644 index 00000000..71120920 --- /dev/null +++ b/base_group_backend/README.rst @@ -0,0 +1,181 @@ +============= +Group backend +============= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:879007f368a0b75ad5da7f5d3e3d1d6ae386da26d27df7fc4dec1a6865cf0233 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github + :target: https://github.com/OCA/server-backend/tree/16.0/base_group_backend + :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-16-0/server-backend-16-0-base_group_backend + :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=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module was written to extend the standard functionality regarding users +and groups management by adding a new `Backend user` group that only gives access +to odoo backend (`/web`): + +* minimal default access: + * users and partners (this is necessary to access your own data) + * mail activity, notification and channel + * presence +* minimal default menu + * notification + * activities +* minimal default access rules + +The problem with the `Internal user` is when you want to gives access to the +backend to a really thin part of your business to some users, it's quite hard +to properly maintain those roles over the project life, a lot of models use +that group (`base.group_user`) by default which makes hard to maintains. + +So that helps creating well-defined user groups with more controls. + +This modules does 3 things: +* It hijack the has_group method of res.users by returning True for group_backend users when the requested group is group_user (The need for this needs to be investigated) +* It sets the res_users.share to False for group_backend users. This allows those users to access the backend. +* It sets the bare minimum permission in the ir.model.access.csv to display the backend + +We suggest to use this module with its compagnon `base_user_role` + + +Here is an example where a backend ui user can only access and use the dummy app. No other application are available to this user. You may define your own application instead of the dummy one. + +.. figure:: https://raw.githubusercontent.com/OCA/server-backend/16.0/base_group_backend/static/description/dummy_app.png + :alt: Dummy app for demo + + + +Limitations +~~~~~~~~~~~ + +At the time of writing, Odoo uses `res.users.share == False` to give the +backend access. +However to be able to access the backend without any errors some basic rights are necessary. +This module change the way `res.users.share` is computed to allow `group_backend users` to use the backend. + +This avoids to write a lot of overwrite in different controllers from +different modules ('portal', 'web', 'base', 'website') with hard coded statements +that check if user is part of the `base.group_user` or `share == False` group. + +.. warning:: + + Using this module and grant a user with `group_backend`'s group is + equivalent to grant `group_user`'s group everywhere `has_group` + has been used. + +.. 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 `_ + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To allow `group_backend` to interact with a model you can either add access rules to the group +or you can add `implied_ids` to `group_backend`. + +.. note:: + + Be aware users can only belong to one group from the user type category + (`base.module_category_user_type`). So your other groups can't inherit both + internal users and backend users. + +Usage +===== + +To use this module, you need to: + +#. Go to Configuration / Users / Users, choose a user and set the user type. + +You get a users that is only able to access to the Odoo backend which you +can attach other groups that not implies other kind of users (`portal`, +`internal users`) + +.. figure:: https://raw.githubusercontent.com/OCA/server-backend/16.0/base_group_backend/static/description/backend_ui.png + :alt: Backend UI user + +Known issues / Roadmap +====================== + +Current module depends on `base_install_request` instead of `base`. + +We don't need `base_install_request` auto install module but we must override it to set a security group on `App` menu. + +This dependency should be remove if possible in future versions. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Pierre Verkest + +Contributors +~~~~~~~~~~~~ + +* Pierre Verkest +* François Poizat + +Do not contact contributors directly about support or help with technical issues. + +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-FranzPoize| image:: https://github.com/FranzPoize.png?size=40px + :target: https://github.com/FranzPoize + :alt: FranzPoize +.. |maintainer-bealdav| image:: https://github.com/bealdav.png?size=40px + :target: https://github.com/bealdav + :alt: bealdav + +Current `maintainers `__: + +|maintainer-FranzPoize| |maintainer-bealdav| + +This module is part of the `OCA/server-backend `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_group_backend/__init__.py b/base_group_backend/__init__.py new file mode 100644 index 00000000..fc95f8e7 --- /dev/null +++ b/base_group_backend/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import demo diff --git a/base_group_backend/__manifest__.py b/base_group_backend/__manifest__.py new file mode 100644 index 00000000..6b4af75f --- /dev/null +++ b/base_group_backend/__manifest__.py @@ -0,0 +1,30 @@ +# Copyright 2021 Pierre Verkest +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Group backend", + "version": "16.0.1.0.0", + "development_status": "Alpha", + "category": "Tools", + "author": "Pierre Verkest, Odoo Community Association (OCA)", + "license": "LGPL-3", + "website": "https://github.com/OCA/server-backend", + "depends": [ + "base", + "base_install_request", # weird module, we need to survive with it + "mail", + ], + "maintainers": ["FranzPoize", "bealdav"], + "demo": [ + "demo/test-model.xml", + "demo/ir.model.access.csv", + "demo/backend_dummy_model.xml", + "demo/res_partners.xml", + "demo/res_users.xml", + ], + "data": [ + "data/res_groups.xml", + "data/ir_ui_menu.xml", + "security/ir.model.access.csv", + ], + "installable": True, +} diff --git a/base_group_backend/data/ir_ui_menu.xml b/base_group_backend/data/ir_ui_menu.xml new file mode 100644 index 00000000..a8a80e10 --- /dev/null +++ b/base_group_backend/data/ir_ui_menu.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/base_group_backend/data/res_groups.xml b/base_group_backend/data/res_groups.xml new file mode 100644 index 00000000..db3df006 --- /dev/null +++ b/base_group_backend/data/res_groups.xml @@ -0,0 +1,43 @@ + + + + Backend user + + + This group is used to gives user backend access. + + While users in `base.group_user` gets a lot of default access + which makes hard to define properly records/rules/menu access. + + So for maintainability you shouldn't linked any access right, rules, + menu, and so on to this group directly. + + The only intent of this groups is to be able to get a session + to Odoo backend (`/web`). + + + + + Backend UI user + + + This group is used to gives user basic ui access. + + + + + diff --git a/base_group_backend/demo/__init__.py b/base_group_backend/demo/__init__.py new file mode 100644 index 00000000..87682b5e --- /dev/null +++ b/base_group_backend/demo/__init__.py @@ -0,0 +1,4 @@ +from odoo.tools import config + +if not config["without_demo"]: + from . import backend_dummy_model diff --git a/base_group_backend/demo/backend_dummy_model.py b/base_group_backend/demo/backend_dummy_model.py new file mode 100644 index 00000000..649f2241 --- /dev/null +++ b/base_group_backend/demo/backend_dummy_model.py @@ -0,0 +1,15 @@ +from odoo import fields, models + + +class BackendDummyModel(models.Model): + _name = "backend.dummy.model" + _description = "Backend Dummy Model demo" + + my_value = fields.Char(name="Value", required=True) + my_other_value = fields.Char(name="Other value", required=True) + date_start = fields.Datetime( + name="Date start", required=True, default=fields.Datetime.now + ) + date_stop = fields.Datetime( + name="Date stop", required=True, default=fields.Datetime.now + ) diff --git a/base_group_backend/demo/backend_dummy_model.xml b/base_group_backend/demo/backend_dummy_model.xml new file mode 100644 index 00000000..ade0d44c --- /dev/null +++ b/base_group_backend/demo/backend_dummy_model.xml @@ -0,0 +1,44 @@ + + + + Backend dummy tree view + backend.dummy.model + + + + + + + + + + Dummies + ir.actions.act_window + backend.dummy.model + tree,form,kanban,calendar,pivot,graph,activity + + + + + + + + diff --git a/base_group_backend/demo/ir.model.access.csv b/base_group_backend/demo/ir.model.access.csv new file mode 100644 index 00000000..6c353bcb --- /dev/null +++ b/base_group_backend/demo/ir.model.access.csv @@ -0,0 +1,3 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +"backend_dummy_models","backend dummy.model","model_backend_dummy_model",group_backend_ui_users,1,0,0,0 +"backend_dummy_models_user_grp","backend dummy.model user grp","model_backend_dummy_model",base.group_user,1,0,0,0 diff --git a/base_group_backend/demo/res_partners.xml b/base_group_backend/demo/res_partners.xml new file mode 100644 index 00000000..32b45580 --- /dev/null +++ b/base_group_backend/demo/res_partners.xml @@ -0,0 +1,12 @@ + + + + Demo partner backend + + + Demo partner backend 1 + + + Demo partner backend 2 + + diff --git a/base_group_backend/demo/res_users.xml b/base_group_backend/demo/res_users.xml new file mode 100644 index 00000000..37baa44a --- /dev/null +++ b/base_group_backend/demo/res_users.xml @@ -0,0 +1,21 @@ + + + + demo backend user + + + + + demo backend user 1 + + + + + demo backend user 2 + + + + diff --git a/base_group_backend/demo/test-model.xml b/base_group_backend/demo/test-model.xml new file mode 100644 index 00000000..3ced409a --- /dev/null +++ b/base_group_backend/demo/test-model.xml @@ -0,0 +1,7 @@ + + + + hello + hello + + diff --git a/base_group_backend/models/__init__.py b/base_group_backend/models/__init__.py new file mode 100644 index 00000000..88351653 --- /dev/null +++ b/base_group_backend/models/__init__.py @@ -0,0 +1 @@ +from . import res_users diff --git a/base_group_backend/models/res_users.py b/base_group_backend/models/res_users.py new file mode 100644 index 00000000..87a6c248 --- /dev/null +++ b/base_group_backend/models/res_users.py @@ -0,0 +1,50 @@ +import logging + +from odoo import api, models + +_logger = logging.getLogger(__name__) + + +class Users(models.Model): + _inherit = "res.users" + + @api.model + def has_group(self, group_ext_id): + """While ensuring a user is part of `base.group_user` this code will + try if user is in the `base_group_backend.group_backend` group to let access + to the odoo backend. + + This code avoid to overwrite a lot of places in controllers from + different modules ('portal', 'web', 'base') with hardcoded statement + that check if user is part of `base.group_user` group. + + As far `base.group_user` have a lot of default permission this + makes hard to maintain proper access right according your business. + """ + res = super().has_group(group_ext_id) + if not res and (group_ext_id == "base.group_user"): + has_base_group_backend = super().has_group( + "base_group_backend.base_group_backend" + ) or super().has_group("base_group_backend.group_backend_ui_users") + if has_base_group_backend: + _logger.warning( + "Forcing has_group to return True" + + " for group_backend and base_group_backend_ui_users" + ) + return has_base_group_backend + return res + + @api.depends("groups_id") + def _compute_share(self): + res = super()._compute_share() + backend_user_group_id = self.env["ir.model.data"]._xmlid_to_res_id( + "base_group_backend.base_group_backend" + ) + backend_ui_user_group_id = self.env["ir.model.data"]._xmlid_to_res_id( + "base_group_backend.group_backend_ui_users" + ) + internal_users = self.filtered_domain( + [("groups_id", "in", [backend_user_group_id, backend_ui_user_group_id])] + ) + internal_users.share = False + return res diff --git a/base_group_backend/readme/CONFIGURE.rst b/base_group_backend/readme/CONFIGURE.rst new file mode 100644 index 00000000..e480b4f2 --- /dev/null +++ b/base_group_backend/readme/CONFIGURE.rst @@ -0,0 +1,8 @@ +To allow `group_backend` to interact with a model you can either add access rules to the group +or you can add `implied_ids` to `group_backend`. + +.. note:: + + Be aware users can only belong to one group from the user type category + (`base.module_category_user_type`). So your other groups can't inherit both + internal users and backend users. diff --git a/base_group_backend/readme/CONTRIBUTORS.rst b/base_group_backend/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..f8032a3b --- /dev/null +++ b/base_group_backend/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Pierre Verkest +* François Poizat + +Do not contact contributors directly about support or help with technical issues. diff --git a/base_group_backend/readme/DESCRIPTION.rst b/base_group_backend/readme/DESCRIPTION.rst new file mode 100644 index 00000000..83169020 --- /dev/null +++ b/base_group_backend/readme/DESCRIPTION.rst @@ -0,0 +1,52 @@ +This module was written to extend the standard functionality regarding users +and groups management by adding a new `Backend user` group that only gives access +to odoo backend (`/web`): + +* minimal default access: + * users and partners (this is necessary to access your own data) + * mail activity, notification and channel + * presence +* minimal default menu + * notification + * activities +* minimal default access rules + +The problem with the `Internal user` is when you want to gives access to the +backend to a really thin part of your business to some users, it's quite hard +to properly maintain those roles over the project life, a lot of models use +that group (`base.group_user`) by default which makes hard to maintains. + +So that helps creating well-defined user groups with more controls. + +This modules does 3 things: +* It hijack the has_group method of res.users by returning True for group_backend users when the requested group is group_user (The need for this needs to be investigated) +* It sets the res_users.share to False for group_backend users. This allows those users to access the backend. +* It sets the bare minimum permission in the ir.model.access.csv to display the backend + +We suggest to use this module with its compagnon `base_user_role` + + +Here is an example where a backend ui user can only access and use the dummy app. No other application are available to this user. You may define your own application instead of the dummy one. + +.. figure:: ../static/description/dummy_app.png + :alt: Dummy app for demo + + + +Limitations +~~~~~~~~~~~ + +At the time of writing, Odoo uses `res.users.share == False` to give the +backend access. +However to be able to access the backend without any errors some basic rights are necessary. +This module change the way `res.users.share` is computed to allow `group_backend users` to use the backend. + +This avoids to write a lot of overwrite in different controllers from +different modules ('portal', 'web', 'base', 'website') with hard coded statements +that check if user is part of the `base.group_user` or `share == False` group. + +.. warning:: + + Using this module and grant a user with `group_backend`'s group is + equivalent to grant `group_user`'s group everywhere `has_group` + has been used. diff --git a/base_group_backend/readme/ROADMAP.rst b/base_group_backend/readme/ROADMAP.rst new file mode 100644 index 00000000..5190afe1 --- /dev/null +++ b/base_group_backend/readme/ROADMAP.rst @@ -0,0 +1,5 @@ +Current module depends on `base_install_request` instead of `base`. + +We don't need `base_install_request` auto install module but we must override it to set a security group on `App` menu. + +This dependency should be remove if possible in future versions. diff --git a/base_group_backend/readme/USAGE.rst b/base_group_backend/readme/USAGE.rst new file mode 100644 index 00000000..eab476ce --- /dev/null +++ b/base_group_backend/readme/USAGE.rst @@ -0,0 +1,10 @@ +To use this module, you need to: + +#. Go to Configuration / Users / Users, choose a user and set the user type. + +You get a users that is only able to access to the Odoo backend which you +can attach other groups that not implies other kind of users (`portal`, +`internal users`) + +.. figure:: ../static/description/backend_ui.png + :alt: Backend UI user diff --git a/base_group_backend/security/ir.model.access.csv b/base_group_backend/security/ir.model.access.csv new file mode 100644 index 00000000..1746a239 --- /dev/null +++ b/base_group_backend/security/ir.model.access.csv @@ -0,0 +1,33 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +backend_ui_users_ir_default,backend_ui_users_ir_default,base.model_ir_default,group_backend_ui_users,1,1,1,1 +backend_ui_users_ir_filters,backend_ui_users_ir_filters,base.model_ir_filters,group_backend_ui_users,1,1,1,1 +backend_ui_users_ir_model,backend_ui_users_ir_model,base.model_ir_model,group_backend_ui_users,1,0,0,0 +backend_ui_users_ir_model_fields,backend_ui_users_ir_model_fields,base.model_ir_model_fields,group_backend_ui_users,1,0,0,0 +backend_ui_users_ir_model_data,backend_ui_users_ir_model_data,base.model_ir_model_data,group_backend_ui_users,1,0,1,0 +backend_ui_users_ir_model_fields_selection,backend_ui_users_ir_model_fields_selection,base.model_ir_model_fields_selection,group_backend_ui_users,1,0,0,0 +backend_ui_users_ir_sequence,backend_ui_users_ir_sequence,base.model_ir_sequence,group_backend_ui_users,1,0,0,0 +backend_ui_users_ir_sequence_date_range,backend_ui_users_ir_sequence_date_range,base.model_ir_sequence_date_range,group_backend_ui_users,1,0,0,0 +backend_ui_users_ir_ui_menu,backend_ui_users_ir_ui_menu,base.model_ir_ui_menu,group_backend_ui_users,1,0,0,0 +backend_ui_users_ir_attachment,backend_ui_users_ir_attachment,base.model_ir_attachment,group_backend_ui_users,1,0,1,0 +backend_ui_users_res_partner,backend_ui_users_res_partner,base.model_res_partner,group_backend_ui_users,1,0,0,0 +backend_ui_users_bus_presence,backend_ui_users_bus_presence,bus.model_bus_presence,group_backend_ui_users,1,1,1,1 +backend_ui_users_mail_channel_member_public,backend_ui_users_mail_channel_member,mail.model_mail_channel_member,group_backend_ui_users,1,1,1,0 +backend_ui_users_mail_channel_public,backend_ui_users_mail_channel_member,mail.model_mail_channel,group_backend_ui_users,1,1,1,0 +backend_ui_users_mail_activity,backend_ui_users_mail_activity,mail.model_mail_activity,group_backend_ui_users,1,1,1,1 +backend_ui_users_mail_activity_type,backend_ui_users_mail_activity_type,mail.model_mail_activity_type,group_backend_ui_users,1,0,0,0 +backend_ui_users_mail_followers,backend_ui_users_mail_followers,mail.model_mail_followers,group_backend_ui_users,1,0,0,0 +backend_ui_users_mail_mail,backend_ui_users_mail_mail,mail.model_mail_mail,group_backend_ui_users,0,0,0,0 +backend_ui_users_mail_compose_message,backend_ui_users_mail_compose_message,mail.model_mail_compose_message,group_backend_ui_users,1,1,1,0 +backend_ui_users_mail_wizard_invite,backend_ui_users_mail_wizard_invite,mail.model_mail_wizard_invite,group_backend_ui_users,1,1,1,0 +backend_ui_users_mail_template,backend_ui_users_mail_template,mail.model_mail_template,group_backend_ui_users,1,0,0,0 +backend_ui_users_mail_template_preview,backend_ui_users_mail_template_preview,mail.model_mail_template_preview,group_backend_ui_users,1,0,0,0 +backend_ui_users_mail_message,backend_ui_users_mail_message,mail.model_mail_message,group_backend_ui_users,1,1,1,0 +backend_ui_users_mail_resend_message,backend_ui_users_mail_resend_message,mail.model_mail_resend_message,group_backend_ui_users,1,1,1,0 +backend_ui_users_mail_notification,backend_ui_users_mail_notification,mail.model_mail_notification,group_backend_ui_users,1,1,1,1 +backend_ui_users_mail_alias,backend_ui_users_mail_alias,mail.model_mail_alias,group_backend_ui_users,1,0,0,0 +backend_ui_users_res_groups,backend_ui_users_res_groups,base.model_res_groups,group_backend_ui_users,1,0,0,0 +backend_ui_users_res_partner_category,backend_ui_users_res_partner_category,base.model_res_partner_category,group_backend_ui_users,1,0,0,0 +backend_ui_users_res_partner_industry,backend_ui_users_res_partner_industry,base.model_res_partner_industry,group_backend_ui_users,1,0,0,0 +backend_ui_users_res_users_identitycheck,backend_ui_users_res_users_identitycheck,base.model_res_users_identitycheck,group_backend_ui_users,1,1,1,0 +backend_ui_users_res_bank,backend_ui_users_res_bank,base.model_res_bank,group_backend_ui_users,1,0,0,0 +backend_ui_users_res_partner_bank,backend_ui_users_res_partner_bank,base.model_res_partner_bank,group_backend_ui_users,1,0,0,0 diff --git a/base_group_backend/static/description/backend_ui.png b/base_group_backend/static/description/backend_ui.png new file mode 100644 index 00000000..f0c6a0b8 Binary files /dev/null and b/base_group_backend/static/description/backend_ui.png differ diff --git a/base_group_backend/static/description/dummy_app.png b/base_group_backend/static/description/dummy_app.png new file mode 100644 index 00000000..70bd4571 Binary files /dev/null and b/base_group_backend/static/description/dummy_app.png differ diff --git a/base_group_backend/static/description/index.html b/base_group_backend/static/description/index.html new file mode 100644 index 00000000..bfe6eafd --- /dev/null +++ b/base_group_backend/static/description/index.html @@ -0,0 +1,501 @@ + + + + + + +Group backend + + + +
+

Group backend

+ + +

Alpha License: LGPL-3 OCA/server-backend Translate me on Weblate Try me on Runboat

+

This module was written to extend the standard functionality regarding users +and groups management by adding a new Backend user group that only gives access +to odoo backend (/web):

+
    +
  • minimal default access: +* users and partners (this is necessary to access your own data) +* mail activity, notification and channel +* presence
  • +
  • minimal default menu +* notification +* activities
  • +
  • minimal default access rules
  • +
+

The problem with the Internal user is when you want to gives access to the +backend to a really thin part of your business to some users, it’s quite hard +to properly maintain those roles over the project life, a lot of models use +that group (base.group_user) by default which makes hard to maintains.

+

So that helps creating well-defined user groups with more controls.

+

This modules does 3 things: +* It hijack the has_group method of res.users by returning True for group_backend users when the requested group is group_user (The need for this needs to be investigated) +* It sets the res_users.share to False for group_backend users. This allows those users to access the backend. +* It sets the bare minimum permission in the ir.model.access.csv to display the backend

+

We suggest to use this module with its compagnon base_user_role

+

Here is an example where a backend ui user can only access and use the dummy app. No other application are available to this user. You may define your own application instead of the dummy one.

+
+Dummy app for demo +
+
+

Limitations

+

At the time of writing, Odoo uses res.users.share == False to give the +backend access. +However to be able to access the backend without any errors some basic rights are necessary. +This module change the way res.users.share is computed to allow group_backend users to use the backend.

+

This avoids to write a lot of overwrite in different controllers from +different modules (‘portal’, ‘web’, ‘base’, ‘website’) with hard coded statements +that check if user is part of the base.group_user or share == False group.

+
+

Warning

+

Using this module and grant a user with group_backend’s group is +equivalent to grant group_user’s group everywhere has_group +has been used.

+
+
+

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

+
+

Table of contents

+ +
+

Configuration

+

To allow group_backend to interact with a model you can either add access rules to the group +or you can add implied_ids to group_backend.

+
+

Note

+

Be aware users can only belong to one group from the user type category +(base.module_category_user_type). So your other groups can’t inherit both +internal users and backend users.

+
+
+
+

Usage

+

To use this module, you need to:

+
    +
  1. Go to Configuration / Users / Users, choose a user and set the user type.
  2. +
+

You get a users that is only able to access to the Odoo backend which you +can attach other groups that not implies other kind of users (portal, +internal users)

+
+Backend UI user +
+
+
+

Known issues / Roadmap

+

Current module depends on base_install_request instead of base.

+

We don’t need base_install_request auto install module but we must override it to set a security group on App menu.

+

This dependency should be remove if possible in future versions.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+ +
+
+

Authors

+
    +
  • Pierre Verkest
  • +
+
+
+

Contributors

+ +

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

+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainers:

+

FranzPoize bealdav

+

This module is part of the OCA/server-backend project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+ + diff --git a/base_group_backend/tests/__init__.py b/base_group_backend/tests/__init__.py new file mode 100644 index 00000000..d9b96c4f --- /dev/null +++ b/base_group_backend/tests/__init__.py @@ -0,0 +1 @@ +from . import test_module diff --git a/base_group_backend/tests/test_module.py b/base_group_backend/tests/test_module.py new file mode 100644 index 00000000..ec209805 --- /dev/null +++ b/base_group_backend/tests/test_module.py @@ -0,0 +1,31 @@ +from odoo import Command +from odoo.tests.common import TransactionCase + + +class TestResUsers(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.base_group_backend = cls.env.ref("base_group_backend.base_group_backend") + cls.internal_user = cls.env.ref("base.user_demo") + cls.portal_user = cls.env.ref("base_group_backend.user_demo_external") + cls.portal_ui_user = cls.env.ref( + "base_group_backend.user_demo_external_with_ui" + ) + + def test_has_groups(self): + self.assertTrue(self.internal_user.has_group("base.group_user")) + self.assertFalse(self.portal_user.has_group("base.group_user")) + self.assertTrue(self.portal_ui_user.has_group("base.group_user")) + self.portal_user.write( + {"groups_id": [Command.set([self.base_group_backend.id])]} + ) + self.assertTrue(self.portal_user.has_group("base.group_user")) + + def test_share(self): + self.assertTrue(self.portal_user.share) + self.portal_user.write( + {"groups_id": [Command.set([self.base_group_backend.id])]} + ) + self.assertFalse(self.portal_user.share) + self.assertFalse(self.portal_ui_user.share) diff --git a/setup/base_group_backend/odoo/addons/base_group_backend b/setup/base_group_backend/odoo/addons/base_group_backend new file mode 120000 index 00000000..99760248 --- /dev/null +++ b/setup/base_group_backend/odoo/addons/base_group_backend @@ -0,0 +1 @@ +../../../../base_group_backend \ No newline at end of file diff --git a/setup/base_group_backend/setup.py b/setup/base_group_backend/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/base_group_backend/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)