|
@ -1,7 +1,7 @@ |
|
|
# -*- coding: utf-8 -*- |
|
|
# -*- coding: utf-8 -*- |
|
|
# Copyright 2015-2017 LasLabs Inc. |
|
|
# Copyright 2015-2017 LasLabs Inc. |
|
|
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). |
|
|
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). |
|
|
|
|
|
|
|
|
|
|
|
import collections |
|
|
from odoo import api, fields, models |
|
|
from odoo import api, fields, models |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -32,3 +32,22 @@ class ResUsers(models.Model): |
|
|
if vals.get('login'): |
|
|
if vals.get('login'): |
|
|
vals['login'] = vals['login'].lower() |
|
|
vals['login'] = vals['login'].lower() |
|
|
return super(ResUsers, self).write(vals) |
|
|
return super(ResUsers, self).write(vals) |
|
|
|
|
|
|
|
|
|
|
|
@api.model |
|
|
|
|
|
def search(self, args, offset=0, limit=None, order=None, count=False): |
|
|
|
|
|
"""Modifies all search domains to replace login with login.lower().""" |
|
|
|
|
|
new_args = [] |
|
|
|
|
|
for arg in args: |
|
|
|
|
|
new_arg = arg |
|
|
|
|
|
if len(arg) == 3 and arg[0] == 'login': |
|
|
|
|
|
new_rvalue = arg[2] |
|
|
|
|
|
if hasattr(arg[2], 'lower'): |
|
|
|
|
|
new_rvalue = arg[2].lower() |
|
|
|
|
|
elif isinstance(arg[2], collections.Iterable): |
|
|
|
|
|
new_rvalue = [getattr( |
|
|
|
|
|
x, 'lower', lambda: x)() for x in arg[2]] |
|
|
|
|
|
new_arg = (new_arg[0], new_arg[1], new_rvalue) |
|
|
|
|
|
new_args.append(new_arg) |
|
|
|
|
|
return super(ResUsers, self).search( |
|
|
|
|
|
args=new_args, offset=offset, limit=limit, |
|
|
|
|
|
order=order, count=count) |