İçereği Atla
Menü
Bu soru işaretlendi
4 Cevaplar
2842 Görünümler

Hi!!

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

Pleas, how can i do it help

Avatar
Vazgeç

Elaborate your purpose little bit please !

Üretici

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.

En İyi Yanıt

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()
Avatar
Vazgeç
En İyi Yanıt


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)

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
0
Mar 25
1268
0
Oca 25
3326
1
Ağu 23
14628
change password Çözüldü
1
Ağu 23
13267
1
Tem 23
10287