From ea329ba9e5ae6be8292b7df5ea6d9a59fa1332d4 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 27 Sep 2018 18:11:00 +0200 Subject: [PATCH] [ADD] portal_partner_select_all: New module --- portal_partner_select_all/README.rst | 89 +++++++++++++++++++ portal_partner_select_all/__init__.py | 3 + portal_partner_select_all/__manifest__.py | 20 +++++ .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 5 ++ portal_partner_select_all/readme/USAGE.rst | 8 ++ portal_partner_select_all/wizard/__init__.py | 4 + .../wizard/portal_wizard.py | 27 ++++++ .../wizard/portal_wizard.xml | 19 ++++ 9 files changed, 176 insertions(+) create mode 100644 portal_partner_select_all/README.rst create mode 100644 portal_partner_select_all/__init__.py create mode 100644 portal_partner_select_all/__manifest__.py create mode 100644 portal_partner_select_all/readme/CONTRIBUTORS.rst create mode 100644 portal_partner_select_all/readme/DESCRIPTION.rst create mode 100644 portal_partner_select_all/readme/USAGE.rst create mode 100644 portal_partner_select_all/wizard/__init__.py create mode 100644 portal_partner_select_all/wizard/portal_wizard.py create mode 100644 portal_partner_select_all/wizard/portal_wizard.xml diff --git a/portal_partner_select_all/README.rst b/portal_partner_select_all/README.rst new file mode 100644 index 000000000..2693fdb47 --- /dev/null +++ b/portal_partner_select_all/README.rst @@ -0,0 +1,89 @@ +========================= +Portal Partner Select All +========================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fpartner--contact-lightgray.png?logo=github + :target: https://github.com/OCA/partner-contact/tree/10.0/portal_partner_select_all + :alt: OCA/partner-contact +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/partner-contact-10-0/partner-contact-10-0-portal_partner_select_all + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/134/10.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +When a user wants invite a lot of custumers to the portal it can be a pain to +select them all one by one. + +This module adds a helper in the wizard to toggle between all selected and only +the ones that already exist. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +#. Go to *Contacts* and choose the tree view. +#. Filter the ones you want to invite to the portal. +#. Click on *Action > Portal Access Management* +#. In the wizard there's now a check box to invite to all the contacts in the + list. +#. Set it on and a warning will appear advising all of them will be invited. +#. Set it off again and only the already existing users will be checked. + + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* David Vidal + +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/partner-contact `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/portal_partner_select_all/__init__.py b/portal_partner_select_all/__init__.py new file mode 100644 index 000000000..3b4c3edf0 --- /dev/null +++ b/portal_partner_select_all/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import wizard diff --git a/portal_partner_select_all/__manifest__.py b/portal_partner_select_all/__manifest__.py new file mode 100644 index 000000000..4939666b7 --- /dev/null +++ b/portal_partner_select_all/__manifest__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Tecnativa S.L. - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + 'name': 'Portal Partner Select All', + 'version': '10.0.1.0.1', + 'category': 'Custom', + 'author': 'Tecnativa,' + 'Odoo Community Association (OCA)', + 'website': 'https://www.github.com/OCA/partner-contact', + "license": "AGPL-3", + 'depends': [ + 'portal', + ], + 'data': [ + 'wizard/portal_wizard.xml', + ], + 'installable': True, +} diff --git a/portal_partner_select_all/readme/CONTRIBUTORS.rst b/portal_partner_select_all/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..885d4ba98 --- /dev/null +++ b/portal_partner_select_all/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* David Vidal diff --git a/portal_partner_select_all/readme/DESCRIPTION.rst b/portal_partner_select_all/readme/DESCRIPTION.rst new file mode 100644 index 000000000..6281e8dd6 --- /dev/null +++ b/portal_partner_select_all/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +When a user wants invite a lot of custumers to the portal it can be a pain to +select them all one by one. + +This module adds a helper in the wizard to toggle between all selected and only +the ones that already exist. diff --git a/portal_partner_select_all/readme/USAGE.rst b/portal_partner_select_all/readme/USAGE.rst new file mode 100644 index 000000000..1215bc6f7 --- /dev/null +++ b/portal_partner_select_all/readme/USAGE.rst @@ -0,0 +1,8 @@ +#. Go to *Contacts* and choose the tree view. +#. Filter the ones you want to invite to the portal. +#. Click on *Action > Portal Access Management* +#. In the wizard there's now a check box to invite to all the contacts in the + list. +#. Set it on and a warning will appear advising all of them will be invited. +#. Set it off again and only the already existing users will be checked. + diff --git a/portal_partner_select_all/wizard/__init__.py b/portal_partner_select_all/wizard/__init__.py new file mode 100644 index 000000000..ee3fa9521 --- /dev/null +++ b/portal_partner_select_all/wizard/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import portal_wizard diff --git a/portal_partner_select_all/wizard/portal_wizard.py b/portal_partner_select_all/wizard/portal_wizard.py new file mode 100644 index 000000000..1bef89e2b --- /dev/null +++ b/portal_partner_select_all/wizard/portal_wizard.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class PortalWizard(models.TransientModel): + _inherit = "portal.wizard" + + set_all_users = fields.Boolean( + string="Invite all the contacts", + default=False, + ) + + @api.onchange('set_all_users') + def onchange_set_all_users(self): + """Toggle between select all partners and the default""" + if not self.set_all_users: + for user in self.user_ids: + user.in_portal = ( + user.partner_id.user_ids and + self.portal_id in user.partner_id.user_ids[0].groups_id + ) + else: + not_in_portal = self.user_ids.filtered(lambda x: not x.in_portal) + not_in_portal.update({'in_portal': True}) diff --git a/portal_partner_select_all/wizard/portal_wizard.xml b/portal_partner_select_all/wizard/portal_wizard.xml new file mode 100644 index 000000000..abcc59003 --- /dev/null +++ b/portal_partner_select_all/wizard/portal_wizard.xml @@ -0,0 +1,19 @@ + + + + + portal.wizard + + + + + + +
+ You're about to invite to portal all the contacts list below. +
+
+
+
+ +