Skip to Content
Menu
This question has been flagged
3286 Views

Trying to change text in a user's login textfield to lowercase as they're typing.

When users login on their phones, the first letter in their email is autocapitalized. Therefore, we want to change the uppercase letters so that the credentials they submit match the credentials saved in our database.

We've already started developing a module to do this, but as of right now it only changes emails in our database (IE when they create accounts with uppercase letters in emails), but we want to make it so that their typing gets converted to lowercase before they submit their login credentials.

Here is the current code snippet:

_________________________________________________________________________________

###Changes usernames (emails) of clients to be all lowercase, thus eliminating

##discrepencies between what users input and what is in our database

##Created 29 March, 2017 by Spencer Burnside & Grayson Doherty


from openerp import models, api class Users(models.Model):

    _inherit = 'res.users'


    @api.model

    def create(self, vals):

        if vals.get('login', False):

            vals['login'] = vals.get('login', '').lower()

        return super(Users, self).create(vals)


    @api.multi

    def write(self, vals):

        if vals.get('login', False):

            vals['login'] = vals.get('login', '').lower()

        return super(Users, self).write(vals)

_________________________________________________________________________________
Avatar
Discard