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
875 B

  1. # -*- coding: utf-8 -*-
  2. # © 2012 Therp BV (<http://therp.nl>)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/gpl.html).
  4. from odoo import models, fields, api
  5. class CompanyLDAPPopulateWizard(models.TransientModel):
  6. _name = 'res.company.ldap.populate_wizard'
  7. _description = 'Populate users from LDAP'
  8. name = fields.Char('Name', size=16)
  9. ldap_id = fields.Many2one(
  10. 'res.company.ldap',
  11. 'LDAP Configuration'
  12. )
  13. users_created = fields.Integer(
  14. 'Number of users created',
  15. readonly=True
  16. )
  17. @api.model
  18. @api.returns('self', lambda value: value.id)
  19. def create(self, vals):
  20. if 'ldap_id' in vals:
  21. ldap = self.env['res.company.ldap'].browse(vals['ldap_id'])
  22. vals['users_created'] = ldap.action_populate()
  23. return super(CompanyLDAPPopulateWizard, self).create(vals)