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.

24 lines
856 B

  1. # -*- coding: utf-8 -*-
  2. # (c) 2015 Antiun Ingeniería S.L. - Sergio Teruel
  3. # (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden
  4. # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
  5. from openerp import models, api
  6. class ResUsers(models.Model):
  7. _inherit = "res.users"
  8. @api.model
  9. def _signup_create_user(self, values):
  10. account_type = values.get('account_type', False)
  11. if 'account_type' in values:
  12. values.pop('account_type')
  13. res = super(ResUsers, self)._signup_create_user(values)
  14. if isinstance(res, int):
  15. user = self.env['res.users'].browse(res)
  16. if account_type == 'supplier':
  17. user.partner_id.supplier = True
  18. user.groups_id = user.groups_id | self.env.ref(
  19. 'auth_supplier.group_auth_supplier')
  20. return res