diff --git a/setup/website_menu_by_user_status/odoo/addons/website_menu_by_user_status b/setup/website_menu_by_user_status/odoo/addons/website_menu_by_user_status new file mode 120000 index 0000000000..a8109a7f6e --- /dev/null +++ b/setup/website_menu_by_user_status/odoo/addons/website_menu_by_user_status @@ -0,0 +1 @@ +../../../../website_menu_by_user_status \ No newline at end of file diff --git a/setup/website_menu_by_user_status/setup.py b/setup/website_menu_by_user_status/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/website_menu_by_user_status/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/website_menu_by_user_status/README.rst b/website_menu_by_user_status/README.rst new file mode 100644 index 0000000000..6a2aea1912 --- /dev/null +++ b/website_menu_by_user_status/README.rst @@ -0,0 +1,98 @@ +============================ +Website Menu By User Display +============================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a2ff455071078badb7f6294ce0f6ac5e994792077e5e29a49ff0fa8bec350232 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |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%2Fwebsite-lightgray.png?logo=github + :target: https://github.com/OCA/website/tree/16.0/website_menu_by_user_status + :alt: OCA/website +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/website-16-0/website-16-0-website_menu_by_user_status + :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/website&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +The module manages display website menu entries, depending if the user is +logged or not. +The selection of the display status can be chosen logged and/or not. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +#. Go to Website > Configuration > Settings > Pages. +#. Select the page for which you would like to hide the menu. +#. In the `Related Menu Items` table, check whether the menu item is visible for logged/unlogged users. + +#. remove default filter to edit website menu line + +Known issues / Roadmap +====================== + +* 2 flags will just toggle specific groups automatically [based on https://github.com/OCA/website/tree/11.0/website_menu_permission] + +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 +~~~~~~~ + +* Savoir-faire Linux + +Contributors +~~~~~~~~~~~~ + +* Bruno Joliveau +* Jordi Riera +* Meyomesse Gilles +* David Dufresne +* Kaushal Prajapati + +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. + +This module is part of the `OCA/website `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/website_menu_by_user_status/__init__.py b/website_menu_by_user_status/__init__.py new file mode 100644 index 0000000000..69f7babdfb --- /dev/null +++ b/website_menu_by_user_status/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/website_menu_by_user_status/__manifest__.py b/website_menu_by_user_status/__manifest__.py new file mode 100644 index 0000000000..3a10143569 --- /dev/null +++ b/website_menu_by_user_status/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2013-2017 Savoir-faire Linux () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "Website Menu By User Display", + "version": "16.0.1.0.0", + "author": "Savoir-faire Linux,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/website", + "license": "AGPL-3", + "category": "Website", + "summary": "Allow to manage the display of website.menus", + "depends": ["website"], + "data": ["views/website_menu.xml"], + "installable": True, +} diff --git a/website_menu_by_user_status/i18n/ca.po b/website_menu_by_user_status/i18n/ca.po new file mode 100644 index 0000000000..bff41e392b --- /dev/null +++ b/website_menu_by_user_status/i18n/ca.po @@ -0,0 +1,65 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_menu_by_user_status +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-02-23 12:45+0000\n" +"Last-Translator: claudiagn \n" +"Language-Team: none\n" +"Language: ca\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.3.2\n" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__display_name +msgid "Display Name" +msgstr "" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__id +msgid "ID" +msgstr "" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,help:website_menu_by_user_status.field_website_menu__user_logged +msgid "" +"If checked, the menu will be displayed when the user is logged and give " +"access." +msgstr "" +"Si està marcat, el menú es mostrarà quan l'usuari estigui registrat i hi " +"doni accés." + +#. module: website_menu_by_user_status +#: model:ir.model.fields,help:website_menu_by_user_status.field_website_menu__user_not_logged +msgid "" +"If checked, the menu will be displayed when the user is not logged and give " +"access." +msgstr "" +"Si està marcat, el menú es mostrarà quan l'usuari no estigui registrat i hi " +"doni accés." + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu____last_update +msgid "Last Modified on" +msgstr "" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__user_logged +msgid "Visible for logged Users" +msgstr "Visible per als usuaris registrats" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__user_not_logged +msgid "Visible for public Users" +msgstr "Visible per als usuaris públics" + +#. module: website_menu_by_user_status +#: model:ir.model,name:website_menu_by_user_status.model_website_menu +msgid "Website Menu" +msgstr "Menú del lloc web" diff --git a/website_menu_by_user_status/i18n/es.po b/website_menu_by_user_status/i18n/es.po new file mode 100644 index 0000000000..008b5727cf --- /dev/null +++ b/website_menu_by_user_status/i18n/es.po @@ -0,0 +1,64 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_menu_by_user_status +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-02-23 12:45+0000\n" +"Last-Translator: claudiagn \n" +"Language-Team: none\n" +"Language: es\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.3.2\n" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__display_name +msgid "Display Name" +msgstr "" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__id +msgid "ID" +msgstr "" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,help:website_menu_by_user_status.field_website_menu__user_logged +msgid "" +"If checked, the menu will be displayed when the user is logged and give " +"access." +msgstr "" +"Si se marca, el menú se mostrará cuando el usuario inicie sesión y dé acceso." + +#. module: website_menu_by_user_status +#: model:ir.model.fields,help:website_menu_by_user_status.field_website_menu__user_not_logged +msgid "" +"If checked, the menu will be displayed when the user is not logged and give " +"access." +msgstr "" +"Si se marca, el menú se mostrará cuando el usuario no esté registrado y no " +"le dé acceso." + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu____last_update +msgid "Last Modified on" +msgstr "" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__user_logged +msgid "Visible for logged Users" +msgstr "Visible para usuarios registrados" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__user_not_logged +msgid "Visible for public Users" +msgstr "Visible para usuarios públicos" + +#. module: website_menu_by_user_status +#: model:ir.model,name:website_menu_by_user_status.model_website_menu +msgid "Website Menu" +msgstr "Menú del sitio web" diff --git a/website_menu_by_user_status/i18n/es_AR.po b/website_menu_by_user_status/i18n/es_AR.po new file mode 100644 index 0000000000..e5176492e0 --- /dev/null +++ b/website_menu_by_user_status/i18n/es_AR.po @@ -0,0 +1,65 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_menu_by_user_status +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-09-05 07:07+0000\n" +"Last-Translator: Ignacio Buioli \n" +"Language-Team: none\n" +"Language: es_AR\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.3.2\n" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__display_name +msgid "Display Name" +msgstr "Nombre Mostrado" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__id +msgid "ID" +msgstr "ID" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,help:website_menu_by_user_status.field_website_menu__user_logged +msgid "" +"If checked, the menu will be displayed when the user is logged and give " +"access." +msgstr "" +"Si está marcado, el menú se mostrará cuando el usuario inicie sesión y dé " +"acceso." + +#. module: website_menu_by_user_status +#: model:ir.model.fields,help:website_menu_by_user_status.field_website_menu__user_not_logged +msgid "" +"If checked, the menu will be displayed when the user is not logged and give " +"access." +msgstr "" +"Si está marcado, el menú se mostrará cuando el usuario no haya iniciado " +"sesión y le dé acceso." + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu____last_update +msgid "Last Modified on" +msgstr "Última Modificación el" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__user_logged +msgid "Visible for logged Users" +msgstr "Visible para usuarios logeados" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__user_not_logged +msgid "Visible for public Users" +msgstr "Visible para Usuarios públicos" + +#. module: website_menu_by_user_status +#: model:ir.model,name:website_menu_by_user_status.model_website_menu +msgid "Website Menu" +msgstr "Menú del Sitio Web" diff --git a/website_menu_by_user_status/i18n/it.po b/website_menu_by_user_status/i18n/it.po new file mode 100644 index 0000000000..c638225d90 --- /dev/null +++ b/website_menu_by_user_status/i18n/it.po @@ -0,0 +1,65 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_menu_by_user_status +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-12-27 17:45+0000\n" +"Last-Translator: mymage \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.14.1\n" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__id +msgid "ID" +msgstr "ID" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,help:website_menu_by_user_status.field_website_menu__user_logged +msgid "" +"If checked, the menu will be displayed when the user is logged and give " +"access." +msgstr "" +"Se selezionato, il menu verrà visualizzato quando l'utente è registrato e " +"concede l'accesso." + +#. module: website_menu_by_user_status +#: model:ir.model.fields,help:website_menu_by_user_status.field_website_menu__user_not_logged +msgid "" +"If checked, the menu will be displayed when the user is not logged and give " +"access." +msgstr "" +"Se selezionato, il menu verrà visualizzato quando l'utente non è registrato " +"e concede l'accesso." + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__user_logged +msgid "Visible for logged Users" +msgstr "Visibile per gli utenti registrati" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__user_not_logged +msgid "Visible for public Users" +msgstr "Visibile agli utenti pubblici" + +#. module: website_menu_by_user_status +#: model:ir.model,name:website_menu_by_user_status.model_website_menu +msgid "Website Menu" +msgstr "Menu sito web" diff --git a/website_menu_by_user_status/i18n/website_menu_by_user_status.pot b/website_menu_by_user_status/i18n/website_menu_by_user_status.pot new file mode 100644 index 0000000000..4a2b0cb42d --- /dev/null +++ b/website_menu_by_user_status/i18n/website_menu_by_user_status.pot @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_menu_by_user_status +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.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: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__display_name +msgid "Display Name" +msgstr "" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__id +msgid "ID" +msgstr "" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,help:website_menu_by_user_status.field_website_menu__user_logged +msgid "" +"If checked, the menu will be displayed when the user is logged and give " +"access." +msgstr "" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,help:website_menu_by_user_status.field_website_menu__user_not_logged +msgid "" +"If checked, the menu will be displayed when the user is not logged and give " +"access." +msgstr "" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu____last_update +msgid "Last Modified on" +msgstr "" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__user_logged +msgid "Visible for logged Users" +msgstr "" + +#. module: website_menu_by_user_status +#: model:ir.model.fields,field_description:website_menu_by_user_status.field_website_menu__user_not_logged +msgid "Visible for public Users" +msgstr "" + +#. module: website_menu_by_user_status +#: model:ir.model,name:website_menu_by_user_status.model_website_menu +msgid "Website Menu" +msgstr "" diff --git a/website_menu_by_user_status/models/__init__.py b/website_menu_by_user_status/models/__init__.py new file mode 100644 index 0000000000..28a1362d67 --- /dev/null +++ b/website_menu_by_user_status/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import website_menu diff --git a/website_menu_by_user_status/models/website_menu.py b/website_menu_by_user_status/models/website_menu.py new file mode 100644 index 0000000000..05a9a8f30d --- /dev/null +++ b/website_menu_by_user_status/models/website_menu.py @@ -0,0 +1,41 @@ +# Copyright 2013-2017 Savoir-faire Linux () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class WebsiteMenu(models.Model): + """Improve website.menu with adding booleans that drive + if the menu is displayed when the user is logger or not. + """ + + _inherit = "website.menu" + + user_logged = fields.Boolean( + string="Visible for logged Users", + default=True, + help="If checked, " + "the menu will be displayed when the user is logged " + "and give access.", + ) + + user_not_logged = fields.Boolean( + string="Visible for public Users", + default=True, + help="If checked, " + "the menu will be displayed when the user is not logged " + "and give access.", + ) + + def _compute_visible(self): + # pylint: disable=missing-return + """Display the menu item whether the user is logged or not.""" + super()._compute_visible() + for menu in self: + if not menu.is_visible: + continue + + if self.env.user == self.env.ref("base.public_user"): + menu.is_visible = menu.user_not_logged + else: + menu.is_visible = menu.user_logged diff --git a/website_menu_by_user_status/readme/CONTRIBUTORS.rst b/website_menu_by_user_status/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..87066bfb26 --- /dev/null +++ b/website_menu_by_user_status/readme/CONTRIBUTORS.rst @@ -0,0 +1,5 @@ +* Bruno Joliveau +* Jordi Riera +* Meyomesse Gilles +* David Dufresne +* Kaushal Prajapati diff --git a/website_menu_by_user_status/readme/DESCRIPTION.rst b/website_menu_by_user_status/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..ac13753c55 --- /dev/null +++ b/website_menu_by_user_status/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +The module manages display website menu entries, depending if the user is +logged or not. +The selection of the display status can be chosen logged and/or not. diff --git a/website_menu_by_user_status/readme/ROADMAP.rst b/website_menu_by_user_status/readme/ROADMAP.rst new file mode 100644 index 0000000000..43b36e8901 --- /dev/null +++ b/website_menu_by_user_status/readme/ROADMAP.rst @@ -0,0 +1 @@ +* 2 flags will just toggle specific groups automatically [based on https://github.com/OCA/website/tree/11.0/website_menu_permission] diff --git a/website_menu_by_user_status/readme/USAGE.rst b/website_menu_by_user_status/readme/USAGE.rst new file mode 100644 index 0000000000..f68329ac61 --- /dev/null +++ b/website_menu_by_user_status/readme/USAGE.rst @@ -0,0 +1,7 @@ +To use this module, you need to: + +#. Go to Website > Configuration > Settings > Pages. +#. Select the page for which you would like to hide the menu. +#. In the `Related Menu Items` table, check whether the menu item is visible for logged/unlogged users. + +#. remove default filter to edit website menu line diff --git a/website_menu_by_user_status/static/description/icon.png b/website_menu_by_user_status/static/description/icon.png new file mode 100644 index 0000000000..d7b9f4f25b Binary files /dev/null and b/website_menu_by_user_status/static/description/icon.png differ diff --git a/website_menu_by_user_status/static/description/index.html b/website_menu_by_user_status/static/description/index.html new file mode 100644 index 0000000000..9a9e40ba31 --- /dev/null +++ b/website_menu_by_user_status/static/description/index.html @@ -0,0 +1,444 @@ + + + + + +Website Menu By User Display + + + +
+

Website Menu By User Display

+ + +

Beta License: AGPL-3 OCA/website Translate me on Weblate Try me on Runboat

+

The module manages display website menu entries, depending if the user is +logged or not. +The selection of the display status can be chosen logged and/or not.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Go to Website > Configuration > Settings > Pages.
  2. +
  3. Select the page for which you would like to hide the menu.
  4. +
  5. In the Related Menu Items table, check whether the menu item is visible for logged/unlogged users.
  6. +
  7. remove default filter to edit website menu line
  8. +
+
+
+

Known issues / Roadmap

+ +
+
+

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

+
    +
  • Savoir-faire Linux
  • +
+
+
+

Contributors

+ +
+
+

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.

+

This module is part of the OCA/website project on GitHub.

+

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

+
+
+
+ + diff --git a/website_menu_by_user_status/tests/__init__.py b/website_menu_by_user_status/tests/__init__.py new file mode 100644 index 0000000000..53ac973554 --- /dev/null +++ b/website_menu_by_user_status/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2018 David Dufresne +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_website_menu diff --git a/website_menu_by_user_status/tests/test_website_menu.py b/website_menu_by_user_status/tests/test_website_menu.py new file mode 100644 index 0000000000..f768e59c73 --- /dev/null +++ b/website_menu_by_user_status/tests/test_website_menu.py @@ -0,0 +1,57 @@ +# Copyright 2018 David Dufresne +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests import SavepointCase + + +class TestWebsiteMenu(SavepointCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.page = cls.env.ref("website.contactus_page") + cls.page.is_visible = False + + cls.menu = cls.env.ref("website.menu_contactus") + cls.menu.user_logged = False + cls.menu.user_not_logged = False + + cls.public_user = cls.env.ref("base.public_user") + group_id = cls.env.ref("website.group_website_designer") + cls.public_user.groups_id = (4, group_id.id) + cls.demo_user = cls.env.ref("base.user_demo") + + def test_visible_user_logged_demo(self): + self.page.is_visible = True + self.menu.user_logged = True + self.assertTrue(self.menu.with_user(self.demo_user).is_visible) + + def test_visible_user_logged_public(self): + self.page.is_visible = True + self.menu.user_logged = True + self.assertFalse(self.menu.with_user(self.public_user).is_visible) + + def test_visible_user_not_logged_demo(self): + self.page.is_visible = True + self.user_not_logged = True + self.assertFalse(self.menu.with_user(self.demo_user).is_visible) + + def test_visible_user_not_logged_public(self): + self.page.is_visible = True + self.user_not_logged = True + self.assertFalse(self.menu.with_user(self.public_user).is_visible) + + def test_not_visible_user_logged_demo(self): + self.menu.user_logged = True + self.assertTrue(self.menu.with_user(self.demo_user).is_visible) + + def test_not_visible_user_logged_public(self): + self.menu.user_logged = True + self.assertFalse(self.menu.with_user(self.public_user).is_visible) + + def test_not_visible_user_not_logged_demo(self): + self.user_not_logged = True + self.assertFalse(self.menu.with_user(self.demo_user).is_visible) + + def test_not_visible_user_not_logged_public(self): + self.user_not_logged = True + self.assertFalse(self.menu.with_user(self.public_user).is_visible) diff --git a/website_menu_by_user_status/views/website_menu.xml b/website_menu_by_user_status/views/website_menu.xml new file mode 100644 index 0000000000..f96bea3570 --- /dev/null +++ b/website_menu_by_user_status/views/website_menu.xml @@ -0,0 +1,27 @@ + + + + + Website.menu: Display to user booleans + website.menu + + + + + + + + + + Website.menu: Display to user booleans + website.menu + + + + + + + + +