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.

24 lines
850 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 = user.partner_id.user_ids and user.partner_id.user_ids[
  16. 0
  17. ].has_group("base.group_portal")
  18. else:
  19. not_in_portal = self.user_ids.filtered(lambda x: not x.in_portal)
  20. not_in_portal.update({"in_portal": True})