我需要检查给定的电子邮件是否与用户相关联
class validate(http.Controller):
@http.route('/cp/validate_email/<email>', auth='none', type='json',website=True)
def validate_user(self,email,**kwargs):
res = http.request.env['res.users'].search([('login','=',email)])
res_validate = False if len(res) > 0 else True
return {'validate': res_validate,}
我收到以下错误:
s = self._fmt % record.__dict__
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 61: ordinal not in range(128)
Logged from file sql_db.py, line 237
2016-05-10 03:48:00,712 23361 ERROR inova openerp.http: Exception during JSON request handling.
.....
ProgrammingError: el operador no existe: integer = boolean
LÍNEA 1: SELECT "parent_id" FROM "res_company" WHERE "id" IN (false)
答案 0 :(得分:1)
只需使用email.encode('utf-8')
而不是email
[('login','=',email)]
,因为电子邮件在您的案例中有一些特殊字符。