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.

30 lines
1.1 KiB

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