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.

26 lines
1.0 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('groups_id')
  17. self.user_ids |= self.env['portal.wizard.user'].new({
  18. 'partner_id': contact.id,
  19. 'email': contact.email,
  20. 'in_portal': in_portal,
  21. })