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.

28 lines
1.1 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. from odoo import api, models
  2. class BeesdooWizard(models.TransientModel):
  3. _inherit = "portal.wizard"
  4. @api.onchange("portal_id")
  5. def onchange_portal(self):
  6. # for each partner, determine corresponding portal.wizard.user records
  7. res_partner = self.env["res.partner"]
  8. partner_ids = self._context.get("active_ids", [])
  9. contact_ids = set()
  10. for partner in res_partner.browse(partner_ids):
  11. for contact in partner.child_ids | partner:
  12. # make sure that each contact appears at most once in the list
  13. if contact.id not in contact_ids:
  14. contact_ids.add(contact.id)
  15. in_portal = self.portal_id in contact.user_ids.mapped(
  16. "groups_id"
  17. )
  18. self.user_ids |= self.env["portal.wizard.user"].new(
  19. {
  20. "partner_id": contact.id,
  21. "email": contact.email,
  22. "in_portal": in_portal,
  23. }
  24. )