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.

25 lines
872 B

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