Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
4 Ответы
2857 Представления

Hi!!

I want to controle a field if it contains a space (\t) in odoo v8.

Pleas, how can i do it help

Аватар
Отменить

Elaborate your purpose little bit please !

Автор

I have a field called project in which i wouldnt have empty string so i put it required= True and now i want it to NOT COTAIN a space.

Лучший ответ

You should define a python constraint

_constraints = [(_function_name, warning_string, list_of_relevant_attributes)]
ex :

_constraints = [(_check_empty_string, 'The name cannot contains only spaces", ['name'])
def _check_empty_string(self, cr, uid, ids, context=None) : (old API way)
    project = self.browse(cr,uid, ids, context=context)
    return not project.name.isspace()
Аватар
Отменить
Лучший ответ


for v8 you can write constraint like to validate the space,

	@api.constrains('name')
def check_name(self):
if self.name.isspace():
raise ValidationError("Name can not be Empty")

name = fields.Char('Name', required=True)

Аватар
Отменить
Related Posts Ответы Просмотры Активность
0
мар. 25
1285
0
янв. 25
3376
1
авг. 23
14675
change password Решено
1
авг. 23
13308
1
июл. 23
10334