diff --git a/portal_partner_select_all/README.rst b/portal_partner_select_all/README.rst index a5540c890..5c5edeced 100644 --- a/portal_partner_select_all/README.rst +++ b/portal_partner_select_all/README.rst @@ -23,9 +23,9 @@ Portal Partner Select All :target: https://runbot.odoo-community.org/runbot/134/12.0 :alt: Try me on Runbot -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| -When a user wants invite a lot of custumers to the portal it can be a pain to +When a user wants invite a lot of customers 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 diff --git a/portal_partner_select_all/__manifest__.py b/portal_partner_select_all/__manifest__.py index 9633ff2c9..64b8c2257 100644 --- a/portal_partner_select_all/__manifest__.py +++ b/portal_partner_select_all/__manifest__.py @@ -1,5 +1,5 @@ # Copyright 2018 Tecnativa - David Vidal -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { 'name': 'Portal Partner Select All', 'version': '12.0.1.0.1', diff --git a/portal_partner_select_all/readme/DESCRIPTION.rst b/portal_partner_select_all/readme/DESCRIPTION.rst index 6281e8dd6..8e509703d 100644 --- a/portal_partner_select_all/readme/DESCRIPTION.rst +++ b/portal_partner_select_all/readme/DESCRIPTION.rst @@ -1,4 +1,4 @@ -When a user wants invite a lot of custumers to the portal it can be a pain to +When a user wants invite a lot of customers 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 diff --git a/portal_partner_select_all/static/description/index.html b/portal_partner_select_all/static/description/index.html index 14853463f..788cd0631 100644 --- a/portal_partner_select_all/static/description/index.html +++ b/portal_partner_select_all/static/description/index.html @@ -368,7 +368,7 @@ ul.auto-toc { !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/partner-contact Translate me on Weblate Try me on Runbot

-

When a user wants invite a lot of custumers to the portal it can be a pain to +

When a user wants invite a lot of customers 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/tests/__init__.py b/portal_partner_select_all/tests/__init__.py new file mode 100644 index 000000000..ef4dfc103 --- /dev/null +++ b/portal_partner_select_all/tests/__init__.py @@ -0,0 +1 @@ +from . import test_portal_partner_select_all diff --git a/portal_partner_select_all/tests/test_portal_partner_select_all.py b/portal_partner_select_all/tests/test_portal_partner_select_all.py new file mode 100644 index 000000000..5f7e7eb9d --- /dev/null +++ b/portal_partner_select_all/tests/test_portal_partner_select_all.py @@ -0,0 +1,39 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo.tests import common, Form + + +class TestPortalPartnerSelctAll(common.TransactionCase): + + def setUp(self): + super().setUp() + + Partner = self.env["res.partner"] + self.partner1 = Partner.create({'name': 'P1', 'email': 'p1@p1'}) + self.partner2 = Partner.create({'name': 'P2', 'email': 'p2@p2'}) + self.partner3 = Partner.create({'name': 'P3', 'email': 'p3@p3'}) + self.wizard_all = self.env["portal.wizard"].with_context({ + 'active_ids': [self.partner1.id, self.partner2.id] + }).create({}) + self.wizard_default = self.env["portal.wizard"].with_context({ + 'active_ids': [self.partner1.id, self.partner2.id, self.partner3.id] + }).create({}) + + def test_portal_partner_select_all_wizard(self): + # check selecting all + wizard_all_form = Form(self.wizard_all) + wizard_all_form.set_all_users = True + w = wizard_all_form.save() + w.action_apply() + # partner should have user records with assigned portal group + self.assertTrue(self.partner1.user_ids, "Partner should have user") + self.assertTrue(self.partner2.user_ids, "Partner should have user") + self.assertTrue(self.partner1.user_ids[0].has_group('base.group_portal')) + self.assertTrue(self.partner2.user_ids[0].has_group('base.group_portal')) + + # checking toogle + wizard_default_form = Form(self.wizard_default) + wizard_default_form.set_all_users = True + wizard_default_form.set_all_users = False + w = wizard_default_form.save() + w.action_apply() + self.assertFalse(self.partner3.user_ids, "Partner shouldn't have a user") diff --git a/portal_partner_select_all/wizard/__init__.py b/portal_partner_select_all/wizard/__init__.py index b922ddc32..cc61a5f86 100644 --- a/portal_partner_select_all/wizard/__init__.py +++ b/portal_partner_select_all/wizard/__init__.py @@ -1,2 +1,2 @@ -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License AGPL-3.0 or later (https://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 index aabdb8038..aa208db45 100644 --- a/portal_partner_select_all/wizard/portal_wizard.py +++ b/portal_partner_select_all/wizard/portal_wizard.py @@ -1,5 +1,5 @@ # Copyright 2018 Tecnativa - David Vidal -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from odoo import api, fields, models @@ -18,7 +18,7 @@ class PortalWizard(models.TransientModel): 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 + user.partner_id.user_ids[0].has_group("base.group_portal") ) else: not_in_portal = self.user_ids.filtered(lambda x: not x.in_portal)