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.

21 lines
828 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(string="Invite all the contacts", default=False,)
  7. @api.onchange("set_all_users")
  8. def onchange_set_all_users(self):
  9. """Toggle between select all partners and the default"""
  10. if not self.set_all_users:
  11. for user in self.user_ids:
  12. user.in_portal = user.partner_id.user_ids and user.partner_id.user_ids[
  13. 0
  14. ].has_group("base.group_portal")
  15. else:
  16. not_in_portal = self.user_ids.filtered(lambda x: not x.in_portal)
  17. not_in_portal.update({"in_portal": True})