You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
893 B

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2018 Tecnativa - David Vidal
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo import api, fields, models
  5. class PortalWizard(models.TransientModel):
  6. _inherit = "portal.wizard"
  7. set_all_users = fields.Boolean(
  8. string="Invite all the contacts",
  9. default=False,
  10. )
  11. @api.onchange('set_all_users')
  12. def onchange_set_all_users(self):
  13. """Toggle between select all partners and the default"""
  14. if not self.set_all_users:
  15. for user in self.user_ids:
  16. user.in_portal = (
  17. user.partner_id.user_ids and
  18. self.portal_id in user.partner_id.user_ids[0].groups_id
  19. )
  20. else:
  21. not_in_portal = self.user_ids.filtered(lambda x: not x.in_portal)
  22. not_in_portal.update({'in_portal': True})